Commit d0bbfdf4 by Kim Gyeongeun

#56952 設問設定機能追加

parent 16e32420
...@@ -9,6 +9,17 @@ import java.util.List; ...@@ -9,6 +9,17 @@ import java.util.List;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.TokenProcessor;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
import org.seasar.struts.util.RequestUtil;
import jp.agentec.sinaburocast.action.AbstractAction; import jp.agentec.sinaburocast.action.AbstractAction;
import jp.agentec.sinaburocast.action.admin.enquete.EnqueteRegistAction; import jp.agentec.sinaburocast.action.admin.enquete.EnqueteRegistAction;
import jp.agentec.sinaburocast.action.batch.EnqueteSumBatchAction; import jp.agentec.sinaburocast.action.batch.EnqueteSumBatchAction;
...@@ -41,17 +52,6 @@ import jp.agentec.sinaburocast.service.ReplyService; ...@@ -41,17 +52,6 @@ import jp.agentec.sinaburocast.service.ReplyService;
import jp.agentec.sinaburocast.service.TemplateService; import jp.agentec.sinaburocast.service.TemplateService;
import jp.agentec.sinaburocast.vo.EnqueteKey; import jp.agentec.sinaburocast.vo.EnqueteKey;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.TokenProcessor;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
import org.seasar.struts.util.RequestUtil;
/** /**
* アンケート処理 * アンケート処理
* *
...@@ -193,12 +193,13 @@ public class EnqueteAction extends AbstractAction { ...@@ -193,12 +193,13 @@ public class EnqueteAction extends AbstractAction {
} }
} }
ArrayList<Question> questionList = questionService.findAllOrderByEnqueteId(enqueteForm.eid); ArrayList<Question> questionList = questionService.findAllOrderByEnqueteId(enqueteForm.eid);
for (Question question : questionList) { for (Question question : questionList) {
if(StringUtil.equals("6", question.controlId+"") ){ if(StringUtil.equals("6", question.controlId+"") ){
enqueteForm.organizationListFor1Percent = organizationService.findAllOrderByNo(); enqueteForm.organizationListFor1Percent = organizationService.findAllOrderByNo();
} }
} }
//条件付必須チェック(初期画面表示・非表示セット)
questionService.setQuestionDisable(questionList);
//予約語を変更する。 //予約語を変更する。
if(enquete.enqueteType ==SinaburoConstant.EnqueteType.PUBLIC_COMMENT if(enquete.enqueteType ==SinaburoConstant.EnqueteType.PUBLIC_COMMENT
......
...@@ -645,6 +645,10 @@ public interface SinaburoConstant { ...@@ -645,6 +645,10 @@ public interface SinaburoConstant {
String MEMBER_CARD_RECEIPT_HIDE_DATE = "2023/09/11"; String MEMBER_CARD_RECEIPT_HIDE_DATE = "2023/09/11";
} }
interface initDisable {
short YES = 1;
short NO = 0;
}
} }
...@@ -14,6 +14,8 @@ import javax.persistence.Transient; ...@@ -14,6 +14,8 @@ import javax.persistence.Transient;
import org.apache.commons.lang.builder.StandardToStringStyle; import org.apache.commons.lang.builder.StandardToStringStyle;
import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringBuilder;
import jp.agentec.sinaburocast.common.SinaburoConstant;
@Entity @Entity
@Table(name="m_answer") @Table(name="m_answer")
public class Answer extends AbstractEntity { public class Answer extends AbstractEntity {
...@@ -55,6 +57,9 @@ public class Answer extends AbstractEntity { ...@@ -55,6 +57,9 @@ public class Answer extends AbstractEntity {
@Column(name = "default_flg") @Column(name = "default_flg")
public int defaultFlg; public int defaultFlg;
@Transient
public short answerInitDisable = SinaburoConstant.initDisable.NO;
/** MEnquete関連プロパティ */ /** MEnquete関連プロパティ */
@ManyToOne @ManyToOne
@JoinColumn(name = "enquete_id", referencedColumnName = "enquete_id") @JoinColumn(name = "enquete_id", referencedColumnName = "enquete_id")
......
...@@ -4,7 +4,6 @@ import java.util.List; ...@@ -4,7 +4,6 @@ import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -14,6 +13,8 @@ import javax.persistence.Transient; ...@@ -14,6 +13,8 @@ import javax.persistence.Transient;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import jp.agentec.sinaburocast.common.SinaburoConstant;
@Entity @Entity
@Table(name="m_question") @Table(name="m_question")
public class Question extends AbstractEntity { public class Question extends AbstractEntity {
...@@ -117,6 +118,9 @@ public class Question extends AbstractEntity { ...@@ -117,6 +118,9 @@ public class Question extends AbstractEntity {
@Transient @Transient
public Integer answerCount; public Integer answerCount;
@Transient
public short questionInitDisable = SinaburoConstant.initDisable.NO;
public String getYearRange() { public String getYearRange() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (StringUtils.isEmpty(startymd)) { if (StringUtils.isEmpty(startymd)) {
......
package jp.agentec.sinaburocast.service; package jp.agentec.sinaburocast.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.seasar.extension.jdbc.where.SimpleWhere; import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.container.annotation.tiger.Component; import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType; import org.seasar.framework.container.annotation.tiger.InstanceType;
import org.seasar.framework.util.IntegerConversionUtil;
import jp.agentec.sinaburocast.common.SinaburoConstant; import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.entity.AdminUser; import jp.agentec.sinaburocast.entity.AdminUser;
...@@ -286,7 +290,40 @@ public class QuestionService extends AbstractService<Question> { ...@@ -286,7 +290,40 @@ public class QuestionService extends AbstractService<Question> {
} }
} }
} }
/**
* 条件付必須チェック(初期画面表示・非表示セット)
*
* @param questionList
* @return
*/
public void setQuestionDisable(List<Question> questionList) {
HashMap<Integer, Integer> requiredQuestionInfo = new HashMap<Integer, Integer>();
//初期表示情報セット
for (Question question : questionList) {
for (Answer answer : question.answerList) {
if (question.condRequiredQuestionNo != null && question.condRequiredQuestionNo == 0
&& answer.defaultFlg == 1 && requiredQuestionInfo.get(answer.answerId) == null) {
requiredQuestionInfo.put(answer.answerId, answer.defaultFlg);
}
}
}
for (Question question : questionList) {
//条件付必須チェック(初期画面表示・非表示セット)
for (Answer answer : question.answerList) {
if (question.condRequiredQuestionNo != null && question.condRequiredQuestionNo != 0
&& StringUtils.isNotBlank(question.condRequiredAnswer)) {
List<String> requiredAnswerIdList = new ArrayList<String>(Arrays.asList(question.condRequiredAnswer.split(",")));
for (String requiredAnswerId : requiredAnswerIdList) {
if (requiredQuestionInfo.get(IntegerConversionUtil.toInteger(requiredAnswerId)) == null) {
question.questionInitDisable = SinaburoConstant.initDisable.YES;
answer.answerInitDisable = SinaburoConstant.initDisable.YES;
break;
}
}
}
}
}
}
/** /**
......
...@@ -9,22 +9,57 @@ ...@@ -9,22 +9,57 @@
#set($dateIndex=0) #set($dateIndex=0)
#foreach($question in $!enqueteForm.questionList) #foreach($question in $!enqueteForm.questionList)
<script language="javascript" type="text/javascript" charset="utf-8">
console.log("${question.questionId}");
console.log("${question.condRequiredQuestionNo}");
console.log("${question.condRequiredAnswer}");
</script>
#if($question.controlId == 5) #if($question.controlId == 5)
#set($dateIndex = $dateIndex+1) #set($dateIndex = $dateIndex+1)
<script language="javascript" type="text/javascript" charset="utf-8"> <script language="javascript" type="text/javascript" charset="utf-8">
<!-- <!--
$(function() {
//開始日 //開始日
$(function() {
$("#enqStartFrom${dateIndex}").datepick({showTrigger: "#enqFrom${dateIndex}", $("#enqStartFrom${dateIndex}").datepick({showTrigger: "#enqFrom${dateIndex}",
yearRange: "$question.yearRange", yearRange: "$question.yearRange",
minDate: "$question.startymd", minDate: "$question.startymd",
maxDate: "$question.endymd"}); maxDate: "$question.endymd"});
});
//-->
</script>
#end
#end
#foreach($question in $!enqueteForm.questionList)
#foreach($answer in $question.answerList)
<script language="javascript" type="text/javascript" charset="utf-8">
<!--
$(function() {
//条件付必須チェック
$("input[type=radio], input[type=checkbox], input[type=select]").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 ("${question.controlId}" == "2" || "${question.controlId}" == "3" || "${question.controlId}" == "4") {
$("#${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}" == "0" || "${question.controlId}" == "1") {
$("#${answer.answerId}").attr("disabled", false);
} else if ("${question.controlId}" == "2" || "${question.controlId}" == "3" || "${question.controlId}" == "4") {
$("#${question.questionId}").attr("disabled", false);
} else if ("${question.controlId}" == "5") {
$(".${question.questionId}").attr("disabled", false);
$(".${question.questionId}").next().show();
}
}
}
}); });
});
// --> // -->
</script> </script>
#end #end
...@@ -187,7 +222,7 @@ $tools.getMsg("errorheader") ...@@ -187,7 +222,7 @@ $tools.getMsg("errorheader")
#if($!question.controlId == "2") #if($!question.controlId == "2")
<td width="$tdWidthPercent%" valign = "top" > <td width="$tdWidthPercent%" valign = "top" >
#set($answerIdValueName = "questionList[$questionIndex].answerList[0].answerIdValue") #set($answerIdValueName = "questionList[$questionIndex].answerList[0].answerIdValue")
<select name="$answerIdValueName" #if($!question.condRequiredQuestionNo != "0") disabled="disabled" #end> <select name="$answerIdValueName" id="#he($!question.questionId)" #if($!question.questionInitDisable == "1") disabled #end>
#foreach($selectAnswer in $question.answerList) #foreach($selectAnswer in $question.answerList)
<option value="$!selectAnswer.answerId" #if($enqueteForm.initCount =="2" && $!selectAnswer.answerId == $!selectAnswer.answerIdValue) selected #elseif($!selectAnswer.defaultFlg == "1" && $enqueteForm.initCount!="2") selected #end >$!escape.html($!selectAnswer.answer)</option> <option value="$!selectAnswer.answerId" #if($enqueteForm.initCount =="2" && $!selectAnswer.answerId == $!selectAnswer.answerIdValue) selected #elseif($!selectAnswer.defaultFlg == "1" && $enqueteForm.initCount!="2") selected #end >$!escape.html($!selectAnswer.answer)</option>
<!-- <option value="$!selectAnswer.answerId" #if($enqueteForm.initCount =="2" && $!selectAnswer.answerId == $!selectAnswer.answerIdValue) selected $!selectAnswer.answerId , $!selectAnswer.answerIdValue #elseif($!selectAnswer.defaultFlg == "1" ) selected $!selectAnswer.answerId , $!selectAnswer.answerIdValue #end >$!escape.html($!selectAnswer.answer)</option> --> <!-- <option value="$!selectAnswer.answerId" #if($enqueteForm.initCount =="2" && $!selectAnswer.answerId == $!selectAnswer.answerIdValue) selected $!selectAnswer.answerId , $!selectAnswer.answerIdValue #elseif($!selectAnswer.defaultFlg == "1" ) selected $!selectAnswer.answerId , $!selectAnswer.answerIdValue #end >$!escape.html($!selectAnswer.answer)</option> -->
...@@ -217,41 +252,39 @@ $tools.getMsg("errorheader") ...@@ -217,41 +252,39 @@ $tools.getMsg("errorheader")
<!-- 0:RADIO インデクスを値にする。 --> <!-- 0:RADIO インデクスを値にする。 -->
#if($!question.controlId == "0") #if($!question.controlId == "0")
##if($!answer.freeTextFlg != "1" && $!answer.freeTextFlg != "2") ##if($!answer.freeTextFlg != "1" && $!answer.freeTextFlg != "2")
<input type="radio" name="$!answerIdValueRadioName" value="$velocityCount" #if($!answer.answerIdValue == $velocityCount.toString() && $enqueteForm.initCount =="2") checked #{end} <input type="radio" class="#he($!question.questionId)" id="#he($!answer.answerId)" name="$!answerIdValueRadioName" value="$velocityCount" #if($!answer.answerIdValue == $velocityCount.toString() && $enqueteForm.initCount =="2") checked #end
#if($!answer.defaultFlg == 1 && $enqueteForm.initCount =="1") checked #end #if($!answer.defaultFlg == 1 && $enqueteForm.initCount =="1") checked #end #if($!answer.answerInitDisable == "1") disabled #end> $!escape.html($!answer.answer)
#if($!question.condRequiredQuestionNo != "0") disabled="disabled" #end> $!escape.html($!answer.answer)
##end ##end
##<!-- 自由入力欄。freeTextFlg=1(あり)、2(必須) --> ##<!-- 自由入力欄。freeTextFlg=1(あり)、2(必須) -->
#if($!answer.freeTextFlg == "1" || $!answer.freeTextFlg == "2") #if($!answer.freeTextFlg == "1" || $!answer.freeTextFlg == "2")
<input type="text" name="$answerValue" size="$!answer.freeTextColWidth" value="$!escape.html($!answer.answerValue)" /> <input type="text" class="#he($!question.questionId)" id="#he($!answer.answerId)" name="$answerValue" size="$!answer.freeTextColWidth" value="$!escape.html($!answer.answerValue)" />
#end #end
##<!-- 1:CHECKBOX answer.answerNo値を値にする。--> ##<!-- 1:CHECKBOX answer.answerNo値を値にする。-->
#elseif($!question.controlId == "1") #elseif($!question.controlId == "1")
##if($!answer.freeTextFlg != "1" && $!answer.freeTextFlg != "2") ##if($!answer.freeTextFlg != "1" && $!answer.freeTextFlg != "2")
<input type="checkbox" name="$answerIdValueName" value="$!escape.html($!answer.answerNo)" #if($answer.answerIdValue != "" && $enqueteForm.initCount =="2") checked #end <input type="checkbox" class="#he($!question.questionId)" id="#he($!answer.answerId)" name="$answerIdValueName" value="$!escape.html($!answer.answerNo)" #if($answer.answerIdValue != "" && $enqueteForm.initCount =="2") checked #end
#if($!answer.defaultFlg == 1 && $enqueteForm.initCount =="1") checked #end #if($!answer.defaultFlg == 1 && $enqueteForm.initCount =="1") checked #end #if($!answer.answerInitDisable == "1") disabled #end> $!escape.html($!answer.answer)
#if($!question.condRequiredQuestionNo != "0") disabled="disabled" #end> $!escape.html($!answer.answer)
##end ##end
##<!-- 自由入力欄。freeTextFlg=1(あり)、2(必須) --> ##<!-- 自由入力欄。freeTextFlg=1(あり)、2(必須) -->
#if($!answer.freeTextFlg == "1" || $!answer.freeTextFlg == "2") #if($!answer.freeTextFlg == "1" || $!answer.freeTextFlg == "2")
<input type="text" name="$answerValue" size="$!answer.freeTextColWidth" value="$!escape.html($!answer.answerValue)"/> <input type="text" class="#he($!question.questionId)" id="#he($!answer.answerId)" name="$answerValue" size="$!answer.freeTextColWidth" value="$!escape.html($!answer.answerValue)" #if($!question.questionInitDisable == "1") disabled #end/>
#end #end
##<!-- 3:TEXTAREA ユーザー入力値を値にする。--> ##<!-- 3:TEXTAREA ユーザー入力値を値にする。-->
#elseif($!question.controlId == "3") #elseif($!question.controlId == "3")
<textArea type="text" name="$answerIdValueName" cols="$!question.dispWitdth" rows="$!question.rowCount">$!answer.answerIdValue</textarea> <textArea type="text" id="#he($!question.questionId)" name="$answerIdValueName" cols="$!question.dispWitdth" rows="$!question.rowCount" #if($!question.questionInitDisable == "1") disabled #end>$!answer.answerIdValue</textarea>
##<!-- 4:TEXTFIELD ユーザー入力値を値にする。--> ##<!-- 4:TEXTFIELD ユーザー入力値を値にする。-->
#elseif($!question.controlId == "4") #elseif($!question.controlId == "4")
<input type="text" name="$answerIdValueName" value="$!escape.html($!answer.answerIdValue)" size="$!question.dispWitdth"/> <input type="text" id="#he($!question.questionId)" name="$answerIdValueName" value="$!escape.html($!answer.answerIdValue)" size="$!question.dispWitdth" #if($!question.questionInitDisable == "1") disabled #end />
##<!-- 5:日付入力 ユーザー入力値を値にする。--> ##<!-- 5:日付入力 ユーザー入力値を値にする。-->
#elseif($!question.controlId == "5") #elseif($!question.controlId == "5")
#set($dateIndex = $dateIndex+1) #set($dateIndex = $dateIndex+1)
<input name="$answerValue" id="enqStartFrom${dateIndex}" type="text" class="w100 mgl10" value="$!escape.html($!answer.answerValue)" > <input name="$answerValue" id="enqStartFrom${dateIndex}" type="text" class="w100 mgl10 #he($!question.questionId)" value="$!escape.html($!answer.answerValue)" #if($!question.questionInitDisable == "1") disabled #end>
<div style="display: none;"><img id="enqFrom${dateIndex}" src="/em/images/icon_cal.gif" style="padding-left:5px;padding-right:5px; vertical-align: middle;"></div> <div style="display: none;"><img id="enqFrom${dateIndex}" src="/em/images/icon_cal.gif" style="padding-left:5px;padding-right:5px; vertical-align: middle; #if($!question.questionInitDisable == '1') display: none; #end" ></div>
<input type="hidden" name="$answerIdValueName" value="$!answer.answerId" /> <input type="hidden" name="$answerIdValueName" value="$!answer.answerId" />
#elseif($!question.controlId == "6") #elseif($!question.controlId == "6")
<select name="$answerIdValueName"> <select name="$answerIdValueName" id="#he($!question.questionId)" #if($!question.questionInitDisable == "1") disabled #end>
<option value="" >下記より選択してください</option> <option value="" >下記より選択してください</option>
#foreach($pecent1 in $enqueteForm.organizationListFor1Percent) #foreach($pecent1 in $enqueteForm.organizationListFor1Percent)
<option value="$!pecent1.organizationId" #if($!answer.answerIdValue == $!pecent1.organizationId) selected #end>$!{pecent1.organizationNo} : $!escape.html($!{pecent1.organizationName})</option> <option value="$!pecent1.organizationId" #if($!answer.answerIdValue == $!pecent1.organizationId) selected #end>$!{pecent1.organizationNo} : $!escape.html($!{pecent1.organizationName})</option>
......
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