From 9a5263f1cffc2c10c9f494cd93b307e0b333de1a Mon Sep 17 00:00:00 2001 From: Adam Barnhard Date: Sat, 3 Jan 2015 17:47:09 -0600 Subject: [PATCH] finished creating schedule workout modal --- client/views/schedule/modals/add_modal.jade | 63 +------------------- client/views/schedule/modals/edit_modal.jade | 2 +- client/views/schedule/schedule.js | 9 ++- db/tables/days.sql | 2 +- 4 files changed, 10 insertions(+), 66 deletions(-) diff --git a/client/views/schedule/modals/add_modal.jade b/client/views/schedule/modals/add_modal.jade index 73b1257..baa7cb7 100644 --- a/client/views/schedule/modals/add_modal.jade +++ b/client/views/schedule/modals/add_modal.jade @@ -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 \ No newline at end of file + + a.close-reveal-modal x \ No newline at end of file diff --git a/client/views/schedule/modals/edit_modal.jade b/client/views/schedule/modals/edit_modal.jade index 79c94f7..599eaf1 100644 --- a/client/views/schedule/modals/edit_modal.jade +++ b/client/views/schedule/modals/edit_modal.jade @@ -4,5 +4,5 @@ h3 Update Workout .row.padded-row .small-12.columns - pre {{selectedWorkout | json}} + pre {{selectedLiftDay | json}} a.close-reveal-modal x diff --git a/client/views/schedule/schedule.js b/client/views/schedule/schedule.js index 21aea2a..051f6ff 100644 --- a/client/views/schedule/schedule.js +++ b/client/views/schedule/schedule.js @@ -17,6 +17,7 @@ $scope.workouts = []; $scope.regime = null; $scope.phase = null; + $scope.selectedLiftDay = null; $scope.selectedWorkout = null; // define querys for workouts modals @@ -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();}); diff --git a/db/tables/days.sql b/db/tables/days.sql index 366329d..2296369 100644 --- a/db/tables/days.sql +++ b/db/tables/days.sql @@ -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) );