Merge pull request #4863 from chrismeyersfsu/fix-4787

hide add permissions when editing super user
This commit is contained in:
Chris Meyers 2017-01-24 15:52:41 -05:00 committed by GitHub
commit 2828352d3e
3 changed files with 20 additions and 3 deletions

View File

@ -221,9 +221,12 @@ export function UsersEdit($scope, $rootScope, $location,
init();
function init() {
$scope.hidePagination = false;
$scope.hideSmartSearch = false;
$scope.user_type_options = user_type_options;
$scope.user_type = user_type_options[0];
$scope.$watch('user_type', user_type_sync($scope));
$scope.$watch('is_superuser', hidePermissionsTabSmartSearchAndPaginationIfSuperUser($scope));
Rest.setUrl(defaultUrl);
Wait('start');
Rest.get(defaultUrl).success(function(data) {
@ -271,6 +274,20 @@ export function UsersEdit($scope, $rootScope, $location,
});
}
// Organizations and Teams tab pagination is hidden through other mechanism
function hidePermissionsTabSmartSearchAndPaginationIfSuperUser(scope) {
return function(isSuperuserNewValue) {
let shouldHide = isSuperuserNewValue;
if (shouldHide === true) {
scope.hidePagination = true;
scope.hideSmartSearch = true;
} else if (shouldHide === false) {
scope.hidePagination = false;
scope.hideSmartSearch = false;
}
};
}
function setScopeFields(data) {
_(data)

View File

@ -210,7 +210,7 @@ export default
awToolTip: i18n._('Grant Permission'),
actionClass: 'btn List-buttonSubmit',
buttonContent: '+ ' + i18n._('ADD PERMISSIONS'),
ngShow: '(user_obj.summary_fields.user_capabilities.edit || canAdd)'
ngShow: '(!is_superuser && (user_obj.summary_fields.user_capabilities.edit || canAdd))'
}
},
fieldActions: {

View File

@ -1844,7 +1844,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
// smart-search directive
html += `
<div
ng-hide="${itm}.length === 0 && (searchTags | isEmpty)">
ng-hide="(${itm}.length === 0 && (searchTags | isEmpty)) || hideSmartSearch === true">
<smart-search
django-model="${itm}"
search-size="${width}"
@ -1983,7 +1983,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
//html += "</div>\n"; // close well
html += "</div>\n"; // close list-wrapper div
html += `<paginate base-path="${collection.basePath}" dataset="${collection.iterator}_dataset" iterator="${collection.iterator}">`;
html += `<paginate base-path="${collection.basePath}" dataset="${collection.iterator}_dataset" iterator="${collection.iterator}" ng-hide="hidePagination">`;
return html;
}
};