mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Survey maker
changed the way that question data is gathered from the question form. Instead of looping through I explicitly set the varaibles needed for the particular question
This commit is contained in:
@@ -706,54 +706,67 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
};
|
};
|
||||||
|
|
||||||
scope.submitQuestion = function(){
|
scope.submitQuestion = function(){
|
||||||
var form = SurveyQuestionForm,
|
var data = {},
|
||||||
data = {},
|
//form = SurveyQuestionForm,
|
||||||
// labels={},
|
// labels={},
|
||||||
// min= "min",
|
// min= "min",
|
||||||
// max = "max",
|
// max = "max",
|
||||||
fld, key, elementID;
|
// fld,
|
||||||
|
key, elementID;
|
||||||
//generator.clearApiErrors();
|
//generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (fld in form.fields) {
|
//create data object for each submitted question
|
||||||
if(fld==='required'){
|
data.question_name = scope.question_name;
|
||||||
data[fld] = (scope[fld]===true) ? true : false;
|
data.question_description = (scope.question_description) ? scope.question_description : "" ;
|
||||||
}
|
data.required = scope.required;
|
||||||
if(scope[fld]){
|
data.type = scope.type.type;
|
||||||
if(fld === "type"){
|
data.variable = scope.variable;
|
||||||
data[fld] = scope[fld].type;
|
data.min = (scope.type.type === 'text') ? scope.text_min : (scope.type.type === 'textarea') ? scope.textarea_min : (scope.type.type === "float") ? scope.float_min : (scope.type.type==="integer") ? scope.int_min : "" ;
|
||||||
|
data.max = (scope.type.type === 'text') ? scope.text_max : (scope.type.type === 'textarea') ? scope.textarea_max : (scope.type.type === "float") ? scope.float_max : (scope.type.type==="integer") ? scope.int_max : "" ;
|
||||||
|
data.default = (scope.type.type === 'textarea') ? scope.default_textarea : (scope.type.type === "float") ? scope.default_float : (scope.type.type==="integer") ? scope.default_int : (scope.type.type === "multiselect") ? scope.default_multiselect : (scope.default) ? scope.default : "" ;
|
||||||
|
data.choices = (scope.type.type === "multiplechoice") ? scope.choices : (scope.type.type === 'multiselect') ? scope.choices : "" ;
|
||||||
|
|
||||||
if(scope[fld].type === 'text'){
|
// for (fld in form.fields) {
|
||||||
data.min = scope.text_min;
|
// if(fld==='required'){
|
||||||
data.max = scope.text_max;
|
// data[fld] = (scope[fld]===true) ? true : false;
|
||||||
// data.default = scope.default_text;
|
// }
|
||||||
}
|
// if(scope[fld]){
|
||||||
if(scope[fld].type === 'textarea'){
|
// if(fld === "type"){
|
||||||
data.min = scope.textarea_min;
|
// data[fld] = scope[fld].type;
|
||||||
data.max = scope.textarea_max;
|
|
||||||
// data.default = scope.default_text;
|
// if(scope[fld].type === 'text'){
|
||||||
}
|
// data.min = scope.text_min;
|
||||||
if(scope[fld].type === 'float'){
|
// data.max = scope.text_max;
|
||||||
data.min = scope.float_min;
|
// // data.default = scope.default_text;
|
||||||
data.max = scope.float_max;
|
// }
|
||||||
data.default = scope.default_float;
|
// if(scope[fld].type === 'textarea'){
|
||||||
}
|
// data.min = scope.textarea_min;
|
||||||
if(scope[fld].type==="integer" ){
|
// data.max = scope.textarea_max;
|
||||||
data.min = scope.int_min;
|
// // data.default = scope.default_textarea;
|
||||||
data.max = scope.int_max;
|
// }
|
||||||
data.default = scope.default_int;
|
// if(scope[fld].type === 'float'){
|
||||||
}
|
// data.min = scope.float_min;
|
||||||
}
|
// data.max = scope.float_max;
|
||||||
else if(fld==='default_multiselect'){
|
// data.default = scope.default_float;
|
||||||
data.default = scope.default_multiselect;
|
// }
|
||||||
}
|
// if(scope[fld].type==="integer" ){
|
||||||
else{
|
// data.min = scope.int_min;
|
||||||
data[fld] = scope[fld];
|
// data.max = scope.int_max;
|
||||||
}
|
// data.default = scope.default_int;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if(fld==='default_multiselect'){
|
||||||
|
// data.default = scope.default_multiselect;
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// data[fld] = scope[fld];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
if(scope.mode === 'add' || scope.mode==="edit" && scope.can_edit === true){
|
if(scope.mode === 'add' || scope.mode==="edit" && scope.can_edit === true){
|
||||||
$('#survey-save-button').removeAttr('disabled');
|
$('#survey-save-button').removeAttr('disabled');
|
||||||
|
|||||||
Reference in New Issue
Block a user