1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

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.
This commit is contained in:
Jared Tabor 2015-05-15 11:01:34 -04:00
parent e41359c8cc
commit bc9c4d355e

View File

@ -419,7 +419,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
var scope = params.scope, var scope = params.scope,
index = params.index, index = params.index,
element, element,
//fld, tmpVar,
i, i,
question = params.question, //scope.survey_questions[index], question = params.question, //scope.survey_questions[index],
form = SurveyQuestionForm; form = SurveyQuestionForm;
@ -490,7 +490,9 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
scope.removeGenerateForm(); scope.removeGenerateForm();
} }
scope.removeGenerateForm = scope.$on('GenerateForm', function() { scope.removeGenerateForm = scope.$on('GenerateForm', function() {
tmpVar = scope.mode;
GenerateForm.inject(form, { id: 'question_'+index, mode: 'edit' , related: false, scope:scope, breadCrumbs: false}); GenerateForm.inject(form, { id: 'question_'+index, mode: 'edit' , related: false, scope:scope, breadCrumbs: false});
scope.mode = tmpVar;
scope.$emit('FillQuestionForm'); scope.$emit('FillQuestionForm');
}); });
@ -565,7 +567,9 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
}; };
scope.addQuestion = function(){ 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.required = true; //set the required checkbox to true via the ngmodel attached to scope.required.
scope.text_min = null; scope.text_min = null;
scope.text_max = null; scope.text_max = null;
@ -992,7 +996,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
scope.saveSurvey = function() { scope.saveSurvey = function() {
Wait('start'); Wait('start');
if(scope.mode==="add"){ if(scope.mode ==="add"){
$('#survey-modal-dialog').dialog('close'); $('#survey-modal-dialog').dialog('close');
if(questions.length>0){ if(questions.length>0){
scope.survey_questions = questions; scope.survey_questions = questions;
@ -1014,7 +1018,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
scope.$emit('SurveySaved'); scope.$emit('SurveySaved');
}) })
.error(function (data, status) { .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 }); msg: 'Failed to add new survey. POST returned status: ' + status });
}); });
} }