1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Merge pull request #69 from joefiorini/dialog-forms

Dialog forms
This commit is contained in:
Joe Fiorini 2015-02-10 10:28:50 -05:00
commit 07ef5a1f86
4 changed files with 569 additions and 547 deletions

View File

@ -738,7 +738,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
elem = document.getElementById('group-modal-dialog'); elem = document.getElementById('group-modal-dialog');
$compile(elem)(modal_scope); $compile(elem)(modal_scope);
var form_scope =
generator.inject(GroupForm, { mode: 'edit', id: 'properties-tab', breadCrumbs: false, related: false, scope: properties_scope }); generator.inject(GroupForm, { mode: 'edit', id: 'properties-tab', breadCrumbs: false, related: false, scope: properties_scope });
var source_form_scope =
generator.inject(SourceForm, { mode: 'edit', id: 'sources-tab', breadCrumbs: false, related: false, scope: sources_scope }); generator.inject(SourceForm, { mode: 'edit', id: 'sources-tab', breadCrumbs: false, related: false, scope: sources_scope });
//generator.reset(); //generator.reset();
@ -881,6 +883,11 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
modal_scope.cancelModal(); modal_scope.cancelModal();
}, },
open: function () { open: function () {
function updateButtonStatus(isValid) {
$('.ui-dialog[aria-describedby="group-modal-dialog"]').find('.btn-primary').prop('disabled', !isValid);
}
form_scope.$watch('group_form.$valid', updateButtonStatus);
source_form_scope.$watch('source_form.$valid', updateButtonStatus);
$('#group_name').focus(); $('#group_name').focus();
Wait('stop'); Wait('stop');
} }

View File

@ -471,8 +471,9 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
scope = parent_scope.$new(), scope = parent_scope.$new(),
master = {}, master = {},
relatedSets = {}, relatedSets = {},
buttons, url; buttons, url, form_scope;
var form_scope =
generator.inject(HostForm, { mode: 'edit', id: 'host-modal-dialog', breadCrumbs: false, related: false, scope: scope }); generator.inject(HostForm, { mode: 'edit', id: 'host-modal-dialog', breadCrumbs: false, related: false, scope: scope });
generator.reset(); generator.reset();
@ -503,6 +504,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();

View File

@ -201,6 +201,7 @@ export default
form.well = false; form.well = false;
var form_scope =
generator.inject(form, { generator.inject(form, {
mode: 'edit', mode: 'edit',
showButtons: false, showButtons: false,
@ -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();

View File

@ -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);