Skip to content

Commit

Permalink
Implementing workout form
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodeDestroyer committed Feb 15, 2015
1 parent c459326 commit f19d1df
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions www/js/workout/controllers/wrkDetailCtrl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('arete.controllers').controller('wrkDetailCtrl', function ($scope, $translate, $stateParams, Workout) {
angular.module('arete.controllers').controller('wrkDetailCtrl', function ($q, $scope, $translate, $stateParams, Workout) {
'use strict';

var vm = this;
Expand All @@ -13,8 +13,6 @@ angular.module('arete.controllers').controller('wrkDetailCtrl', function ($scope
];
vm.workout.selectedRepeatType = _.first(vm.repeatList).id;



for (var i = 1; i < 8; i++) {
var day = { id: i, label: 'general.days.' + i };
vm.days.push(day);
Expand All @@ -34,7 +32,14 @@ angular.module('arete.controllers').controller('wrkDetailCtrl', function ($scope
};

vm.saveWorkout = function (workoutModel) {
var workout,
saveEntity(workoutModel).then(function() {
//notify and redirect or some other shit
});
};

function saveEntity(workoutModel) {
var deferred = $q.defer(),
workout,
repeatDaysArray = [];

if (vm.workout.id) {
Expand Down Expand Up @@ -71,6 +76,12 @@ angular.module('arete.controllers').controller('wrkDetailCtrl', function ($scope
workout.repeatedDays = repeatDaysArray;
}

};
persistence.flush(function() {
deferred.resolve();
});

return deferred.promise;
}


});

0 comments on commit f19d1df

Please sign in to comment.