mirror of
https://github.com/ansible/awx.git
synced 2026-01-21 14:38:00 -03:30
Fix for adding batch permissions to teams. Also added logic to properly enable/disable the save button on this modal.
This commit is contained in:
parent
c8f1f11816
commit
a5f275bcca
@ -100,6 +100,21 @@ function(rootScope, scope, $state, i18n, CreateSelect2, GetBasePath, Rest, $q, W
|
||||
return Object.keys(scope.selected[tab]).length > 0;
|
||||
};
|
||||
|
||||
scope.saveEnabled = function(){
|
||||
let missingRole = false;
|
||||
let resourceSelected = false;
|
||||
_.forOwn(scope.selected, function(value, key) {
|
||||
if(Object.keys(value).length > 0) {
|
||||
// A resource from this tab has been selected
|
||||
resourceSelected = true;
|
||||
if(!scope.roleSelection[key]) {
|
||||
missingRole = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return resourceSelected && !missingRole;
|
||||
};
|
||||
|
||||
// handle form tab changes
|
||||
scope.selectTab = function(selected){
|
||||
_.each(scope.tab, (value, key, collection) => {
|
||||
|
||||
@ -76,11 +76,11 @@
|
||||
</div>
|
||||
<div id="AddPermissions-credentials" class="AddPermissions-list" ng-show="tab.credentials">
|
||||
<rbac-multiselect-list view="Credentials" all-selected="allSelected" dataset="resolve.credentialsDataset"></rbac-multiselect-list>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end section 1 -->
|
||||
|
||||
|
||||
<!-- begin section 2 -->
|
||||
<div ng-show="showSection2Container()">
|
||||
<div ng-show="showSection2Container()">
|
||||
<div class="AddPermissions-separator"></div>
|
||||
<div class="AddPermissions-directions">
|
||||
<span class="AddPermissions-directionNumber">
|
||||
@ -176,7 +176,7 @@
|
||||
<button type="button"
|
||||
class="btn btn-sm Form-saveButton"
|
||||
ng-click="saveForm()"
|
||||
ng-disabled="!showSection2Container()">
|
||||
ng-disabled="!saveEnabled()">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -64,7 +64,7 @@ export default
|
||||
},
|
||||
|
||||
related: {
|
||||
permissions: {
|
||||
users: {
|
||||
dataPlacement: 'top',
|
||||
awToolTip: i18n._('Please save before adding users'),
|
||||
basePath: 'api/v1/teams/{{$stateParams.team_id}}/access_list/',
|
||||
@ -73,15 +73,14 @@ export default
|
||||
},
|
||||
type: 'collection',
|
||||
title: i18n._('Users'),
|
||||
iterator: 'permission',
|
||||
iterator: 'user',
|
||||
index: false,
|
||||
open: false,
|
||||
actions: {
|
||||
add: {
|
||||
// @issue https://github.com/ansible/ansible-tower/issues/3487
|
||||
//ngClick: "addPermissionWithoutTeamTab",
|
||||
ngClick: "$state.go('.add')",
|
||||
label: i18n._('Add'),
|
||||
awToolTip: i18n._('Add user to team'),
|
||||
awToolTip: i18n._('Add User'),
|
||||
actionClass: 'btn List-buttonSubmit',
|
||||
buttonContent: '+ ' + i18n._('ADD'),
|
||||
ngShow: '(team_obj.summary_fields.user_capabilities.edit || canAdd)'
|
||||
@ -104,44 +103,44 @@ export default
|
||||
}
|
||||
}
|
||||
},
|
||||
roles: {
|
||||
hideSearchAndActions: true,
|
||||
dataPlacement: 'top',
|
||||
awToolTip: i18n._('Please save before assigning permissions'),
|
||||
permissions: {
|
||||
basePath: 'api/v1/teams/{{$stateParams.team_id}}/roles/',
|
||||
search: {
|
||||
page_size: '10',
|
||||
// @todo ask about name field / serializer on this endpoint
|
||||
order_by: 'id'
|
||||
},
|
||||
awToolTip: i18n._('Please save before assigning permissions'),
|
||||
dataPlacement: 'top',
|
||||
hideSearchAndActions: true,
|
||||
type: 'collection',
|
||||
title: i18n._('Permissions'),
|
||||
iterator: 'role',
|
||||
iterator: 'permission',
|
||||
open: false,
|
||||
index: false,
|
||||
emptyListText: i18n._('No permissions have been granted'),
|
||||
fields: {
|
||||
name: {
|
||||
label: i18n._('Name'),
|
||||
ngBind: 'role.summary_fields.resource_name',
|
||||
linkTo: '{{convertApiUrl(role.related[role.summary_fields.resource_type])}}',
|
||||
ngBind: 'permission.summary_fields.resource_name',
|
||||
linkTo: '{{convertApiUrl(permission.related[permission.summary_fields.resource_type])}}',
|
||||
noSort: true
|
||||
},
|
||||
type: {
|
||||
label: i18n._('Type'),
|
||||
ngBind: 'role.summary_fields.resource_type_display_name',
|
||||
ngBind: 'permission.summary_fields.resource_type_display_name',
|
||||
noSort: true
|
||||
},
|
||||
role: {
|
||||
label: i18n._('Role'),
|
||||
ngBind: 'role.name',
|
||||
ngBind: 'permission.name',
|
||||
noSort: true
|
||||
}
|
||||
},
|
||||
fieldActions: {
|
||||
"delete": {
|
||||
label: i18n._('Remove'),
|
||||
ngClick: 'deletePermissionFromTeam(team_id, team_obj.name, role.name, role.summary_fields.resource_name, role.related.teams)',
|
||||
ngClick: 'deletePermissionFromTeam(team_id, team_obj.name, permission.name, permission.summary_fields.resource_name, permission.related.teams)',
|
||||
'class': "List-actionButton--delete",
|
||||
iconClass: 'fa fa-times',
|
||||
awToolTip: i18n._('Dissasociate permission from team'),
|
||||
@ -156,7 +155,7 @@ export default
|
||||
awToolTip: i18n._('Grant Permission'),
|
||||
actionClass: 'btn List-buttonSubmit',
|
||||
buttonContent: '+ ' + i18n._('ADD PERMISSIONS'),
|
||||
ngShow: '(puser_obj.summary_fields.user_capabilities.edit || canAdd)'
|
||||
ngShow: '(team_obj.summary_fields.user_capabilities.edit || canAdd)'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ export default
|
||||
awToolTip: i18n._('Grant Permission'),
|
||||
actionClass: 'btn List-buttonSubmit',
|
||||
buttonContent: '+ ' + i18n._('ADD PERMISSIONS'),
|
||||
ngShow: '(puser_obj.summary_fields.user_capabilities.edit || canAdd)'
|
||||
ngShow: '(user_obj.summary_fields.user_capabilities.edit || canAdd)'
|
||||
}
|
||||
},
|
||||
fieldActions: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user