-
-
Save miickel/ed1e54afbc1923263b83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
angular | |
.module('remente.widgets') | |
.directive('reGoalPlan', reGoalPlan); | |
/* @ngInject */ | |
function reGoalPlan( | |
$timeout, | |
$ionicModal, | |
goalHelpers, | |
moment | |
) { | |
return { | |
restrict: 'E', | |
templateUrl: 'widgets/goal-plan.html', | |
link: link, | |
replace: true, | |
scope: { | |
goal: '=', | |
goalOptions: '=' | |
} | |
}; | |
function link(scope, element, attr) { | |
scope.addStep = addStepHandler; | |
scope.editStep = editStepHandler; | |
$ionicModal | |
.fromTemplateUrl('goals/goals.create.step.edit.modal.html', { | |
scope: scope, | |
animation: 'slide-in-up' | |
}) | |
.then(modalCreatedHandler); | |
function modalCreatedHandler(modal) { | |
scope.modal = modal; | |
} | |
function addStepHandler() { | |
var step = goalHelpers.getNewStep(scope.goal); | |
scope.goal.tasks.push(step); | |
$timeout(function () { | |
editStepHandler(step); | |
}, 300); | |
} | |
function editStepHandler(step) { | |
scope.today = moment().toDate(); | |
scope.currentStep = step; | |
currentStepBeforeEdit = angular.copy(step); | |
if (!step.title) { | |
scope.focusStepTitle = true; | |
} | |
scope.modal.show(); | |
$timeout(function () { | |
scope.focusStepTitle = false; | |
}, 300); | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment