2016-04-22 18:49:52 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.project.member')
|
|
|
|
.constant('roles', roles)
|
2016-04-26 12:23:34 +02:00
|
|
|
.factory('getRole', getRole);
|
2016-04-22 18:49:52 +02:00
|
|
|
|
|
|
|
function roles() {
|
|
|
|
return [
|
2016-06-15 12:31:02 +02:00
|
|
|
{'id': '0', 'name': 'N/A', 'roleName': 'n/a'},
|
2016-04-26 12:23:34 +02:00
|
|
|
{'id': '1', 'name': 'Project Admin', 'roleName': 'projectAdmin'},
|
|
|
|
{'id': '2', 'name': 'Developer', 'roleName': 'developer'},
|
|
|
|
{'id': '3', 'name': 'Guest', 'roleName': 'guest'}
|
2016-04-22 18:49:52 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-04-26 12:23:34 +02:00
|
|
|
getRole.$inject = ['roles'];
|
2016-04-22 18:49:52 +02:00
|
|
|
|
2016-04-26 12:23:34 +02:00
|
|
|
function getRole(roles) {
|
2016-04-22 18:49:52 +02:00
|
|
|
var r = roles();
|
2016-04-26 12:23:34 +02:00
|
|
|
return get;
|
|
|
|
function get(query) {
|
2016-04-22 18:49:52 +02:00
|
|
|
|
|
|
|
for(var i = 0; i < r.length; i++) {
|
|
|
|
var role = r[i];
|
2016-05-23 12:29:17 +02:00
|
|
|
if(query.key === 'roleName' && role.roleName === query.value
|
2016-06-02 09:44:53 +02:00
|
|
|
|| query.key === 'roleId' && role.id === String(query.value)) {
|
2016-04-26 12:23:34 +02:00
|
|
|
return role;
|
2016-04-22 18:49:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|