From 639eec95e77f4b7b721cb49df881060047f6febd Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Wed, 23 Nov 2016 16:33:54 -0500 Subject: [PATCH] Workflow edit survey/show survey on launch --- .../job-templates-list.directive.js | 2 +- awx/ui/client/src/forms/JobTemplates.js | 43 ++++--- awx/ui/client/src/forms/Workflows.js | 15 ++- awx/ui/client/src/helpers/JobTemplates.js | 2 +- .../getsurveyquestions.factory.js | 10 +- .../launchjob.factory.js | 8 ++ .../job-submission.controller.js | 13 +- .../job-submission.partial.html | 6 +- .../organizations-job-templates.controller.js | 2 +- .../src/partials/survey-maker-modal.html | 18 +-- .../portal-mode-job-templates.controller.js | 2 +- awx/ui/client/src/shared/form-generator.js | 34 +++--- .../job-template-add.controller.js | 8 +- .../job-template-edit.controller.js | 8 +- .../survey-maker/questions/edit.factory.js | 2 +- .../shared/question-definition.form.js | 2 +- .../survey-maker/surveys/edit.factory.js | 8 ++ .../survey-maker/surveys/init.factory.js | 114 ++++++++---------- .../edit-workflow/workflow-edit.controller.js | 40 ++++-- .../workflow-results.service.js | 2 +- .../job-results.controller-test.js | 4 + .../workflows/workflow-add.controller-test.js | 5 + 22 files changed, 206 insertions(+), 142 deletions(-) diff --git a/awx/ui/client/src/dashboard/lists/job-templates/job-templates-list.directive.js b/awx/ui/client/src/dashboard/lists/job-templates/job-templates-list.directive.js index 714b3c088a..928f03a1c4 100644 --- a/awx/ui/client/src/dashboard/lists/job-templates/job-templates-list.directive.js +++ b/awx/ui/client/src/dashboard/lists/job-templates/job-templates-list.directive.js @@ -43,7 +43,7 @@ export default }; scope.launchJobTemplate = function(jobTemplateId){ - InitiatePlaybookRun({ scope: scope, id: jobTemplateId }); + InitiatePlaybookRun({ scope: scope, id: jobTemplateId, job_type: 'job_template' }); }; scope.editJobTemplate = function (jobTemplateId) { diff --git a/awx/ui/client/src/forms/JobTemplates.js b/awx/ui/client/src/forms/JobTemplates.js index 11a16701da..9fe64f0469 100644 --- a/awx/ui/client/src/forms/JobTemplates.js +++ b/awx/ui/client/src/forms/JobTemplates.js @@ -373,23 +373,6 @@ export default }, buttons: { //for now always generates @@ -229,12 +229,12 @@
-
+
INVENTORY
None selected
-
+
CREDENTIAL
None selected
diff --git a/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js b/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js index d8e820d73f..7d01276df8 100644 --- a/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js +++ b/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js @@ -47,7 +47,7 @@ export default ['$scope', '$rootScope', '$location', '$log', }; $scope.submitJob = function(id) { - InitiatePlaybookRun({ scope: $scope, id: id }); + InitiatePlaybookRun({ scope: $scope, id: id, job_type: 'job_template' }); }; $scope.scheduleJob = function(id) { diff --git a/awx/ui/client/src/partials/survey-maker-modal.html b/awx/ui/client/src/partials/survey-maker-modal.html index 4ab7dfcc83..7ee3974129 100644 --- a/awx/ui/client/src/partials/survey-maker-modal.html +++ b/awx/ui/client/src/partials/survey-maker-modal.html @@ -32,13 +32,13 @@
-
+
-
+
-
+
PREVIEW
@@ -56,13 +56,13 @@ {{question.question_description}}
- +   -
+
@@ -80,10 +80,10 @@
- - - - + + + +
diff --git a/awx/ui/client/src/portal-mode/portal-mode-job-templates.controller.js b/awx/ui/client/src/portal-mode/portal-mode-job-templates.controller.js index cd55915e40..5453d9a248 100644 --- a/awx/ui/client/src/portal-mode/portal-mode-job-templates.controller.js +++ b/awx/ui/client/src/portal-mode/portal-mode-job-templates.controller.js @@ -18,7 +18,7 @@ export function PortalModeJobTemplatesController($scope, PortalJobTemplateList, } $scope.submitJob = function(id) { - InitiatePlaybookRun({ scope: $scope, id: id }); + InitiatePlaybookRun({ scope: $scope, id: id, job_type: 'job_template' }); }; } diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index b7f82f9fab..25e2204de9 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -268,7 +268,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat // this.addListeners(); // } if (options.mode === 'add') { - this.applyDefaults(); + this.applyDefaults(form, this.scope); } } @@ -282,21 +282,21 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat $(this).remove(); }); - // Prepend an asterisk to required field label - $('.form-control[required], input[type="radio"][required]').each(function () { - var label, span; - if (Empty($(this).attr('aw-required-when'))) { - label = $(this).closest('.form-group').find('label').first(); - if (label.length > 0) { - span = label.children('span'); - if (span.length > 0 && !span.first().hasClass('prepend-asterisk')) { - span.first().addClass('prepend-asterisk'); - } else if (span.length <= 0 && !label.first().hasClass('prepend-asterisk')) { - label.first().addClass('prepend-asterisk'); - } - } - } - }); + // // Prepend an asterisk to required field label + // $('.form-control[required], input[type="radio"][required]').each(function () { + // var label, span; + // if (Empty($(this).attr('aw-required-when'))) { + // label = $(this).closest('.form-group').find('label').first(); + // if (label.length > 0) { + // span = label.children('span'); + // if (span.length > 0 && !span.first().hasClass('prepend-asterisk')) { + // span.first().addClass('prepend-asterisk'); + // } else if (span.length <= 0 && !label.first().hasClass('prepend-asterisk')) { + // label.first().addClass('prepend-asterisk'); + // } + // } + // } + // }); try { $('#help-modal').empty().dialog('destroy'); @@ -476,7 +476,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat } } if (this.mode === 'add') { - this.applyDefaults(); + this.applyDefaults(form, scope); } }, diff --git a/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js b/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js index 1313fc0051..bbb97b3684 100644 --- a/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js +++ b/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js @@ -8,13 +8,13 @@ [ '$filter', '$scope', '$rootScope', '$compile', '$location', '$log', '$stateParams', 'JobTemplateForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'ClearScope', 'GetBasePath', 'md5Setup', 'ParseTypeChange', 'Wait', - 'Empty', 'ToJSON', 'CallbackHelpInit', 'initSurvey', 'Prompt', 'GetChoices', '$state', + 'Empty', 'ToJSON', 'CallbackHelpInit', 'Prompt', 'GetChoices', '$state', 'CreateSelect2', '$q', function( $filter, $scope, $rootScope, $compile, $location, $log, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert, ProcessErrors, ClearScope, GetBasePath, md5Setup, ParseTypeChange, Wait, - Empty, ToJSON, CallbackHelpInit, SurveyControllerInit, Prompt, GetChoices, + Empty, ToJSON, CallbackHelpInit, Prompt, GetChoices, $state, CreateSelect2, $q ) { @@ -54,10 +54,6 @@ default_val: false }); CallbackHelpInit({ scope: $scope }); - SurveyControllerInit({ - scope: $scope, - parent_scope: $scope - }); } callback = function() { diff --git a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js index 8bfa760941..ac49b172b1 100644 --- a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js +++ b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js @@ -56,7 +56,8 @@ export default SurveyControllerInit({ scope: $scope, parent_scope: $scope, - id: id + id: id, + templateType: 'job_template' }); } @@ -287,7 +288,7 @@ export default Wait('start'); if ($scope.removeSurveySaved) { - $scope.rmoveSurveySaved(); + $scope.removeSurveySaved(); } $scope.removeSurveySaved = $scope.$on('SurveySaved', function() { Wait('stop'); @@ -662,7 +663,8 @@ export default InitiatePlaybookRun({ scope: $scope, - id: id + id: id, + job_type: 'job_template' }); } }; diff --git a/awx/ui/client/src/templates/survey-maker/questions/edit.factory.js b/awx/ui/client/src/templates/survey-maker/questions/edit.factory.js index 37a899f5d4..08b04da907 100644 --- a/awx/ui/client/src/templates/survey-maker/questions/edit.factory.js +++ b/awx/ui/client/src/templates/survey-maker/questions/edit.factory.js @@ -82,7 +82,7 @@ export default } scope.removeGenerateForm = scope.$on('GenerateForm', function() { tmpVar = scope.mode; - GenerateForm.inject(form, { id: 'survey_maker_question_form', mode: 'edit', related: false, scope:scope }); + GenerateForm.inject(form, { id: 'survey_maker_question_form', mode: 'edit', related: false, scope:scope, noPanel: true }); scope.mode = tmpVar; scope.$emit('FillQuestionForm'); }); diff --git a/awx/ui/client/src/templates/survey-maker/shared/question-definition.form.js b/awx/ui/client/src/templates/survey-maker/shared/question-definition.form.js index e888590cfd..289ab2b0b0 100644 --- a/awx/ui/client/src/templates/survey-maker/shared/question-definition.form.js +++ b/awx/ui/client/src/templates/survey-maker/shared/question-definition.form.js @@ -43,7 +43,7 @@ export default variable: { realName: 'variable', type: 'custom', - control:'