Skip to content

Instantly share code, notes, and snippets.

@miickel
Created August 26, 2015 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miickel/ed1e54afbc1923263b83 to your computer and use it in GitHub Desktop.
Save miickel/ed1e54afbc1923263b83 to your computer and use it in GitHub Desktop.
(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