initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
42
static/js/directives/ui/role-group.js
Normal file
42
static/js/directives/ui/role-group.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* An element which displays a set of roles, and highlights the current role. This control also
|
||||
* allows the current role to be changed.
|
||||
*/
|
||||
angular.module('quay').directive('roleGroup', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/role-group.html',
|
||||
replace: false,
|
||||
transclude: false,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'roles': '@roles',
|
||||
'currentRole': '=currentRole',
|
||||
'readOnly': '=readOnly',
|
||||
'roleChanged': '&roleChanged',
|
||||
'pullLeft': '@pullLeft'
|
||||
},
|
||||
controller: function($scope, $element, RolesService, Config) {
|
||||
$scope.fullRoles = RolesService[$scope.roles];
|
||||
$scope.Config = Config;
|
||||
|
||||
$scope.setRole = function(role) {
|
||||
if ($scope.currentRole == role) { return; }
|
||||
if ($scope.roleChanged) {
|
||||
$scope.roleChanged({'role': role});
|
||||
} else {
|
||||
$scope.currentRole = role;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.getRoleInfo = function(role) {
|
||||
var found = null;
|
||||
$scope.fullRoles.forEach(function(r) {
|
||||
if (r.id == role) { found = r; }
|
||||
});
|
||||
return found;
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue