diff --git a/js/app/main.js b/js/app/main.js index 9489ba2..d778741 100644 --- a/js/app/main.js +++ b/js/app/main.js @@ -438,6 +438,7 @@ define(['lib/i18n.min!nls/resources.js', 'prepareAppConfigInfo', 'handleUserSign // Provide the i18n strings to the survey survey.flag_important_question = i18n.tooltips.flag_important_question; survey.error_text = i18n.messages.error_text; + survey.domain_error_text = i18n.messages.domain_error_text; diff --git a/js/app/survey.js b/js/app/survey.js index efb7981..fd56f83 100644 --- a/js/app/survey.js +++ b/js/app/survey.js @@ -312,6 +312,22 @@ define([], function () { return surveyQuestions; }, + /** + * Creates a survey form in the specified element. + * @param {object} questionInfo Survey question, which contains question, field, style, domain, important + */ + _checkDomain: function(questionInfo){ + var reqDomain = ["button", "list", "dropdown"]; + if (!isNaN(questionInfo.domain) && (reqDomain.includes(questionInfo.style))){ + return false; + } + else{ + return true; + } + }, + + + /** * Creates a survey form in the specified element. * @param {div} surveyContainer Element containing survey form @@ -323,7 +339,7 @@ define([], function () { _addQuestion: function (surveyContainer, iQuestion, questionInfo, isReadOnly) { var question = survey._startQuestion(iQuestion, questionInfo); //Question Object Needs to exist in order for HTML element to be created - if (questionInfo){ + if (questionInfo && survey._checkDomain(questionInfo)){ //Create parent flags if question type is parent (domain value 0) var primeQFlag = questionInfo.questionType === 0 ? "prime" : " contingent"; primeQFlag = questionInfo.style === "dropdown" ? "primeD" : primeQFlag; @@ -384,17 +400,25 @@ define([], function () { //Check for question info object if (questionInfo){ - // Determine whether to show question on first load. Applies to questions with no parents - var initDisplay = !questionInfo.parent ? "" : " style='display: none;'"; - var start = - "
" - + "
"; - if (questionInfo.image && questionInfo.image.length > 0 && questionInfo.imagepos === "Before") { - start += "
"; + //Check to see if button, list, and dropdown questions have a domain set + var reqDomain = ["button", "list", "dropdown"]; + if (!survey._checkDomain(questionInfo)){ + var start = "
" + + survey.domain_error_text.replace("${0}", iQuestion) +"
" + } + else{ + // Determine whether to show question on first load. Applies to questions with no parents + var initDisplay = !questionInfo.parent ? "" : " style='display: none;'"; + var start = + "
" + + "
"; + if (questionInfo.image && questionInfo.image.length > 0 && questionInfo.imagepos === "Before") { + start += "
"; + } } } //If object is not defined or null then display it with error text diff --git a/nls/resources.js b/nls/resources.js index 6b9d775..c1af965 100644 --- a/nls/resources.js +++ b/nls/resources.js @@ -53,7 +53,8 @@ define({ guestLabel: "Guest" }, messages: { - error_text: "Question ${0} Error displaying question, please check that field name from survey question table matches the photo points feature service" + error_text: "Question ${0} Error displaying question, please check that field name from survey question table matches the photo points feature service", + domain_error_text: "Question ${0} Error displaying question. Button, list, and dropdown style questions require that the associated field has a domain." } }), "ar": 0,