mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Allow CreateDialog helper to set disabled status on save button
This commit is contained in:
@@ -503,6 +503,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
|||||||
title: 'Host Properties',
|
title: 'Host Properties',
|
||||||
id: 'host-modal-dialog',
|
id: 'host-modal-dialog',
|
||||||
clonseOnEscape: false,
|
clonseOnEscape: false,
|
||||||
|
form: form_scope.host_form,
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
scope.codeMirror.destroy();
|
scope.codeMirror.destroy();
|
||||||
|
|||||||
@@ -201,15 +201,16 @@ export default
|
|||||||
|
|
||||||
form.well = false;
|
form.well = false;
|
||||||
|
|
||||||
generator.inject(form, {
|
var form_scope =
|
||||||
mode: 'edit',
|
generator.inject(form, {
|
||||||
showButtons: false,
|
mode: 'edit',
|
||||||
showActions: false,
|
showButtons: false,
|
||||||
id: 'inventory-edit-modal-dialog',
|
showActions: false,
|
||||||
breadCrumbs: false,
|
id: 'inventory-edit-modal-dialog',
|
||||||
related: false,
|
breadCrumbs: false,
|
||||||
scope: scope
|
related: false,
|
||||||
});
|
scope: scope
|
||||||
|
});
|
||||||
|
|
||||||
/* Reset form properties. Otherwise it screws up future requests of the Inventories detail page */
|
/* Reset form properties. Otherwise it screws up future requests of the Inventories detail page */
|
||||||
form.well = true;
|
form.well = true;
|
||||||
@@ -241,6 +242,7 @@ export default
|
|||||||
title: 'Inventory Properties',
|
title: 'Inventory Properties',
|
||||||
id: 'inventory-edit-modal-dialog',
|
id: 'inventory-edit-modal-dialog',
|
||||||
clonseOnEscape: false,
|
clonseOnEscape: false,
|
||||||
|
form: form_scope.inventory_form,
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
scope.codeMirror.destroy();
|
scope.codeMirror.destroy();
|
||||||
|
|||||||
@@ -57,10 +57,15 @@ angular.module('ModalDialog', ['Utilities', 'ParseHelper'])
|
|||||||
beforeDestroy = params.beforeDestroy,
|
beforeDestroy = params.beforeDestroy,
|
||||||
closeOnEscape = (params.closeOnEscape === undefined) ? false : params.closeOnEscape,
|
closeOnEscape = (params.closeOnEscape === undefined) ? false : params.closeOnEscape,
|
||||||
resizable = (params.resizable === undefined) ? true : params.resizable,
|
resizable = (params.resizable === undefined) ? true : params.resizable,
|
||||||
|
forms = _.chain([params.form]).flatten().compact().value(),
|
||||||
buttons,
|
buttons,
|
||||||
id = params.id,
|
id = params.id,
|
||||||
x, y, wh, ww;
|
x, y, wh, ww;
|
||||||
|
|
||||||
|
function updateButtonStatus(isValid) {
|
||||||
|
$('.ui-dialog[aria-describedby="' + id + '"]').find('.btn-primary').prop('disabled', !isValid);
|
||||||
|
}
|
||||||
|
|
||||||
if (Empty(buttonSet)) {
|
if (Empty(buttonSet)) {
|
||||||
// Default button object
|
// Default button object
|
||||||
buttonSet = [{
|
buttonSet = [{
|
||||||
@@ -115,6 +120,12 @@ angular.module('ModalDialog', ['Utilities', 'ParseHelper'])
|
|||||||
});
|
});
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
|
if (forms.length > 0) {
|
||||||
|
forms.map(function(form_ctrl) {
|
||||||
|
scope.$watch(form_ctrl.$name + '.$valid', updateButtonStatus);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
scope.$apply(function() {
|
scope.$apply(function() {
|
||||||
scope.$emit(callback);
|
scope.$emit(callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user