mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
Merge pull request #2000 from anoek/1503
Disable custom inventory script input when you have no access
This commit is contained in:
commit
3425c1d4d1
@ -20,6 +20,8 @@ export default
|
||||
form = inventoryScriptsFormObject,
|
||||
url = GetBasePath('inventory_scripts');
|
||||
|
||||
$scope.canEdit = true;
|
||||
|
||||
generator.inject(form, {
|
||||
mode: 'add' ,
|
||||
scope:scope,
|
||||
@ -38,7 +40,6 @@ export default
|
||||
|
||||
// Save
|
||||
scope.formSave = function () {
|
||||
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
|
||||
@ -61,6 +61,10 @@ export default
|
||||
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||
}
|
||||
}
|
||||
$scope.canEdit = data['script'] !== null;
|
||||
if (!$scope.canEdit) {
|
||||
$scope.script = "Script contents hidden";
|
||||
}
|
||||
Wait('stop');
|
||||
})
|
||||
.error(function (data, status) {
|
||||
|
||||
@ -52,6 +52,7 @@ export default function() {
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
awDropFile: true,
|
||||
ngDisabled: '!canEdit',
|
||||
rows: 10,
|
||||
awPopOver: "<p>Drag and drop your custom inventory script file here or create one in the field to import your custom inventory. " +
|
||||
"<br><br> Script must begin with a hashbang sequence: i.e.... #!/usr/bin/env python</p>",
|
||||
@ -67,7 +68,7 @@ export default function() {
|
||||
},
|
||||
save: {
|
||||
ngClick: 'formSave()', //$scope.function to call on click, optional
|
||||
ngDisabled: true //Disable when $pristine or $invalid, optional
|
||||
ngDisabled: 'custom_inventory_form.$pristine || custom_inventory_form.$invalid || !canEdit' //Disable when $pristine or $invalid, optional
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -1053,6 +1053,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
||||
html += (field.ngChange) ? this.attr(field, 'ngChange') : "";
|
||||
html += buildId(field, fld, this.form);
|
||||
html += (field.placeholder) ? this.attr(field, 'placeholder') : "";
|
||||
html += (field.ngDisabled) ? this.attr(field, 'ngDisabled'): "";
|
||||
html += (options.mode === 'edit' && field.editRequired) ? "required " : "";
|
||||
html += (options.mode === 'add' && field.addRequired) ? "required " : "";
|
||||
html += (field.ngRequired) ? "ng-required=\"" + field.ngRequired +"\"" : "";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user