(function () { "use strict"; var streamApp = angular.module('streamApp'); streamApp.directive('timelineEditDirective', ['timelineService', '$window', '$routeParams', TimelineEditDirective]); function TimelineEditDirective(timelineService, $window, $routeParams) { return { restrict: 'E', scope: { callback: '=' }, templateUrl: '/App/Directives/timelines/timelineAddDirective/timelineAddDirective.html?v=6.0.0c', link: function (scope, element, attrs, tabsCtrl) { scope.title = "Edit Name of Storyline"; scope.saveAction = "Save"; timelineService.get($routeParams.id).then(timeline => { scope.name = timeline.Name; scope.description = timeline.description; }); scope.submit = function () { if (scope.name && scope.name.length > 1) { timelineService.update($routeParams.id, scope.name, scope.description) .then(() => { if (scope.callback) { scope.callback(); } else { scope.cancel(); } }); } } scope.cancel = function () { scope.name = ''; scope.description = ''; $window.history.back(); } } }; } }());