From 9b2470a9d35bf32f8e925b88eb3f2724baea73f2 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Fri, 20 Feb 2015 13:53:26 -0500 Subject: [PATCH] fixing range bug with awMax directive --- awx/ui/static/js/helpers/ConfigureTower.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/awx/ui/static/js/helpers/ConfigureTower.js b/awx/ui/static/js/helpers/ConfigureTower.js index 0e6736a47e..a0659fd60c 100644 --- a/awx/ui/static/js/helpers/ConfigureTower.js +++ b/awx/ui/static/js/helpers/ConfigureTower.js @@ -151,9 +151,22 @@ export default e = angular.element(document.getElementById('prompt_for_days_form')); scope.prompt_for_days_form.days_to_keep.$setViewValue(30); $compile(e)(scope); - $('#prompt-for-days-launch').attr("ng-disabled", 'prompt_for_days_form.$invalid'); - e = angular.element(document.getElementById('prompt-for-days-launch')); - $compile(e)(scope); + + // this is a work-around for getting awMax to work (without + // clearing out the form) + scope.$watch('days_to_keep', function(newVal, oldVal, scope) { + if (!newVal) { + $('#prompt-for-days-launch').prop("disabled", true); + } else if (isNaN(newVal)) { + $('#prompt-for-days-launch').prop("disabled", true); + } else if (newVal <= 0) { + $('#prompt-for-days-launch').prop("disabled", true); + } else if (newVal > 9999) { + $('#prompt-for-days-launch').prop("disabled", true); + } else { + $('#prompt-for-days-launch').prop("disabled", false); + } + }); }, buttons: [{ "label": "Cancel",