mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Merge pull request #1957 from jaredevantabor/fix-1824-2
Makes rows inactive on permissions list if assigning user doesn't have
This commit is contained in:
commit
be864012b7
@ -16,6 +16,12 @@
|
|||||||
index: false,
|
index: false,
|
||||||
hover: true,
|
hover: true,
|
||||||
emptyListText : i18n._('No Users exist'),
|
emptyListText : i18n._('No Users exist'),
|
||||||
|
disableRow: "{{ user.summary_fields.user_capabilities.edit === false }}",
|
||||||
|
disableRowValue: 'summary_fields.user_capabilities.edit === false',
|
||||||
|
disableTooltip: {
|
||||||
|
placement: 'top',
|
||||||
|
tipWatch: 'user.tooltip'
|
||||||
|
},
|
||||||
fields: {
|
fields: {
|
||||||
first_name: {
|
first_name: {
|
||||||
label: i18n._('First Name'),
|
label: i18n._('First Name'),
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
/* jshint unused: vars */
|
/* jshint unused: vars */
|
||||||
export default ['addPermissionsTeamsList', 'addPermissionsUsersList', 'TemplateList', 'ProjectList',
|
export default ['addPermissionsTeamsList', 'addPermissionsUsersList', 'TemplateList', 'ProjectList',
|
||||||
'InventoryList', 'CredentialList', '$compile', 'generateList',
|
'InventoryList', 'CredentialList', '$compile', 'generateList',
|
||||||
'OrganizationList', '$window',
|
'OrganizationList', '$window', 'i18n',
|
||||||
function(addPermissionsTeamsList, addPermissionsUsersList, TemplateList, ProjectList,
|
function(addPermissionsTeamsList, addPermissionsUsersList, TemplateList, ProjectList,
|
||||||
InventoryList, CredentialList, $compile, generateList,
|
InventoryList, CredentialList, $compile, generateList,
|
||||||
OrganizationList, $window) {
|
OrganizationList, $window, i18n) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: {
|
scope: {
|
||||||
@ -159,6 +159,21 @@ export default ['addPermissionsTeamsList', 'addPermissionsUsersList', 'TemplateL
|
|||||||
// iterate over the list and add fields like type label, after the
|
// iterate over the list and add fields like type label, after the
|
||||||
// OPTIONS request returns, or the list is sorted/paginated/searched
|
// OPTIONS request returns, or the list is sorted/paginated/searched
|
||||||
function optionsRequestDataProcessing(){
|
function optionsRequestDataProcessing(){
|
||||||
|
if(scope.list.name === 'users'){
|
||||||
|
if (scope[list.name] !== undefined) {
|
||||||
|
scope[list.name].forEach(function(item, item_idx) {
|
||||||
|
var itm = scope[list.name][item_idx];
|
||||||
|
if(itm.summary_fields.user_capabilities.edit){
|
||||||
|
// undefined doesn't render the tooltip,
|
||||||
|
// which is intended here.
|
||||||
|
itm.tooltip = undefined;
|
||||||
|
}
|
||||||
|
else if(!itm.summary_fields.user_capabilities.edit){
|
||||||
|
itm.tooltip = i18n._('You do not have permission to manage this user');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
if(scope.list.name === 'projects'){
|
if(scope.list.name === 'projects'){
|
||||||
if (scope[list.name] !== undefined) {
|
if (scope[list.name] !== undefined) {
|
||||||
scope[list.name].forEach(function(item, item_idx) {
|
scope[list.name].forEach(function(item, item_idx) {
|
||||||
|
@ -19,6 +19,7 @@ export default ['i18n', function(i18n) {
|
|||||||
basePath: 'inventory',
|
basePath: 'inventory',
|
||||||
title: false,
|
title: false,
|
||||||
disableRow: "{{ inventory.pending_deletion }}",
|
disableRow: "{{ inventory.pending_deletion }}",
|
||||||
|
disableRowValue: 'pending_deletion',
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
status: {
|
status: {
|
||||||
|
@ -290,6 +290,7 @@ export default ['$compile', 'Attr', 'Icon',
|
|||||||
// gotcha: transcluded elements require custom scope linking - binding to $parent models assumes a very rigid DOM hierarchy
|
// gotcha: transcluded elements require custom scope linking - binding to $parent models assumes a very rigid DOM hierarchy
|
||||||
// see: lookup-modal.directive.js for example
|
// see: lookup-modal.directive.js for example
|
||||||
innerTable += options.mode === 'lookup' ? `<tbody ng-init="selection.${list.iterator} = {id: $parent.${list.iterator}, name: $parent.${list.iterator}_name}">` : `"<tbody>\n"`;
|
innerTable += options.mode === 'lookup' ? `<tbody ng-init="selection.${list.iterator} = {id: $parent.${list.iterator}, name: $parent.${list.iterator}_name}">` : `"<tbody>\n"`;
|
||||||
|
|
||||||
innerTable += "<tr ng-class=\"[" + list.iterator;
|
innerTable += "<tr ng-class=\"[" + list.iterator;
|
||||||
innerTable += (options.mode === 'lookup' || options.mode === 'select') ? ".success_class" : ".active_class";
|
innerTable += (options.mode === 'lookup' || options.mode === 'select') ? ".success_class" : ".active_class";
|
||||||
|
|
||||||
@ -313,7 +314,7 @@ export default ['$compile', 'Attr', 'Icon',
|
|||||||
innerTable += `, {'List-tableRow--selected' : $stateParams['${list.iterator}_id'] == ${list.iterator}.id}`;
|
innerTable += `, {'List-tableRow--selected' : $stateParams['${list.iterator}_id'] == ${list.iterator}.id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
innerTable += (list.disableRow) ? `, {true: 'List-tableRow--disabled'}[${list.iterator}.pending_deletion]` : "";
|
innerTable += (list.disableRow) ? `, {true: 'List-tableRow--disabled'}[${list.iterator}.${list.disableRowValue}]` : "";
|
||||||
|
|
||||||
if (list.multiSelect) {
|
if (list.multiSelect) {
|
||||||
innerTable += ", " + list.iterator + ".isSelected ? 'is-selected-row' : ''";
|
innerTable += ", " + list.iterator + ".isSelected ? 'is-selected-row' : ''";
|
||||||
@ -323,18 +324,21 @@ export default ['$compile', 'Attr', 'Icon',
|
|||||||
innerTable += "id=\"{{ " + list.iterator + ".id }}\" ";
|
innerTable += "id=\"{{ " + list.iterator + ".id }}\" ";
|
||||||
innerTable += "class=\"List-tableRow " + list.iterator + "_class\" ";
|
innerTable += "class=\"List-tableRow " + list.iterator + "_class\" ";
|
||||||
innerTable += (list.disableRow) ? " disable-row=\"" + list.disableRow + "\" " : "";
|
innerTable += (list.disableRow) ? " disable-row=\"" + list.disableRow + "\" " : "";
|
||||||
|
if(_.has(list, 'disableTooltip')){
|
||||||
|
let { placement, tipWatch } = list.disableTooltip;
|
||||||
|
innerTable += `aw-tool-tip="{{tipWatch}}" data-placement="${placement}" data-tip-watch="${tipWatch}"`;
|
||||||
|
}
|
||||||
innerTable += "ng-repeat=\"" + list.iterator + " in " + list.name;
|
innerTable += "ng-repeat=\"" + list.iterator + " in " + list.name;
|
||||||
innerTable += (list.trackBy) ? " track by " + list.trackBy : "";
|
innerTable += (list.trackBy) ? " track by " + list.trackBy : "";
|
||||||
innerTable += (list.orderBy) ? " | orderBy:'" + list.orderBy + "'" : "";
|
innerTable += (list.orderBy) ? " | orderBy:'" + list.orderBy + "'" : "";
|
||||||
innerTable += (list.filterBy) ? " | filter: " + list.filterBy : "";
|
innerTable += (list.filterBy) ? " | filter: " + list.filterBy : "";
|
||||||
innerTable += "\">\n";
|
innerTable += "\">\n";
|
||||||
|
|
||||||
if (list.index) {
|
if (list.index) {
|
||||||
innerTable += "<td class=\"index-column hidden-xs List-tableCell\">{{ $index + ((" + list.iterator + "_page - 1) * " + list.iterator + "_page_size) + 1 }}.</td>\n";
|
innerTable += "<td class=\"index-column hidden-xs List-tableCell\">{{ $index + ((" + list.iterator + "_page - 1) * " + list.iterator + "_page_size) + 1 }}.</td>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.multiSelect) {
|
if (list.multiSelect) {
|
||||||
innerTable += '<td class="col-xs-1 select-column List-staticColumn--smallStatus"><select-list-item item=\"' + list.iterator + '\"></select-list-item></td>';
|
innerTable += '<td class="col-xs-1 select-column List-staticColumn--smallStatus"><select-list-item item=\"' + list.iterator + '\" disabled="'+list.iterator + '.' + list.disableRowValue+'"></select-list-item></td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change layout if a lookup list, place radio buttons before labels
|
// Change layout if a lookup list, place radio buttons before labels
|
||||||
|
@ -27,10 +27,11 @@ export default
|
|||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: {
|
scope: {
|
||||||
item: '=item'
|
item: '=item',
|
||||||
|
disabled: '='
|
||||||
},
|
},
|
||||||
require: '^multiSelectList',
|
require: '^multiSelectList',
|
||||||
template: '<input type="checkbox" data-multi-select-list-item ng-model="item.isSelected" ng-click="userInteractionSelect()">',
|
template: '<input type="checkbox" data-multi-select-list-item ng-model="item.isSelected" ng-click="userInteractionSelect()" ng-disabled=disabled>',
|
||||||
link: function(scope, element, attrs, multiSelectList) {
|
link: function(scope, element, attrs, multiSelectList) {
|
||||||
|
|
||||||
scope.decoratedItem = multiSelectList.registerItem(scope.item);
|
scope.decoratedItem = multiSelectList.registerItem(scope.item);
|
||||||
|
Loading…
Reference in New Issue
Block a user