fix dangling rbac hide issues

This commit is contained in:
John Mitchell
2016-09-16 13:02:35 -04:00
parent b0731181ff
commit 44ea28feb6
3 changed files with 12 additions and 4 deletions

View File

@@ -399,7 +399,7 @@ export default
}, },
save: { save: {
ngClick: 'formSave()', //$scope.function to call on click, optional ngClick: 'formSave()', //$scope.function to call on click, optional
ngDisabled: "job_templates_form.$invalid || can_edit!==true",//true //Disable when $pristine or $invalid, optional and when can_edit = false, for permission reasons ngDisabled: "job_templates_form.$invalid",//true //Disable when $pristine or $invalid, optional and when can_edit = false, for permission reasons
ngShow: '(job_template_obj.summary_fields.user_capabilities.edit || canAdd)' ngShow: '(job_template_obj.summary_fields.user_capabilities.edit || canAdd)'
} }
}, },

View File

@@ -5,10 +5,18 @@
*************************************************/ *************************************************/
export default export default
['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'HostManageService', ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'HostManageService', 'rbacUiControlService', 'GetBasePath',
function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, HostManageService){ function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, HostManageService, rbacUiControlService, GetBasePath){
var generator = GenerateForm, var generator = GenerateForm,
form = HostForm; form = HostForm;
$scope.canAdd = false;
rbacUiControlService.canAdd(GetBasePath('inventory') + $stateParams.inventory_id + "/hosts")
.then(function(canAdd) {
$scope.canAdd = canAdd;
});
$scope.parseType = 'yaml'; $scope.parseType = 'yaml';
$scope.formCancel = function(){ $scope.formCancel = function(){
$state.go('^'); $state.go('^');

View File

@@ -75,7 +75,7 @@ export default function() {
}, },
save: { save: {
ngClick: 'formSave()', //$scope.function to call on click, optional ngClick: 'formSave()', //$scope.function to call on click, optional
ngDisabled: 'custom_inventory_form.$pristine || custom_inventory_form.$invalid || !canEdit', //Disable when $pristine or $invalid, optional ngDisabled: 'custom_inventory_form.$pristine || custom_inventory_form.$invalid', //Disable when $pristine or $invalid, optional
ngShow: '(inventory_script_obj.summary_fields.user_capabilities.edit || canAdd)' ngShow: '(inventory_script_obj.summary_fields.user_capabilities.edit || canAdd)'
} }
} }