Commit 18164fdf by Kim Gyeongeun

#56952 設問設定機能追加(セレクトメニュー動作バグ修正)

parent 702df35c
......@@ -310,6 +310,9 @@ public class QuestionService extends AbstractService<Question> {
copiedQuestion.condRequiredAnswer = answerIdArrayStr.replaceAll(",$", "");
update(copiedQuestion, loginId);
answerIdArrayStr = "";
} else if (copiedQuestion.condRequiredQuestionNo.equals(0) && copiedQuestion.condRequiredAnswer != null) {
copiedQuestion.condRequiredAnswer = null;
update(copiedQuestion, loginId);
}
}
}
......@@ -325,7 +328,7 @@ public class QuestionService extends AbstractService<Question> {
//初期表示情報セット
for (Question question : questionList) {
for (Answer answer : question.answerList) {
if (question.condRequiredQuestionNo != null && question.condRequiredQuestionNo == 0 && requiredQuestionInfo.get(answer.answerId) == null) {
if (question.condRequiredQuestionNo != null /*&& question.condRequiredQuestionNo == 0*/ && requiredQuestionInfo.get(answer.answerId) == null) {
if (answer.defaultFlg == 0 && StringUtil.isBlank(answer.answerIdValue)) {continue;}
//条件付回答設定の選択した値
if (answer.defaultFlg == 0 && StringUtil.isNotBlank(answer.answerIdValue)) {
......@@ -354,9 +357,18 @@ public class QuestionService extends AbstractService<Question> {
question.questionInitDisable = SinaburoConstant.initDisable.YES;
} else {
question.questionInitDisable = SinaburoConstant.initDisable.NO;
return;
break;
}
}
}
}
//グレーアウト処理した項目を初期化
for (Question question : questionList) {
if (question.questionInitDisable == SinaburoConstant.initDisable.YES) {
for (Answer answer : question.answerList) {
answer.answerIdValue = "";
answer.answerValue = "";
}
}
}
}
......
......@@ -28,19 +28,88 @@ $(function() {
#foreach($answer in $question.answerList)
<script language="javascript" type="text/javascript" charset="utf-8">
<!--
function radioOrCheckboxEvent(id, isDisable) {
$("#" + id).trigger("click");
if (isDisable) {
$("#" + id).attr("checked", false);
$("#" + id).attr("disabled", true);
} else {
$("#" + id).attr("disabled", false);
}
}
function dateEvent(id, isDisable) {
if (isDisable) {
$("." + id).val('');
$("." + id).attr("disabled", true);
$("." + id).next().hide();
} else {
$("." + id).attr("disabled", false);
$("." + id).next().show();
}
}
function etcEvent(id, isDisable) {
if (isDisable) {
$("#" + id).val('');
$("#" + id).attr("disabled", true);
} else {
$("#" + id).attr("disabled", false);
}
}
$(function() {
//条件付必須チェック
$("input[type=radio], input[type=checkbox], input[type=select]").click(function () {
//条件付必須チェック(セレクトメニュー)
$('select').change(function() {
var selectQuestionId = $(this).attr("id");
var selectAnswerId = $(this).val();
//表示、非表示対象
if (${question.condRequiredQuestionNo} && ${question.condRequiredQuestionNo} == selectQuestionId) {
//グレーアウト対象
if ("${question.condRequiredAnswer}".split(",").indexOf(selectAnswerId) < 0) {
if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
radioOrCheckboxEvent("${answer.answerId}", true);
} else if ( "${question.controlId}" == "2"
|| "${question.controlId}" == "3"
|| "${question.controlId}" == "4"
|| "${question.controlId}" == "5"
|| "${question.controlId}" == "6") {
if ("${question.controlId}" != "5") {
etcEvent("${question.questionId}", true);
} else {
dateEvent("${question.questionId}", true);
}
}
//グレーアウト解除
} else {
if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
radioOrCheckboxEvent("${answer.answerId}", false);
} else if ("${question.controlId}" == "2"
|| "${question.controlId}" == "3"
|| "${question.controlId}" == "4"
|| "${question.controlId}" == "5"
|| "${question.controlId}" == "6") {
if ("${question.controlId}" != "5") {
etcEvent("${question.questionId}", false);
} else {
dateEvent("${question.questionId}", false);
}
}
}
}
});
//条件付必須チェック(ラジオボタン、チェックボックス)
$("input[type=radio], input[type=checkbox]").click(function () {
var thisQuestionId = $(this).attr("class");
var thisAnswerId = $(this).attr("id");
//表示、非表示対象
if (${question.condRequiredQuestionNo} && ${question.condRequiredQuestionNo} == thisQuestionId) {
//グレーアウト対象
if ("${question.condRequiredAnswer}".split(",").indexOf(thisAnswerId) < 0) {
if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
$("#${answer.answerId}").attr("checked", false);
$("#${answer.answerId}").attr("disabled", true);
} else if ($(this).attr("type") == "radio" && "${question.controlId}" == "2") {
if ($(this).attr("type") == "radio"
&& ("${question.controlId}" == "0" || "${question.controlId}" == "1")) {
if ($(this).is(":checked")) {
radioOrCheckboxEvent("${answer.answerId}", true);
} else {
var array = "${question.condRequiredAnswer}".split(",");
var judgeDisable = true;
for (let i in array) {
......@@ -50,26 +119,48 @@ $(function() {
}
}
if (judgeDisable) {
$("#${question.questionId}").val('');
$("#${question.questionId}").attr("disabled", true);
radioOrCheckboxEvent("${answer.answerId}", true);
}
}
} else if ( "${question.controlId}" == "2"
|| "${question.controlId}" == "3"
|| "${question.controlId}" == "4"
|| "${question.controlId}" == "5"
|| "${question.controlId}" == "6") {
if ("${question.controlId}" == "2") {
$("#${question.questionId}").trigger("change");
}
if ($(this).attr("type") == "radio") {
if ($(this).is(":checked")) {
var array = "${question.condRequiredAnswer}".split(",");
var judgeDisable = true;
for (let i in array) {
if ($("#" + array[i]).is(":checked")) {
judgeDisable = false;
break;
}
}
if (judgeDisable) {
if ("${question.controlId}" != "5") {
etcEvent("${question.questionId}", true);
} else {
$("#${question.questionId}").attr("disabled", false);
dateEvent("${question.questionId}", true);
}
} else if ("${question.controlId}" == "3" || "${question.controlId}" == "4" || "${question.controlId}" == "6") {
$("#${question.questionId}").val('');
$("#${question.questionId}").attr("disabled", true);
} else if ("${question.controlId}" == "5") {
$(".${question.questionId}").val('');
$(".${question.questionId}").attr("disabled", true);
$(".${question.questionId}").next().hide();
}
} else {
if ("${question.controlId}" != "5") {
etcEvent("${question.questionId}", false);
} else {
dateEvent("${question.questionId}", false);
}
}
}
}
//グレーアウト解除
} else {
if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
$("#${answer.answerId}").attr("disabled", false);
} else if ("${question.controlId}" == "2") {
if ($(this).is(":checked")) {
$("#${question.questionId}").attr("disabled", false);
radioOrCheckboxEvent("${answer.answerId}", false);
} else {
var array = "${question.condRequiredAnswer}".split(",");
var judgeDisable = true;
......@@ -80,15 +171,40 @@ $(function() {
}
}
if (judgeDisable) {
$("#${question.questionId}").val('');
$("#${question.questionId}").attr("disabled", true);
radioOrCheckboxEvent("${answer.answerId}", true);
}
}
} else if ("${question.controlId}" == "2"
|| "${question.controlId}" == "3"
|| "${question.controlId}" == "4"
|| "${question.controlId}" == "5"
|| "${question.controlId}" == "6") {
if ("${question.controlId}" == "2") {
$("#${question.questionId}").trigger("change");
}
if ($(this).is(":checked")) {
if ("${question.controlId}" != "5") {
etcEvent("${question.questionId}", false);
} else {
dateEvent("${question.questionId}", false);
}
} else {
var array = "${question.condRequiredAnswer}".split(",");
var judgeDisable = true;
for (let i in array) {
if ($("#" + array[i]).is(":checked")) {
judgeDisable = false;
break;
}
}
if (judgeDisable) {
if ("${question.controlId}" != "5") {
etcEvent("${question.questionId}", true);
} else {
dateEvent("${question.questionId}", true);
}
}
}
} else if ("${question.controlId}" == "3" || "${question.controlId}" == "4" || "${question.controlId}" == "6") {
$("#${question.questionId}").attr("disabled", false);
} else if ("${question.controlId}" == "5") {
$(".${question.questionId}").attr("disabled", false);
$(".${question.questionId}").next().show();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment