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.

This commit is contained in:
chouseknecht 2013-09-12 07:37:12 -04:00
parent 1c97cb202e
commit 9b11bb6f69
3 changed files with 31 additions and 5 deletions

View File

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

View File

@ -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,

View File

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