mirror of
https://github.com/ansible/awx.git
synced 2026-05-22 08:17:39 -02:30
full commit of fixes to the survey by jared
This commit is contained in:
@@ -106,13 +106,13 @@ export default
|
|||||||
control:'<div class="row">'+
|
control:'<div class="row">'+
|
||||||
'<div class="col-xs-6">'+
|
'<div class="col-xs-6">'+
|
||||||
'<label for="text_min"><span class="label-text">Minimum Length</span></label><input id="text_min" type="number" name="text_min" ng-model="text_min" min=0 aw-min="0" aw-max="text_max" class="form-control" integer />'+
|
'<label for="text_min"><span class="label-text">Minimum Length</span></label><input id="text_min" type="number" name="text_min" ng-model="text_min" min=0 aw-min="0" aw-max="text_max" class="form-control" integer />'+
|
||||||
'<div class="error" ng-show="survey_question_form.text_min.$error.number || survey_question_form.text_min.$error.integer">The minimum length you entered is not a number. Please enter a number.</div>'+
|
'<div class="error" ng-show="survey_question_form.text_min.$error.number">The minimum length you entered is not a number. Please enter a number.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.text_min.$error.awMax">The minimium length is too high. Please enter a lower number.</div>'+
|
'<div class="error" ng-show="survey_question_form.text_min.$error.awMax">The minimium length is too high. Please enter a lower number.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.text_min.$error.awMin">The minimum length is too low. Please enter a positive number.</div>'+
|
'<div class="error" ng-show="survey_question_form.text_min.$error.awMin">The minimum length is too low. Please enter a positive number.</div>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'<div class="col-xs-6">'+
|
'<div class="col-xs-6">'+
|
||||||
'<label for="text_max"><span class="label-text">Maximum Length</span></label><input id="text_max" type="number" name="text_max" ng-model="text_max" aw-min="text_min || 0" class="form-control" integer >'+
|
'<label for="text_max"><span class="label-text">Maximum Length</span></label><input id="text_max" type="number" name="text_max" ng-model="text_max" aw-min="text_min || 0" min=0 class="form-control" integer >'+
|
||||||
'<div class="error" ng-show="survey_question_form.text_max.$error.number || survey_question_form.text_max.$error.integer">The maximum length you entered is not a number. Please enter a number.</div>'+
|
'<div class="error" ng-show="survey_question_form.text_max.$error.number">The maximum length you entered is not a number. Please enter a number.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.text_max.$error.awMin">The maximum length is too low. Please enter a number larger than the minimum length you set.</div>'+
|
'<div class="error" ng-show="survey_question_form.text_max.$error.awMin">The maximum length is too low. Please enter a number larger than the minimum length you set.</div>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'</div>',
|
'</div>',
|
||||||
@@ -127,13 +127,13 @@ export default
|
|||||||
control:'<div class="row">'+
|
control:'<div class="row">'+
|
||||||
'<div class="col-xs-6">'+
|
'<div class="col-xs-6">'+
|
||||||
'<label for="textarea_min"><span class="label-text">Minimum Length</span></label><input id="textarea_min" type="number" name="textarea_min" ng-model="textarea_min" min=0 aw-min="0" aw-max="textarea_max" class="form-control" integer />'+
|
'<label for="textarea_min"><span class="label-text">Minimum Length</span></label><input id="textarea_min" type="number" name="textarea_min" ng-model="textarea_min" min=0 aw-min="0" aw-max="textarea_max" class="form-control" integer />'+
|
||||||
'<div class="error" ng-show="survey_question_form.textarea_min.$error.number || survey_question_form.textarea_min.$error.integer">The minimum length you entered is not a number. Please enter a number.</div>'+
|
'<div class="error" ng-show="survey_question_form.textarea_min.$error.number">The minimum length you entered is not a number. Please enter a number.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.textarea_min.$error.awMax">The minimium length is too high. Please enter a lower number.</div>'+
|
'<div class="error" ng-show="survey_question_form.textarea_min.$error.awMax">The minimium length is too high. Please enter a lower number.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.textarea_min.$error.awMin">The minimum length is too low. Please enter a positive number.</div>'+
|
'<div class="error" ng-show="survey_question_form.textarea_min.$error.awMin">The minimum length is too low. Please enter a positive number.</div>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'<div class="col-xs-6">'+
|
'<div class="col-xs-6">'+
|
||||||
'<label for="textarea_max"><span class="label-text">Maximum Length</span></label><input id="textarea_max" type="number" name="textarea_max" ng-model="textarea_max" aw-min="textarea_min || 0" class="form-control" integer >'+
|
'<label for="textarea_max"><span class="label-text">Maximum Length</span></label><input id="textarea_max" type="number" name="textarea_max" ng-model="textarea_max" aw-min="textarea_min || 0" min=0 class="form-control" integer >'+
|
||||||
'<div class="error" ng-show="survey_question_form.textarea_max.$error.number || survey_question_form.textarea_max.$error.integer">The maximum length you entered is not a number. Please enter a number.</div>'+
|
'<div class="error" ng-show="survey_question_form.textarea_max.$error.number">The maximum length you entered is not a number. Please enter a number.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.textarea_max.$error.awMin">The maximum length is too low. Please enter a number larger than the minimum length you set.</div>'+
|
'<div class="error" ng-show="survey_question_form.textarea_max.$error.awMin">The maximum length is too low. Please enter a number larger than the minimum length you set.</div>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'</div>',
|
'</div>',
|
||||||
@@ -148,12 +148,12 @@ export default
|
|||||||
control:'<div class="row">'+
|
control:'<div class="row">'+
|
||||||
'<div class="col-xs-6">'+
|
'<div class="col-xs-6">'+
|
||||||
'<label for="minimum"><span class="label-text">Minimum</span></label><input id="int_min" type="number" name="int_min" ng-model="int_min" aw-max="int_max" class="form-control" integer >'+
|
'<label for="minimum"><span class="label-text">Minimum</span></label><input id="int_min" type="number" name="int_min" ng-model="int_min" aw-max="int_max" class="form-control" integer >'+
|
||||||
'<div class="error" ng-show="survey_question_form.int_min.$error.number || survey_question_form.int_min.$error.integer">Please enter a valid integer.</div>'+
|
'<div class="error" ng-show="survey_question_form.int_min.$error.integer || survey_question_form.int_min.$error.number">Please enter a valid integer.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.int_min.$error.awMax">Please enter a smaller integer.</div>'+
|
'<div class="error" ng-show="survey_question_form.int_min.$error.awMax">Please enter a smaller integer.</div>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'<div class="col-xs-6">'+
|
'<div class="col-xs-6">'+
|
||||||
'<label for="minimum"><span class="label-text">Maximum</span></label><input id="int_max" type="number" name="int_max" ng-model="int_max" aw-min="int_min" class="form-control" integer >'+
|
'<label for="minimum"><span class="label-text">Maximum</span></label><input id="int_max" type="number" name="int_max" ng-model="int_max" aw-min="int_min" class="form-control" integer >'+
|
||||||
'<div class="error" ng-show="survey_question_form.int_max.$error.number || survey_question_form.int_max.$error.integer">Please enter a valid integer.</div>'+
|
'<div class="error" ng-show="survey_question_form.int_max.$error.integer || survey_question_form.int_max.$error.number">Please enter a valid integer.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.int_max.$error.awMin">Please enter a larger integer.</div>'+
|
'<div class="error" ng-show="survey_question_form.int_max.$error.awMin">Please enter a larger integer.</div>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'</div>',
|
'</div>',
|
||||||
@@ -168,7 +168,7 @@ export default
|
|||||||
control: '<div class="row">'+
|
control: '<div class="row">'+
|
||||||
'<div class="col-xs-6">'+
|
'<div class="col-xs-6">'+
|
||||||
'<label for="minimum"><span class="label-text">Minimum</span></label><input id="float_min" type="number" name="float_min" ng-model="float_min" class="form-control" smart-float aw-max="float_max">'+
|
'<label for="minimum"><span class="label-text">Minimum</span></label><input id="float_min" type="number" name="float_min" ng-model="float_min" class="form-control" smart-float aw-max="float_max">'+
|
||||||
'<div class="error" ng-show="survey_question_form.float_min.$error.float">Please enter a valid float.</div>'+
|
'<div class="error" ng-show="survey_question_form.float_min.$error.float || survey_question_form.float_min.$error.number">Please enter a valid float.</div>'+
|
||||||
'<div class="error" ng-show="survey_question_form.float_min.$error.awMax">Please enter a smaller float.</div>'+
|
'<div class="error" ng-show="survey_question_form.float_min.$error.awMax">Please enter a smaller float.</div>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'<div class="col-xs-6">'+
|
'<div class="col-xs-6">'+
|
||||||
@@ -183,35 +183,35 @@ export default
|
|||||||
editRequired: true,
|
editRequired: true,
|
||||||
column: 2
|
column: 2
|
||||||
},
|
},
|
||||||
default: {
|
default:{
|
||||||
realName: 'default_answer',
|
realName: 'default_answer',
|
||||||
label: 'Default Answer',
|
type: 'custom' ,
|
||||||
type: 'text',
|
control: '<div class="form-group" >'+
|
||||||
addRequired: false,
|
'<label for="default"><span class="label-text">Default Answer</span></label>'+
|
||||||
editRequired: false,
|
'<div>'+
|
||||||
|
'<input type="text" ng-model="default" name="default" id="default" class="form-control ng-valid ng-dirty">'+
|
||||||
|
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="invalidChoice">Please enter an answer for the choices listed.</div>' +
|
||||||
|
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="minTextError">The answer is shorter than the minimium length. Please make the answer longer. </div>' +
|
||||||
|
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="maxTextError">The answer is longer than the maximum length. Please make the answer shorter. </div>' +
|
||||||
|
'<div class="error api-error ng-binding" id="survey_question-default-api-error" ng-bind="default_api_error"></div>'+
|
||||||
|
'</div>'+
|
||||||
|
'</div>',
|
||||||
column: 2,
|
column: 2,
|
||||||
ngHide: 'type.type === "textarea" || type.type === "multiselect" || type.type === "integer" || type.type === "float" '
|
ngHide: 'type.type === "textarea" || type.type === "multiselect" || type.type === "integer" || type.type === "float" '
|
||||||
},
|
},
|
||||||
// default_text: {
|
|
||||||
// realName: 'default_answer',
|
|
||||||
// type: 'custom',
|
|
||||||
// control: '<div>'+
|
|
||||||
// '<label for="default_text"><span class="label-text">Default Answer</span></label>'+
|
|
||||||
// '<input type="text" ng-model="default_text" name="default_text" class="form-control" />'+
|
|
||||||
// '<div class="error" ng-show="survey_question_form.default_text.$error.minlength || survey_question_form.default_text.$error.maxlength"> The answer must be between {{text_min}} to {{text_max}} characters long!</div>'+
|
|
||||||
// '</div>',
|
|
||||||
// column: 2,
|
|
||||||
// ngShow: 'type.type === "text" '
|
|
||||||
// },
|
|
||||||
default_multiselect: {
|
default_multiselect: {
|
||||||
realName: 'default_answer',
|
realName: 'default_answer' ,
|
||||||
label: 'Default Answer',
|
type: 'custom',
|
||||||
type: 'textarea',
|
control: '<div class="form-group">'+
|
||||||
rows: 3,
|
'<label for="default_multiselect"><span class="label-text">Default Answer</span></label>'+
|
||||||
addRequired: false,
|
'<div>'+
|
||||||
editRequired: false,
|
'<textarea rows="3" ng-model="default_multiselect" name="default_multiselect" class="form-control ng-pristine ng-valid" id="default_multiselect" aw-watch=""></textarea>'+
|
||||||
|
'<div class="error ng-hide" id=survey_question-default_multiselect-duplicate-error" ng-show="invalidChoice">Please enter an answer/answers for the choices listed.</div>' +
|
||||||
|
'<div class="error api-error ng-binding" id="survey_question-default_multiselect-api-error" ng-bind="default_multiselect_api_error"></div>'+
|
||||||
|
'</div>'+
|
||||||
|
'</div>',
|
||||||
column: 2,
|
column: 2,
|
||||||
ngShow: 'type.type === "multiselect" '
|
ngShow: 'type.type==="multiselect" '
|
||||||
},
|
},
|
||||||
default_int: {
|
default_int: {
|
||||||
realName: 'default_answer',
|
realName: 'default_answer',
|
||||||
@@ -238,13 +238,18 @@ export default
|
|||||||
ngShow: 'type.type=== "float" '
|
ngShow: 'type.type=== "float" '
|
||||||
},
|
},
|
||||||
default_textarea: {
|
default_textarea: {
|
||||||
realName: 'default_answer',
|
realName: "default_answer" ,
|
||||||
label: 'Default Answer',
|
type: 'custom',
|
||||||
type: 'textarea',
|
control: '<div class="form-group">'+
|
||||||
rows: 3,
|
'<label for="default_textarea"><span class="label-text">Default Answer</span></label>'+
|
||||||
addRequired: false,
|
'<div>'+
|
||||||
editRequired: false,
|
'<textarea rows="3" ng-model="default_textarea" name="default_textarea" class="form-control ng-valid ng-dirty" id="default_textarea" aw-watch=""></textarea>'+
|
||||||
column: 2,
|
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="minTextError">The answer is shorter than the minimium length. Please make the answer longer. </div>' +
|
||||||
|
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="maxTextError">The answer is longer than the maximum length. Please make the answer shorter. </div>' +
|
||||||
|
'<div class="error api-error ng-binding" id="survey_question-default_textarea-api-error" ng-bind="default_textarea_api_error"></div>'+
|
||||||
|
'</div>'+
|
||||||
|
'</div>',
|
||||||
|
column : 2,
|
||||||
ngShow: 'type.type === "textarea" '
|
ngShow: 'type.type === "textarea" '
|
||||||
},
|
},
|
||||||
required: {
|
required: {
|
||||||
|
|||||||
@@ -72,12 +72,18 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scope.survey_enabled===true){
|
if(scope.survey_enabled===true){
|
||||||
for (var fld in scope.job_launch_form){
|
for (var i=0; i < scope.survey_questions.length; i++){
|
||||||
//grab only survey question fields, including those that are zero or a blank answer (for optional questions)
|
var fld = scope.survey_questions[i].variable;
|
||||||
if((scope[fld] || scope[fld] === 0 || scope[fld]==="") && scope.passwords_needed_to_start.indexOf(fld) === -1 && fld !== 'extra_vars'){
|
// grab all survey questions that have answers
|
||||||
|
if(scope[fld]) {
|
||||||
job_launch_data.extra_vars[fld] = scope[fld];
|
job_launch_data.extra_vars[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
|
// for optional text and text-areas, submit a blank string if min length is 0
|
||||||
|
if(scope.survey_questions[i].required === false && (scope.survey_questions[i].type === "text" || scope.survey_questions[i].type === "textarea") && scope.survey_questions[i].min === 0 && scope[fld] ===""){
|
||||||
|
job_launch_data.extra_vars[fld] = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -256,19 +256,19 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
// id = params.id,
|
|
||||||
question = params.question,
|
question = params.question,
|
||||||
index = params.index,
|
index = params.index,
|
||||||
required,
|
required,
|
||||||
element, choices, i, checked,
|
element,
|
||||||
max, min, defaultValue,
|
choices,
|
||||||
|
i,
|
||||||
|
checked,
|
||||||
|
max,
|
||||||
|
min,
|
||||||
|
defaultValue,
|
||||||
|
answers,
|
||||||
html = "";
|
html = "";
|
||||||
|
|
||||||
// if(scope.survey_questions.length>0){
|
|
||||||
// $('#survey-save-button').removeAttr('disabled')
|
|
||||||
// }
|
|
||||||
|
|
||||||
question.index = index;
|
question.index = index;
|
||||||
question.question_name = question.question_name.replace(/</g, "<");
|
question.question_name = question.question_name.replace(/</g, "<");
|
||||||
question.question_name = question.question_name.replace(/>/g, ">");
|
question.question_name = question.question_name.replace(/>/g, ">");
|
||||||
@@ -286,7 +286,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
if(!Empty(question.question_description)){
|
if(!Empty(question.question_description)){
|
||||||
html += '<div class="col-xs-12 description"><i>'+question.question_description+'</i></div>\n';
|
html += '<div class="col-xs-12 description"><i>'+question.question_description+'</i></div>\n';
|
||||||
}
|
}
|
||||||
// defaultValue = (question.default) ? question.default : "";
|
|
||||||
|
|
||||||
if(question.type === 'text' ){
|
if(question.type === 'text' ){
|
||||||
defaultValue = (question.default) ? question.default : "";
|
defaultValue = (question.default) ? question.default : "";
|
||||||
@@ -312,9 +311,10 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
choices = question.choices.split(/\n/);
|
choices = question.choices.split(/\n/);
|
||||||
element = (question.type==="multiselect") ? "checkbox" : 'radio';
|
element = (question.type==="multiselect") ? "checkbox" : 'radio';
|
||||||
question.default = (question.default) ? question.default : (question.default_multiselect) ? question.default_multiselect : "" ;
|
question.default = (question.default) ? question.default : (question.default_multiselect) ? question.default_multiselect : "" ;
|
||||||
|
answers = question.default.split(/\n/);
|
||||||
html += '<div class="input_area">';
|
html += '<div class="input_area">';
|
||||||
for( i = 0; i<choices.length; i++){
|
for( i = 0; i<choices.length; i++){
|
||||||
checked = (!Empty(question.default) && question.default.indexOf(choices[i])!==-1) ? "checked" : "";
|
checked = (!Empty(question.default) && $.inArray(choices[i], answers) !== -1) ? "checked" : "";
|
||||||
choices[i] = choices[i] .replace(/</g, "<");
|
choices[i] = choices[i] .replace(/</g, "<");
|
||||||
choices[i] = choices[i] .replace(/>/g, ">");
|
choices[i] = choices[i] .replace(/>/g, ">");
|
||||||
choices[i] = scope.serialize(choices[i]);
|
choices[i] = scope.serialize(choices[i]);
|
||||||
@@ -364,17 +364,42 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
$('#add_question_btn').focus();
|
$('#add_question_btn').focus();
|
||||||
$('#survey_maker_save_btn').removeAttr('disabled');
|
$('#survey_maker_save_btn').removeAttr('disabled');
|
||||||
|
|
||||||
|
// Sometimes the $event.target returns the anchor element that wraps the icon, and sometimes the icon itself
|
||||||
|
// is returned. So for each icon click event we check to see which target the user clicked, and depending no which one
|
||||||
|
// they clicked, we move up the dom hierarchy to get the index on the question. Ultimatley the object that is passed to
|
||||||
|
// each one of these functions should be the index of the question that the user is trying to perform an action on.
|
||||||
$('#delete-question_'+question.index+'').on('click', function($event){
|
$('#delete-question_'+question.index+'').on('click', function($event){
|
||||||
|
if($event.target.nodeName==="A"){
|
||||||
|
scope.deleteQuestion($event.target.parentElement.parentElement.id.split('_')[1]);
|
||||||
|
}
|
||||||
|
else if($event.target.nodeName === "I"){
|
||||||
scope.deleteQuestion($event.target.parentElement.parentElement.parentElement.id.split('_')[1]);
|
scope.deleteQuestion($event.target.parentElement.parentElement.parentElement.id.split('_')[1]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$('#edit-question_'+question.index+'').on('click', function($event){
|
$('#edit-question_'+question.index+'').on('click', function($event){
|
||||||
|
if($event.target.nodeName==="A"){
|
||||||
|
scope.editQuestion($event.target.parentElement.parentElement.id.split('_')[1]);
|
||||||
|
}
|
||||||
|
else if($event.target.nodeName === "I"){
|
||||||
scope.editQuestion($event.target.parentElement.parentElement.parentElement.id.split('_')[1]);
|
scope.editQuestion($event.target.parentElement.parentElement.parentElement.id.split('_')[1]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$('#question-up_'+question.index+'').on('click', function($event){
|
$('#question-up_'+question.index+'').on('click', function($event){
|
||||||
|
if($event.target.nodeName==="A"){
|
||||||
|
scope.questionUp($event.target.parentElement.parentElement.id.split('_')[1]);
|
||||||
|
}
|
||||||
|
else if($event.target.nodeName === "I"){
|
||||||
scope.questionUp($event.target.parentElement.parentElement.parentElement.id.split('_')[1]);
|
scope.questionUp($event.target.parentElement.parentElement.parentElement.id.split('_')[1]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$('#question-down_'+question.index+'').on('click', function($event){
|
$('#question-down_'+question.index+'').on('click', function($event){
|
||||||
|
if($event.target.nodeName==="A"){
|
||||||
|
scope.questionDown($event.target.parentElement.parentElement.id.split('_')[1]);
|
||||||
|
}
|
||||||
|
else if($event.target.nodeName === "I"){
|
||||||
scope.questionDown($event.target.parentElement.parentElement.parentElement.id.split('_')[1]);
|
scope.questionDown($event.target.parentElement.parentElement.parentElement.id.split('_')[1]);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
@@ -701,6 +726,8 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
};
|
};
|
||||||
|
|
||||||
scope.typeChange = function() {
|
scope.typeChange = function() {
|
||||||
|
scope.minTextError = false;
|
||||||
|
scope.maxTextError = false;
|
||||||
scope.default = "";
|
scope.default = "";
|
||||||
scope.default_multiselect = "";
|
scope.default_multiselect = "";
|
||||||
scope.default_float = "";
|
scope.default_float = "";
|
||||||
@@ -721,13 +748,63 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
scope.survey_question_form.default_int.$setPristine();
|
scope.survey_question_form.default_int.$setPristine();
|
||||||
scope.survey_question_form.default_textarea.$setPristine();
|
scope.survey_question_form.default_textarea.$setPristine();
|
||||||
scope.survey_question_form.choices.$setPristine();
|
scope.survey_question_form.choices.$setPristine();
|
||||||
|
scope.survey_question_form.int_min.$setPristine();
|
||||||
|
scope.survey_question_form.int_max.$setPristine();
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.submitQuestion = function(event){
|
scope.submitQuestion = function(event){
|
||||||
var data = {},
|
var data = {},
|
||||||
fld,
|
fld, i,
|
||||||
|
choiceArray,
|
||||||
|
answerArray,
|
||||||
key, elementID;
|
key, elementID;
|
||||||
Wait('start');
|
// Wait('start');
|
||||||
|
scope.invalidChoice = false;
|
||||||
|
scope.duplicate = false;
|
||||||
|
scope.minTextError = false;
|
||||||
|
scope.maxTextError = false;
|
||||||
|
|
||||||
|
if(scope.type.type==="text"){
|
||||||
|
if(scope.default.trim() !== ""){
|
||||||
|
if(scope.default.trim().length < scope.text_min && scope.text_min !== "" ){
|
||||||
|
scope.minTextError = true;
|
||||||
|
}
|
||||||
|
if(scope.text_max < scope.default.trim().length && scope.text_max !== "" ){
|
||||||
|
scope.maxTextError = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(scope.type.type==="textarea"){
|
||||||
|
if(scope.default_textarea.trim() !== ""){
|
||||||
|
if(scope.default_textarea.trim().length < scope.textarea_min && scope.textarea_min !== "" ){
|
||||||
|
scope.minTextError = true;
|
||||||
|
}
|
||||||
|
if(scope.textarea_max < scope.default_textarea.trim().length && scope.textarea_max !== "" ){
|
||||||
|
scope.maxTextError = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(scope.type.type==="multiselect" && scope.default_multiselect.trim() !== ""){
|
||||||
|
choiceArray = scope.choices.split(/\n/);
|
||||||
|
answerArray = scope.default_multiselect.split(/\n/);
|
||||||
|
|
||||||
|
if(answerArray.length>0){
|
||||||
|
for(i=0; i<answerArray.length; i++){
|
||||||
|
if($.inArray(answerArray[i], choiceArray)===-1){
|
||||||
|
scope.invalidChoice = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(scope.type.type==="multiplechoice" && scope.default.trim() !== ""){
|
||||||
|
choiceArray = scope.choices.split(/\n/);
|
||||||
|
if($.inArray(scope.default, choiceArray)===-1){
|
||||||
|
scope.invalidChoice = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// validate that there aren't any questions using this var name.
|
// validate that there aren't any questions using this var name.
|
||||||
if(GenerateForm.mode === 'add'){
|
if(GenerateForm.mode === 'add'){
|
||||||
@@ -735,8 +812,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
for(fld in questions){
|
for(fld in questions){
|
||||||
if(questions[fld].variable === scope.variable){
|
if(questions[fld].variable === scope.variable){
|
||||||
scope.duplicate = true;
|
scope.duplicate = true;
|
||||||
Wait('stop');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -744,8 +819,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
for(fld in scope.survey_questions){
|
for(fld in scope.survey_questions){
|
||||||
if(scope.survey_questions[fld].variable === scope.variable){
|
if(scope.survey_questions[fld].variable === scope.variable){
|
||||||
scope.duplicate = true;
|
scope.duplicate = true;
|
||||||
Wait('stop');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -757,9 +830,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
for(fld in questions){
|
for(fld in questions){
|
||||||
if(questions[fld].variable === scope.variable && fld!==key){
|
if(questions[fld].variable === scope.variable && fld!==key){
|
||||||
scope.duplicate = true;
|
scope.duplicate = true;
|
||||||
|
|
||||||
Wait('stop');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -767,14 +837,16 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
for(fld in scope.survey_questions){
|
for(fld in scope.survey_questions){
|
||||||
if(scope.survey_questions[fld].variable === scope.variable && fld!==key){
|
if(scope.survey_questions[fld].variable === scope.variable && fld!==key){
|
||||||
scope.duplicate = true;
|
scope.duplicate = true;
|
||||||
Wait('stop');
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(scope.duplicate===true || scope.invalidChoice===true || scope.minTextError === true || scope.maxTextError === true){
|
||||||
|
// Wait('stop');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//create data object for each submitted question
|
//create data object for each submitted question
|
||||||
@@ -875,4 +947,3 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
|
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user