Merge pull request #5996 from mabashian/5972-single-select-survey

Optional single select survey question with default bug fix
This commit is contained in:
Michael Abashian 2017-04-11 13:25:32 -04:00 committed by GitHub
commit 34c278fef5
2 changed files with 10 additions and 3 deletions

View File

@ -42,6 +42,13 @@ export default
else if(question.type === "multiplechoice") {
question.model = question.default ? angular.copy(question.default) : "";
question.choices = question.choices.split(/\n/);
// Add a default empty string option to the choices array. If this choice is
// selected then the extra var will not be sent when we POST to the launch
// endpoint
if(!question.required) {
question.choices.unshift('');
}
}
else if(question.type === "float"){
question.model = (!Empty(question.default)) ? angular.copy(question.default) : (!Empty(question.default_float)) ? angular.copy(question.default_float) : "";

View File

@ -90,9 +90,9 @@ export default
// for optional select lists, if they are left blank make sure we submit
// a value that the API will consider "empty"
//
case "multiplechoice":
job_launch_data.extra_vars[fld] = "";
break;
// ISSUE: I don't think this logic ever actually fires
// When I tested this, we don't pass this extra var back
// through the api when the mutliselect is optional and empty
case "multiselect":
job_launch_data.extra_vars[fld] = [];
break;