mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-25 19:56:09 +01:00
41 lines
1005 B
JavaScript
41 lines
1005 B
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.project.member')
|
|
.directive('switchRole', switchRole);
|
|
|
|
SwitchRoleController.$inject = ['getRole', '$scope'];
|
|
|
|
function SwitchRoleController(getRole, $scope) {
|
|
var vm = this;
|
|
|
|
vm.currentRole = getRole({'key': 'roleName', 'value': vm.roleName});
|
|
vm.selectRole = selectRole;
|
|
|
|
function selectRole(role) {
|
|
vm.currentRole = getRole({'key': 'roleName', 'value': role.roleName});
|
|
$scope.$emit('changedRoleId', vm.currentRole.id);
|
|
}
|
|
|
|
}
|
|
|
|
function switchRole() {
|
|
var directive = {
|
|
'restrict': 'E',
|
|
'templateUrl': '/static/ng/resources/js/components/project-member/switch-role.directive.html',
|
|
'scope': {
|
|
'roles': '=',
|
|
'editMode': '=',
|
|
'userId': '=',
|
|
'roleName': '='
|
|
},
|
|
'controller' : SwitchRoleController,
|
|
'controllerAs': 'vm',
|
|
'bindToController': true
|
|
};
|
|
return directive;
|
|
}
|
|
|
|
})(); |