(function () { "use strict"; angular.module('streamApp').controller("timelineController", TimelineController); TimelineController.$inject = ['$scope', 'streamService', 'timelineService', '$routeParams', '$location']; function TimelineController($scope, streamService, timelineService, $routeParams, $location) { $scope.id = $routeParams.id || 0; if ($scope.id) { timelineService.get($scope.id).then((timeline) => $scope.timeline = timeline); } timelineService.getAll().then((timelines) => { if (!$scope.id) { $scope.timeline = $scope.timelines[0] || {}; $scope.Id = $scope.timeline.Id; } let id = parseInt($scope.id); $scope.timelines = timelines.map(x => { return { Id: x.Id, Name: x.Name, Selected: x.Id === id }; }); }); $scope.callback = streamService.getTimeline; $scope.callbackPrompt = function (prompt) { $location.url(`/memory/add?timelineId=${$scope.id}&questionId=${prompt.promptId}`); } $scope.selectTimeline = function () { $scope.showSelectTimeline = !$scope.showSelectTimeline; } $scope.updateTimeline = function (item) { $scope.selectTimeline(); $location.url('/timelines/' + item.Id); } } })();