From 3dc59ae6dba7ca704d949e59282471b158d850e7 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Tue, 26 Apr 2016 12:13:52 -0400 Subject: [PATCH] Added the ability to pass in ngChange with the subCheckbox form object. Separated the checkbox's ngDisabled from the parent form element. --- awx/ui/client/src/forms/Credentials.js | 22 ++++++-- awx/ui/client/src/shared/form-generator.js | 64 +++++++++------------- 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/awx/ui/client/src/forms/Credentials.js b/awx/ui/client/src/forms/Credentials.js index 00853520bd..15ad2f03dc 100644 --- a/awx/ui/client/src/forms/Credentials.js +++ b/awx/ui/client/src/forms/Credentials.js @@ -114,6 +114,7 @@ export default label: 'Secret Key', type: 'sensitive', ngShow: "kind.value == 'aws'", + ngDisabled: "secret_key_ask", awRequiredWhen: { reqExpression: "aws_required", init: false @@ -121,7 +122,8 @@ export default autocomplete: false, subCheckbox: { variable: 'secret_key_ask', - text: 'Ask at runtime?' + text: 'Ask at runtime?', + ngChange: 'ask(\'secret_key\', \'undefined\')' }, clear: false, hasShowInputButton: true, @@ -231,11 +233,13 @@ export default label: 'Password', type: 'sensitive', ngShow: "kind.value == 'ssh'", + ngDisabled: "ssh_password_ask", addRequired: false, editRequired: false, subCheckbox: { variable: 'ssh_password_ask', - text: 'Ask at runtime?' + text: 'Ask at runtime?', + ngChange: 'ask(\'ssh_password\', \'undefined\')' }, hasShowInputButton: true, autocomplete: false, @@ -269,11 +273,13 @@ export default ngShow: "kind.value == 'ssh' || kind.value == 'scm'", addRequired: false, editRequired: false, - ngDisabled: "keyEntered === false", + ngDisabled: "keyEntered === false || ssh_key_unlock_ask", subCheckbox: { variable: 'ssh_key_unlock_ask', ngShow: "kind.value == 'ssh'", - text: 'Ask at runtime?' + text: 'Ask at runtime?', + ngChange: 'ask(\'ssh_key_unlock\', \'undefined\')', + ngDisabled: "keyEntered === false" }, hasShowInputButton: true, subForm: 'credentialSubForm' @@ -305,11 +311,13 @@ export default labelBind: 'becomePasswordLabel', type: 'sensitive', ngShow: "(kind.value == 'ssh' && (become_method && become_method.value)) ", + ngDisabled: "become_password_ask", addRequired: false, editRequired: false, subCheckbox: { variable: 'become_password_ask', - text: 'Ask at runtime?' + text: 'Ask at runtime?', + ngChange: 'ask(\'become_password\', \'undefined\')' }, hasShowInputButton: true, autocomplete: false, @@ -399,11 +407,13 @@ export default label: "Vault Password", type: 'sensitive', ngShow: "kind.value == 'ssh'", + ngDisabled: "vault_password_ask", addRequired: false, editRequired: false, subCheckbox: { variable: 'vault_password_ask', - text: 'Ask at runtime?' + text: 'Ask at runtime?', + ngChange: 'ask(\'vault_password\', \'undefined\')' }, hasShowInputButton: true, autocomplete: false, diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 30a6d39fd8..a446b9991e 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -786,7 +786,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += (field.awPassMatch) ? "awpassmatch=\"" + field.associated + "\" " : ""; html += (field.capitalize) ? "capitalize " : ""; html += (field.awSurveyQuestion) ? "aw-survey-question" : "" ; - html += (field.subCheckbox) ? "ng-disabled=\"" + field.subCheckbox.variable + "\" " : ""; + html += (field.ngDisabled) ? "ng-disabled=\"" + field.ngDisabled + "\" " : ""; html += (field.autocomplete !== undefined) ? this.attr(field, 'autocomplete') : ""; if(field.awRequiredWhen) { html += field.awRequiredWhen.init ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" " : ""; @@ -794,7 +794,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += field.awRequiredWhen.alwaysShowAsterisk ? "data-awrequired-always-show-asterisk=true " : ""; } html += (field.awValidUrl) ? "aw-valid-url " : ""; - html += (field.associated && this.form.fields[field.associated].subCheckbox) ? "ng-disabled=\"" + this.form.fields[field.associated].subCheckbox.variable + "\" " : ""; html += ">\n"; } @@ -803,7 +802,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += "id=\"" + this.form.name + "_" + fld + "_clear_btn\" "; html += "class=\"btn btn-default\" ng-click=\"clear('" + fld + "','" + field.associated + "')\" " + "aw-tool-tip=\"Clear " + field.label + "\" id=\"" + fld + "-clear-btn\" "; - html += (field.subCheckbox) ? "ng-disabled=\"" + field.subCheckbox.variable + "\" " : ""; + html += (field.ngDisabled) ? "ng-disabled=\"" + field.ngDisabled + "\" " : ""; html += " >\n"; html += "\n\n"; } @@ -818,8 +817,8 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += "