From 8aec4ed72e1eb4a5cad97e4bf9ec36caa3a0f486 Mon Sep 17 00:00:00 2001 From: mabashian Date: Thu, 27 Sep 2018 16:30:10 -0400 Subject: [PATCH 1/2] Fixes bug where schedule extra vars were not being displayed in the edit form --- .../src/scheduler/schedulerEdit.controller.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/awx/ui/client/src/scheduler/schedulerEdit.controller.js b/awx/ui/client/src/scheduler/schedulerEdit.controller.js index 4aa3044adf..512df41aee 100644 --- a/awx/ui/client/src/scheduler/schedulerEdit.controller.js +++ b/awx/ui/client/src/scheduler/schedulerEdit.controller.js @@ -316,13 +316,13 @@ function($filter, $state, $stateParams, Wait, $scope, moment, // the extra vars codemirror is ONLY shown if the // schedule is for a JT and the JT has // ask_variables_on_launch = true. - $scope.extraVars = ParentObject.extra_vars === '' ? '---' : ParentObject.extra_vars; $scope.noVars = false; ParseTypeChange({ scope: $scope, variable: 'extraVars', parse_variable: 'parseType', - field_id: 'SchedulerForm-extraVars' + field_id: 'SchedulerForm-extraVars', + readOnly: !$scope.schedule_obj.summary_fields.user_capabilities.edit }); } else { $scope.noVars = true; @@ -366,16 +366,6 @@ function($filter, $state, $stateParams, Wait, $scope, moment, $scope.missingSurveyValue = processed.missingSurveyValue; - $scope.extraVars = (processed.extra_data === '' || _.isEmpty(processed.extra_data)) ? '---' : '---\n' + jsyaml.safeDump(processed.extra_data); - - ParseTypeChange({ - scope: $scope, - variable: 'extraVars', - parse_variable: 'parseType', - field_id: 'SchedulerForm-extraVars', - readOnly: !$scope.schedule_obj.summary_fields.user_capabilities.edit - }); - $scope.promptData = { launchConf: launchConf, launchOptions: launchOptions, From 6c98e6c3a008ef814bd29c45637cffec3a6faac4 Mon Sep 17 00:00:00 2001 From: mabashian Date: Thu, 27 Sep 2018 16:49:23 -0400 Subject: [PATCH 2/2] Actually fix extra vars on edit schedule. This commit takes into account survey question answers which need to get pulled out of extra vars and displayed in the prompt. --- .../src/scheduler/schedulerEdit.controller.js | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/awx/ui/client/src/scheduler/schedulerEdit.controller.js b/awx/ui/client/src/scheduler/schedulerEdit.controller.js index 512df41aee..0e27408c1f 100644 --- a/awx/ui/client/src/scheduler/schedulerEdit.controller.js +++ b/awx/ui/client/src/scheduler/schedulerEdit.controller.js @@ -243,6 +243,15 @@ function($filter, $state, $stateParams, Wait, $scope, moment, let jobTemplate = new JobTemplate(); + const codeMirrorExtraVars = () => { + ParseTypeChange({ + scope: $scope, + variable: 'extraVars', + parse_variable: 'parseType', + field_id: 'SchedulerForm-extraVars' + }); + }; + Rest.setUrl(scheduleResolve.related.credentials); $q.all([jobTemplate.optionsLaunch(ParentObject.id), jobTemplate.getLaunch(ParentObject.id), Rest.get()]) @@ -312,21 +321,10 @@ function($filter, $state, $stateParams, Wait, $scope, moment, prompts.credentials.value = defaultCredsWithoutOverrides.concat(scheduleCredentials); - if (launchConf.ask_variables_on_launch) { - // the extra vars codemirror is ONLY shown if the - // schedule is for a JT and the JT has - // ask_variables_on_launch = true. - $scope.noVars = false; - ParseTypeChange({ - scope: $scope, - variable: 'extraVars', - parse_variable: 'parseType', - field_id: 'SchedulerForm-extraVars', - readOnly: !$scope.schedule_obj.summary_fields.user_capabilities.edit - }); - } else { - $scope.noVars = true; - } + // the extra vars codemirror is ONLY shown if the + // schedule is for a JT and the JT has + // ask_variables_on_launch = true + $scope.noVars = !launchConf.ask_variables_on_launch; if (!launchConf.survey_enabled && !launchConf.ask_inventory_on_launch && @@ -343,6 +341,10 @@ function($filter, $state, $stateParams, Wait, $scope, moment, launchConf.passwords_needed_to_start.length === 0 && launchConf.variables_needed_to_start.length === 0) { $scope.showPromptButton = false; + + if (launchConf.ask_variables_on_launch) { + codeMirrorExtraVars(); + } } else { $scope.showPromptButton = true; @@ -366,6 +368,10 @@ function($filter, $state, $stateParams, Wait, $scope, moment, $scope.missingSurveyValue = processed.missingSurveyValue; + $scope.extraVars = (processed.extra_data === '' || _.isEmpty(processed.extra_data)) ? '---' : '---\n' + jsyaml.safeDump(processed.extra_data); + + codeMirrorExtraVars(); + $scope.promptData = { launchConf: launchConf, launchOptions: launchOptions, @@ -387,6 +393,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment, watchForPromptChanges(); }); } else { + codeMirrorExtraVars(); $scope.promptData = { launchConf: launchConf, launchOptions: launchOptions,