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-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-04-26 12:23:34 +02:00
|
|
|
if(query.key == 'roleName' && role.roleName == query.value
|
|
|
|
|| query.key == 'roleId' && role.id == query.value) {
|
|
|
|
return role;
|
2016-04-22 18:49:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|