From 9b11bb6f697b97a364d0eb0605ba4a381248e7af Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Thu, 12 Sep 2013 07:37:12 -0400 Subject: [PATCH] AC-453 Fixed ongoing job template issue where changing form elements does not cause the Save button to enable. Issue was playbook value was set before list of playbook options was loaded. Now during process of loading playbooks we check for the scope.playbook value. If a match is found, set validity property of scope.form.plabyook.required to true. --- awx/ui/static/js/controllers/JobTemplates.js | 5 +++- awx/ui/static/js/forms/JobTemplates.js | 6 ++--- awx/ui/static/lib/ansible/Utilities.js | 25 +++++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index 1878c2d9b9..f722d5e605 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -297,6 +297,9 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route scope.playbook_options = []; for (var i=0; i < data.length; i++) { scope.playbook_options.push(data[i]); + if (data[i] == scope.playbook) { + scope['job_templates_form']['playbook'].$setValidity('required',true); + } } if (!scope.$$phase) { scope.$digest(); @@ -514,7 +517,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route scope[fld] = master[fld]; } scope.parseType = 'yaml'; - //$('#forks-slider').slider("option", "value", scope.forks); + $('#forks-slider').slider("option", "value", scope.forks); }; // Related set: Add button diff --git a/awx/ui/static/js/forms/JobTemplates.js b/awx/ui/static/js/forms/JobTemplates.js index d55bf78492..b5e0c3363b 100644 --- a/awx/ui/static/js/forms/JobTemplates.js +++ b/awx/ui/static/js/forms/JobTemplates.js @@ -85,10 +85,10 @@ angular.module('JobTemplateFormDefinition', []) forks: { label: 'Forks', id: 'forks-number', - type: 'text', - /*integer: true, + type: 'number', + integer: true, min: 0, - spinner: true,*/ + spinner: true, "default": '0', addRequired: false, editRequired: false, diff --git a/awx/ui/static/lib/ansible/Utilities.js b/awx/ui/static/lib/ansible/Utilities.js index 5578719d80..28887d6a0a 100644 --- a/awx/ui/static/lib/ansible/Utilities.js +++ b/awx/ui/static/lib/ansible/Utilities.js @@ -266,4 +266,27 @@ angular.module('Utilities',[]) $('.spinny, .overlay').fadeOut(1000); } } - }]); + }]) + + /* DeugForm(form_name) + * + * Use to log the $pristine and $invalid properties of each form element. Helpful when form + * buttons fail to enable/disable properly. + * + */ + .factory('DebugForm', [ function() { + return function(form_name) { + $('form[name="' + form_name + '"]').find('select, input, button, textarea').each(function(index){ + var name = $(this).attr('name'); + if (name) { + if (scope['job_templates_form'][name]) { + console.log(name + ' pristine: ' + scope['job_templates_form'][name].$pristine); + console.log(name + ' invalid: ' + scope['job_templates_form'][name].$invalid); + } + } + }); + } + }]); + + +