Repository navigation
Expand file tree
/
Copy pathBoardController.js
More file actions
52 lines (44 loc) · 1.47 KB
/
Copy pathBoardController.js
File metadata and controls
52 lines (44 loc) · 1.47 KB
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
/**
* BoardController
*
* @module :: Controller
* @description :: Contains logic for handling requests.
*/
module.exports = {
/**
* Taskboard main action.
*
* @param {Request} req Request object
* @param {Response} res Response object
*/
index: function(req, res) {
var projectId = req.route.params.projectId || 0;
var sprintId = req.route.params.sprintId || 0;
var sprintCookie = '';
// Project id not given, but user has cookie that contains last selected project
if (projectId === 0 && req.cookies.projectId) {
projectId = req.cookies.projectId;
// Specify sprint cookie
sprintCookie = 'sprintId_' + projectId;
// Sprint cookie exists for current project
if (req.cookies[sprintCookie]) {
sprintId = req.cookies[sprintCookie];
}
}
// Project id given and sprint id not, check cookie for sprint id
if (sprintId === 0 && projectId > 0) {
sprintCookie = 'sprintId_' + projectId;
// Cookie founded
if (req.cookies[sprintCookie]) {
sprintId = req.cookies[sprintCookie];
}
}
projectId = isNaN(parseInt(projectId)) ? 0 : projectId;
sprintId = isNaN(parseInt(sprintId)) ? 0 : sprintId;
// Make view
res.view({
projectId: projectId,
sprintId: sprintId
});
}
};