From bc9c4d355e48a89610f0a9611643799787824416 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 15 May 2015 11:01:34 -0400 Subject: [PATCH] Quick fix to survey's to create new surveys 'mode' was added to generate form, and when adding/editing new questions the 'mode' of the question form was getting mixed with the 'mode' of hte job template form. --- awx/ui/static/js/helpers/Survey.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/awx/ui/static/js/helpers/Survey.js b/awx/ui/static/js/helpers/Survey.js index 0f1f494ed6..a5636feb51 100644 --- a/awx/ui/static/js/helpers/Survey.js +++ b/awx/ui/static/js/helpers/Survey.js @@ -419,7 +419,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', var scope = params.scope, index = params.index, element, - //fld, + tmpVar, i, question = params.question, //scope.survey_questions[index], form = SurveyQuestionForm; @@ -490,7 +490,9 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.removeGenerateForm(); } scope.removeGenerateForm = scope.$on('GenerateForm', function() { + tmpVar = scope.mode; GenerateForm.inject(form, { id: 'question_'+index, mode: 'edit' , related: false, scope:scope, breadCrumbs: false}); + scope.mode = tmpVar; scope.$emit('FillQuestionForm'); }); @@ -565,7 +567,9 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', }; scope.addQuestion = function(){ - GenerateForm.inject(form, { id:'new_question', mode: 'add' , scope:scope, related: false, breadCrumbs: false}); + var tmpMode = scope.mode; + GenerateForm.inject(form, { id:'new_question', mode: 'add' , scope: scope, related: false, breadCrumbs: false}); + scope.mode = tmpMode; scope.required = true; //set the required checkbox to true via the ngmodel attached to scope.required. scope.text_min = null; scope.text_max = null; @@ -992,7 +996,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.saveSurvey = function() { Wait('start'); - if(scope.mode==="add"){ + if(scope.mode ==="add"){ $('#survey-modal-dialog').dialog('close'); if(questions.length>0){ scope.survey_questions = questions; @@ -1014,7 +1018,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.$emit('SurveySaved'); }) .error(function (data, status) { - ProcessErrors(scope, data, status, { hdr: 'Error!', + ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to add new survey. POST returned status: ' + status }); }); }