Skip to content

Commit

Permalink
#696 Add a feature that items move up and down
Browse files Browse the repository at this point in the history
  • Loading branch information
koda-masaru committed Apr 8, 2017
1 parent 2a02b40 commit 483eefe
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/main/resources/appresource.properties
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ label.draft=Draft
label.release=Release
label.new=New
label.initialize=Initialize
label.move.up=Move Up
label.move.down=Move Down

label.public.view=<i class="fa fa-globe"></i>&nbsp;[Public]
label.protect.view=<i class="fa fa-gavel"></i>&nbsp;[Protection]
Expand Down Expand Up @@ -796,4 +798,6 @@ knowledge.survey.label.answer.count=Count
knowledge.survey.label.answer.date=DateTime
knowledge.survey.label.answer.user=User
knowledge.survey.msg.survey=Please post first (because you need to assign ID)
knowledge.survey.msg.warning.move=Please do not delete items or move up and down, if there is an answer already.


3 changes: 3 additions & 0 deletions src/main/resources/appresource_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ label.draft=下書き
label.release=投稿する
label.new=新規作成
label.initialize=初期化
label.move.up=上へ移動
label.move.down=下へ移動

label.public.view=<i class="fa fa-globe"></i>&nbsp;[公開]
label.protect.view=<i class="fa fa-gavel"></i>&nbsp;[保護]
Expand Down Expand Up @@ -796,4 +798,5 @@ knowledge.survey.label.answer.count=回答件数
knowledge.survey.label.answer.date=回答日時
knowledge.survey.label.answer.user=回答者
knowledge.survey.msg.survey=先に投稿してください(IDを採番する必要があるため)
knowledge.survey.msg.warning.move=既にアンケートの回答が登録されている場合は、項目の削除、上下の移動をしないでください。

Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ var LABEL_ADD_CHOICE = '<%= jspUtil.label("knowledge.template.label.choice.add")
var LABEL_DELETE_CHOICE = '<%= jspUtil.label("knowledge.template.label.choice.remove") %>';
var LABEL_CHOICE_LABEL = '<%= jspUtil.label("knowledge.template.label.choice.label") %>';
var LABEL_CHOICE_VALUE = '<%= jspUtil.label("knowledge.template.label.choice.value") %>';
var LABEL_MOVE_UP = '<%= jspUtil.label("label.move.up") %>';
var LABEL_MOVE_DOWN = '<%= jspUtil.label("label.move.down") %>';
</script>

6 changes: 6 additions & 0 deletions src/main/webapp/WEB-INF/views/protect/survey/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
<c:param name="PARAM_CONTENT">
<h4 class="title"><%= jspUtil.label("knowledge.survey.label.edit") %></h4>

<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Information</strong><br/>
- <%= jspUtil.label("knowledge.survey.msg.warning.move") %>
</div>

<form action="<%= request.getContextPath()%>/protect.survey/save" method="post" role="form" id="surveyForm">
<input type="hidden" name="<%= HttpRequestCheckLogic.REQ_ID_KEY %>"
value="<%= jspUtil.out(HttpRequestCheckLogic.REQ_ID_KEY) %>" />
Expand Down
34 changes: 30 additions & 4 deletions src/main/webapp/js/template-item-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ $(document).ready(function() {
var s = '#' + itemId;
$(s).remove();
};

var moveupItem = function(itemId) {
var s = '#' + itemId;
var e = $(s);
e.prev().insertAfter(e);

}
var movedownItem = function(itemId) {
var s = '#' + itemId;
var e = $(s);
e.next().insertBefore(e);

}

/**
* 入力項目に対し、選択肢を追加(ラジオやチェックボックスなどの選択項目)
* @param itemid 入力項目のID
Expand Down Expand Up @@ -108,17 +122,23 @@ $(document).ready(function() {
addItem += '<div id="' + itemId + '" class="add_item">';
addItem += '<h5 class="item_title">' + kind + '<input type="hidden" name="itemType" value="' + prefix + '_' + itemId + '"/>';
if (document._TEMPLATE.editable) {
addItem += '<button type="button" class="btn btn-warning" id="deleteItem_' + itemId + '" >';
addItem += '<i class="fa fa-minus-square"></i>&nbsp;' + LABEL_DELETE;
addItem += '</button>&nbsp;';
if (kind === LABEL_RADIO_ITEM || kind === LABEL_CHECKBOX_ITEM) {
addItem += '<button type="button" class="btn btn-success" id="addChoice_' + itemId + '" >';
addItem += '<i class="fa fa-plus-circle"></i>&nbsp;' + LABEL_ADD_CHOICE;
addItem += '</button>&nbsp;';
addItem += '<button type="button" class="btn btn-success" id="deleteChoice_' + itemId + '" >';
addItem += '<i class="fa fa-minus-circle"></i>&nbsp;' + LABEL_DELETE_CHOICE;
addItem += '</button>';
addItem += '</button>&nbsp;';
}
addItem += '<button type="button" class="btn btn-info" id="moveupItem_' + itemId + '" >';
addItem += '<i class="fa fa-arrow-up"></i>&nbsp;' + LABEL_MOVE_UP;
addItem += '</button>&nbsp;';
addItem += '<button type="button" class="btn btn-info" id="movedownItem_' + itemId + '" >';
addItem += '<i class="fa fa-arrow-down"></i>&nbsp;' + LABEL_MOVE_DOWN;
addItem += '</button>&nbsp;';
addItem += '<button type="button" class="btn btn-warning" id="deleteItem_' + itemId + '" >';
addItem += '<i class="fa fa-minus-square"></i>&nbsp;' + LABEL_DELETE;
addItem += '</button>&nbsp;';
}
addItem += '</h5>';
addItem += '<div class="form-group">';
Expand All @@ -143,6 +163,12 @@ $(document).ready(function() {
$('#deleteItem_' + itemId).click(function() {
deleteItem(itemId);
});
$('#moveupItem_' + itemId).click(function() {
moveupItem(itemId);
});
$('#movedownItem_' + itemId).click(function() {
movedownItem(itemId);
});
$('#addChoice_' + itemId).click(function() {
addChoice(itemId);
});
Expand Down

0 comments on commit 483eefe

Please sign in to comment.