This repository was archived by the owner on Sep 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathTask.js
90 lines (82 loc) · 2.4 KB
/
Task.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
Task Module
============
*/
var module = angular.module('App.Task', ['App.Project', 'ui.router']);
module.config( ($stateProvider) => {
$stateProvider.state( 'tasks', {
parent: 'project',
url: '/tasks',
templateUrl: 'modules/Task/Tasks.html',
controller: 'Tasks',
resolve: {
tasks: (Task, project) => Task.list(project.id)
},
// breadcrumbs resolved in authenticated state
onEnter: function(breadcrumbs) {
breadcrumbs.push({ label: 'Tasks', sref: 'tasks' });
},
onExit: function(breadcrumbs) {
breadcrumbs.pop();
}
});
$stateProvider.state( 'tasks.new', {
url: '/new', // /projects/:projectId/tasks/new (state must be defined BEFORE /:taskId)
resolve: {
task: (project) => project.newTask()
},
templateUrl: 'modules/Task/Form.html',
controller: 'TaskForm',
// breadcrumbs resolved in authenticated state
onEnter: function(breadcrumbs) {
breadcrumbs.push({ label: 'New', sref: 'tasks.new' });
},
onExit: function(breadcrumbs) {
breadcrumbs.pop();
}
});
$stateProvider.state( 'task', {
parent: 'tasks',
url: '/:taskId', // /projects/:projectId/tasks/:taskId (state must be defined AFTER /new)
views: {
'': { // Projects.html: <ui-view></ui-view>
templateUrl: 'modules/Task/Task.html',
controller: 'Task'
},
'header@project': { // Project/Project.html: <ui-view name="header"></ui-view>
templateUrl: 'modules/Task/TaskHeader.html',
controller: 'TaskHeader'
}
},
resolve: {
task: (project, $stateParams) => project.getTask($stateParams.taskId)
},
onEnter: function(task, breadcrumbs) {
task.open();
breadcrumbs.push({ label: task.name, sref: 'task' });
},
onExit: function(task, breadcrumbs) {
task.close();
breadcrumbs.pop();
}
});
$stateProvider.state( 'task.edit', {
templateUrl: 'modules/Task/Form.html',
controller: 'TaskForm'
});
});
module.controller( 'Tasks', ($scope, tasks, project) => {
$scope.tasks = tasks;
$scope.tasks = project;
});
module.controller( 'Task', ($scope, task) => {
$scope.task = task;
});
module.controller( 'TaskHeader', ($scope, task, project) => {
$scope.tasks = project;
$scope.task = task;
});
module.controller( 'TaskForm', ($scope, task) => {
// injected `task` is either a new object or an existing object
$scope.task = task;
});