Skip to content

Commit

Permalink
finished creating schedule workout modal
Browse files Browse the repository at this point in the history
  • Loading branch information
abarnhard committed Jan 3, 2015
1 parent a2f3b88 commit 9a5263f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 66 deletions.
63 changes: 2 additions & 61 deletions client/views/schedule/modals/add_modal.jade
Original file line number Diff line number Diff line change
Expand Up @@ -44,64 +44,5 @@
.row.padded-row
.small-12.columns
button.button.success(href='', ng-click='addToSchedule(selectedWorkout)', ng-disabled='!selectedWorkout') Add
a.close-reveal-modal x

//-
.row
.columns.small-12
.row.collapse.padded-row
.small-4.columns
select(ng-model='regime', name='regime', ng-options='r as r.name for r in regimes | orderBy:\'name\'')
option(value='') Select a Regime
.small-1.columns
a.button.success.postfix(href='', ng-click='showModal(\'#regimeModal\')') +
.small-1.columns
|  
.small-4.columns
div(ng-show='regime')
select(ng-model='phase', name='phase', ng-options='p as p.name for p in phases | orderBy:\'name\'')
option(value='') Select a Phase
.small-1.columns
div(ng-show='regime')
a.button.success.postfix(href='', ng-click='showModal(\'#phaseModal\')') +
.small-1.columns
|  
.row
.columns.small-12
form(ng-show='regime')
fieldset
legend {{regime.name}}
fieldset(ng-show='phase')
legend {{phase.name}}
fieldset
legend
| Workouts  
a.label.success.round(href='', ng-click='showModal(\'#workoutModal\')') +
|  
.row(ng-show='workouts.length')
.columns.small-12
ul.pricing-table(ng-repeat='workout in workouts')
li.title
| {{workout.workoutName}}
a.label.alert.round(href='', ng-click='deleteWorkout(workout, $index)') X
li.bullet-item
table
thead
tr
th(width='75') Sets
th Exercises
th(width='150') Reps
th(width='150') Weight
th(width='150') Rest
tbody
tr(ng-repeat='set in workout.sets')
td {{set.count}}
td(colspan='3')
table
tbody
tr(ng-repeat='exercise in set.exercises')
td {{exercise.name}}
td(width='150') {{exercise.reps}} {{exercise.type}}
td(width='150') {{exercise.weight}} lbs
td {{set.rest}} Sec
p(ng-show='!workouts.length') Add A Workout

a.close-reveal-modal x
2 changes: 1 addition & 1 deletion client/views/schedule/modals/edit_modal.jade
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
h3 Update Workout
.row.padded-row
.small-12.columns
pre {{selectedWorkout | json}}
pre {{selectedLiftDay | json}}
a.close-reveal-modal x
9 changes: 6 additions & 3 deletions client/views/schedule/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
$scope.workouts = [];
$scope.regime = null;
$scope.phase = null;
$scope.selectedLiftDay = null;
$scope.selectedWorkout = null;

// define querys for workouts modals
Expand Down Expand Up @@ -60,16 +61,18 @@
}

function editEvent(obj){
var index = findEventIndex(obj.start, $scope.workouts);
$scope.$apply(function(){$scope.selectedWorkout = $scope.liftDays[index];});
// input is either a moment object or an event object with a moment date in .start
var index = findEventIndex((obj.start || obj), $scope.liftDays);
$scope.$apply(function(){$scope.selectedLiftDay = $scope.liftDays[index];});
showModal('#editModal');
}

$scope.clickHandler = function(obj){
// if it has a title, user clicked on an event
if(obj.title){
editEvent(obj);
}else{
if(hasEventScheduled(obj, $scope.workouts)){
if(hasEventScheduled(obj, $scope.liftDays)){
editEvent(obj);
}else{
$scope.$apply(function(){$scope.selectedDate = obj.format();});
Expand Down
2 changes: 1 addition & 1 deletion db/tables/days.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE TABLE days(
id serial PRIMARY KEY,
date date NOT NULL,
start date NOT NULL,
workout_id integer NOT NULL REFERENCES workouts(id),
phase_id integer NOT NULL REFERENCES phases(id)
);

0 comments on commit 9a5263f

Please sign in to comment.