diff --git a/awx/ui/static/js/helpers/Hosts.js b/awx/ui/static/js/helpers/Hosts.js index c9134c7f20..61cbf33cd7 100644 --- a/awx/ui/static/js/helpers/Hosts.js +++ b/awx/ui/static/js/helpers/Hosts.js @@ -503,6 +503,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H title: 'Host Properties', id: 'host-modal-dialog', clonseOnEscape: false, + form: form_scope.host_form, onClose: function() { Wait('stop'); scope.codeMirror.destroy(); diff --git a/awx/ui/static/js/helpers/inventory.js b/awx/ui/static/js/helpers/inventory.js index 67ca22c3e1..f6c44525fc 100644 --- a/awx/ui/static/js/helpers/inventory.js +++ b/awx/ui/static/js/helpers/inventory.js @@ -201,15 +201,16 @@ export default form.well = false; - generator.inject(form, { - mode: 'edit', - showButtons: false, - showActions: false, - id: 'inventory-edit-modal-dialog', - breadCrumbs: false, - related: false, - scope: scope - }); + var form_scope = + generator.inject(form, { + mode: 'edit', + showButtons: false, + showActions: false, + id: 'inventory-edit-modal-dialog', + breadCrumbs: false, + related: false, + scope: scope + }); /* Reset form properties. Otherwise it screws up future requests of the Inventories detail page */ form.well = true; @@ -241,6 +242,7 @@ export default title: 'Inventory Properties', id: 'inventory-edit-modal-dialog', clonseOnEscape: false, + form: form_scope.inventory_form, onClose: function() { Wait('stop'); scope.codeMirror.destroy(); diff --git a/awx/ui/static/lib/ansible/Modal.js b/awx/ui/static/lib/ansible/Modal.js index 8754d989c0..c34ef22971 100644 --- a/awx/ui/static/lib/ansible/Modal.js +++ b/awx/ui/static/lib/ansible/Modal.js @@ -57,10 +57,15 @@ angular.module('ModalDialog', ['Utilities', 'ParseHelper']) beforeDestroy = params.beforeDestroy, closeOnEscape = (params.closeOnEscape === undefined) ? false : params.closeOnEscape, resizable = (params.resizable === undefined) ? true : params.resizable, + forms = _.chain([params.form]).flatten().compact().value(), buttons, id = params.id, x, y, wh, ww; + function updateButtonStatus(isValid) { + $('.ui-dialog[aria-describedby="' + id + '"]').find('.btn-primary').prop('disabled', !isValid); + } + if (Empty(buttonSet)) { // Default button object buttonSet = [{ @@ -115,6 +120,12 @@ angular.module('ModalDialog', ['Utilities', 'ParseHelper']) }); }, 300); + if (forms.length > 0) { + forms.map(function(form_ctrl) { + scope.$watch(form_ctrl.$name + '.$valid', updateButtonStatus); + }); + } + setTimeout(function() { scope.$apply(function() { scope.$emit(callback); @@ -226,4 +237,4 @@ angular.module('ModalDialog', ['Utilities', 'ParseHelper']) ParseTypeChange({ scope: scope, field_id: textareaId, onReady: waitStop, variable: fld, onChange: onChange }); } }; - }]); \ No newline at end of file + }]);