forked from angular-app/angular-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojects.js
More file actions
46 lines (41 loc) · 1.38 KB
/
Copy pathprojects.js
File metadata and controls
46 lines (41 loc) · 1.38 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
angular.module('resources.projects', ['mongolabResource']);
angular.module('resources.projects').factory('Projects', ['mongolabResource', function ($mongolabResource) {
var Projects = $mongolabResource('projects');
Projects.forUser = function(userId, successcb, errorcb) {
//TODO: get projects for this user only (!)
return Projects.query({}, successcb, errorcb);
};
Projects.prototype.isProductOwner = function (userId) {
return this.productOwner === userId;
};
Projects.prototype.canActAsProductOwner = function (userId) {
return !this.isScrumMaster(userId) && !this.isDevTeamMember(userId);
};
Projects.prototype.isScrumMaster = function (userId) {
return this.scrumMaster === userId;
};
Projects.prototype.canActAsScrumMaster = function (userId) {
return !this.isProductOwner(userId);
};
Projects.prototype.isDevTeamMember = function (userId) {
return this.teamMembers.indexOf(userId) >= 0;
};
Projects.prototype.canActAsDevTeamMember = function (userId) {
return !this.isProductOwner(userId);
};
Projects.prototype.getRoles = function (userId) {
var roles = [];
if (this.isProductOwner(userId)) {
roles.push('PO');
} else {
if (this.isScrumMaster(userId)){
roles.push('SM');
}
if (this.isDevTeamMember(userId)){
roles.push('DEV');
}
}
return roles;
};
return Projects;
}]);