From 0fa9e762c73c1932b340d136c7e74b2a65ddd8e7 Mon Sep 17 00:00:00 2001 From: koda Date: Wed, 25 Nov 2015 15:29:43 +0900 Subject: [PATCH 01/12] =?UTF-8?q?#136=20=E9=80=9A=E7=9F=A5=E3=83=A1?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=81=AB=E6=9B=B4=E6=96=B0=E8=80=85=E5=90=8D?= =?UTF-8?q?=E3=82=92=E8=A8=98=E8=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/support/project/knowledge/bat/NotifyMailBat.java | 1 + .../support/project/knowledge/mail/notify_insert_knowledge.xml | 2 ++ .../project/knowledge/mail/notify_insert_knowledge_ja.xml | 2 ++ .../support/project/knowledge/mail/notify_update_knowledge.xml | 2 ++ .../project/knowledge/mail/notify_update_knowledge_ja.xml | 2 ++ 5 files changed, 9 insertions(+) diff --git a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java index 01a44262f..6b66d9b16 100644 --- a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java +++ b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java @@ -469,6 +469,7 @@ private void insertNotifyKnowledgeUpdateMailQue(KnowledgesEntity knowledge, User String contents = config.getContents(); contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); + contents = contents.replace("{User}", knowledge.getUpdateUserName()); contents = contents.replace("{Contents}", knowledge.getContent()); contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml index 385b1e013..27137cd4c 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml @@ -10,6 +10,8 @@ Knowledge has been inserted:{KnowledgeId} ------------------------------------------ {KnowledgeTitle} +{User} + {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge_ja.xml index 160353a5c..50d5ffa49 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge_ja.xml @@ -10,6 +10,8 @@ ------------------------------------------ {KnowledgeTitle} +{User} + {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge.xml b/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge.xml index 89a6817e4..5e57a8ac3 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge.xml @@ -10,6 +10,8 @@ Knowledge has been updated:{KnowledgeId} ------------------------------------------ {KnowledgeTitle} +{User} + {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge_ja.xml index 432fc70f4..2558eaa24 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge_ja.xml @@ -10,6 +10,8 @@ ------------------------------------------ {KnowledgeTitle} +{User} + {Contents} ------------------------------------------ From 227783fa3a96bc61ca855d29681cde1d4d11212d Mon Sep 17 00:00:00 2001 From: koda Date: Thu, 26 Nov 2015 03:22:28 +0900 Subject: [PATCH 02/12] =?UTF-8?q?#136=20=E3=83=A1=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/support/project/knowledge/bat/NotifyMailBat.java | 2 +- .../project/knowledge/mail/notify_insert_knowledge.xml | 5 +++-- .../project/knowledge/mail/notify_insert_knowledge_ja.xml | 5 +++-- .../project/knowledge/mail/notify_update_knowledge.xml | 5 +++-- .../project/knowledge/mail/notify_update_knowledge_ja.xml | 5 +++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java index 6b66d9b16..53001da12 100644 --- a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java +++ b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java @@ -321,7 +321,7 @@ private void sendCommentMail(CommentsEntity comment, KnowledgesEntity knowledge, private void notifyKnowledgeUpdate(NotifyQueuesEntity notifyQueuesEntity) { // ナレッジが登録/更新された KnowledgesDao knowledgesDao = KnowledgesDao.get(); - KnowledgesEntity knowledge = knowledgesDao.selectOnKey(notifyQueuesEntity.getId()); + KnowledgesEntity knowledge = knowledgesDao.selectOnKeyWithUserName(notifyQueuesEntity.getId()); if (null == knowledge) { LOG.warn("Knowledge record not found. id: " + notifyQueuesEntity.getId()); return; diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml index 27137cd4c..1ca6d4aa9 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml @@ -8,9 +8,10 @@ Knowledge has been inserted:{KnowledgeId} {URL} ------------------------------------------ -{KnowledgeTitle} +User: {User} +Title: {KnowledgeTitle} -{User} +------------------------------------------ {Contents} diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge_ja.xml index 50d5ffa49..7f63ed698 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge_ja.xml @@ -8,9 +8,10 @@ {URL} ------------------------------------------ -{KnowledgeTitle} +User: {User} +Title: {KnowledgeTitle} -{User} +------------------------------------------ {Contents} diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge.xml b/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge.xml index 5e57a8ac3..aaba2c9c8 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge.xml @@ -8,9 +8,10 @@ Knowledge has been updated:{KnowledgeId} {URL} ------------------------------------------ -{KnowledgeTitle} +User: {User} +Title: {KnowledgeTitle} -{User} +------------------------------------------ {Contents} diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge_ja.xml index 2558eaa24..7e998047c 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_update_knowledge_ja.xml @@ -8,9 +8,10 @@ {URL} ------------------------------------------ -{KnowledgeTitle} +User: {User} +Title: {KnowledgeTitle} -{User} +------------------------------------------ {Contents} From 4e8526d72b40ac2a0ff41816e9373659841cd1df Mon Sep 17 00:00:00 2001 From: koda Date: Thu, 26 Nov 2015 03:52:47 +0900 Subject: [PATCH 03/12] =?UTF-8?q?#164=20Cookie=E3=81=AE=E5=8C=BA=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=96=87=E5=AD=97=E3=82=92","=E3=81=8B=E3=82=89?= =?UTF-8?q?=E3=80=81"-"=E3=81=AB=E5=A4=89=E6=9B=B4=20=E5=90=8C=E6=99=82?= =?UTF-8?q?=E3=81=AB=E5=BF=B5=E3=81=AE=E3=81=9F=E3=82=81URLEncode=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/open/KnowledgeControl.java | 118 ++++++++++-------- 1 file changed, 67 insertions(+), 51 deletions(-) diff --git a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java index ea7fb66ea..013fb2bbb 100644 --- a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java @@ -1,5 +1,8 @@ package org.support.project.knowledge.control.open; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -62,6 +65,8 @@ public class KnowledgeControl extends KnowledgeControlBase { public static final int FAV_PAGE_LIMIT = 10; public static final int COOKIE_AGE = 60 * 60 * 24 * 31; + private static final String COOKIE_SEPARATOR = "-"; + /** * ナレッジを表示 * @return @@ -78,37 +83,45 @@ public Boundary view() throws InvalidParamException, ParseException { KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); // 今見たナレッジの情報をCookieに保存 - // TODO セッションのデータを操作 - List ids = new ArrayList(); - ids.add(String.valueOf(knowledgeId)); - Cookie[] cookies = getRequest().getCookies(); - if (cookies != null) { - for (Cookie cookie : cookies) { - if (cookie.getName().equals("KNOWLEDGE_HISTORY")) { - String history = cookie.getValue(); - if (history.indexOf(",") != -1) { - String[] historyIds = history.split(","); - //for (int i = historyIds.length - 1; i >= 0; i--) { - for (int i = 0; i < historyIds.length; i++) { - if (!ids.contains(historyIds[i])) { - ids.add(historyIds[i]); + try { + List ids = new ArrayList(); + ids.add(String.valueOf(knowledgeId)); + Cookie[] cookies = getRequest().getCookies(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookie.getName().equals("KNOWLEDGE_HISTORY")) { + String history = cookie.getValue(); + if (history.indexOf(",") != -1) { + history = ""; // カンマ区切りにしていた場合、その値をクリア + } + history = URLDecoder.decode(history, "UTF-8"); + if (history.indexOf(COOKIE_SEPARATOR) != -1) { + String[] historyIds = history.split(COOKIE_SEPARATOR); + for (int i = 0; i < historyIds.length; i++) { + if (!ids.contains(historyIds[i]) && StringUtils.isLong(historyIds[i])) { + ids.add(historyIds[i]); + } + if (ids.size() >= COOKIE_COUNT) { + break; + } } - if (ids.size() >= COOKIE_COUNT) { - break; + } else { + if (!ids.contains(history)) { + ids.add(history); } } - } else { - if (!ids.contains(history)) { - ids.add(history); - } + break; } } + String cookieHistory = String.join(COOKIE_SEPARATOR, ids); + cookieHistory = URLEncoder.encode(cookieHistory, "UTF-8"); + Cookie cookie = new Cookie("KNOWLEDGE_HISTORY", cookieHistory); + cookie.setPath(getRequest().getContextPath()); + cookie.setMaxAge(COOKIE_AGE); + getResponse().addCookie(cookie); } - String cookieHistory = String.join(",", ids); - Cookie cookie = new Cookie("KNOWLEDGE_HISTORY", cookieHistory); - cookie.setPath(getRequest().getContextPath()); - cookie.setMaxAge(COOKIE_AGE); - getResponse().addCookie(cookie); + } catch (UnsupportedEncodingException e) { + LOG.error("Cokkie error.", e); } KnowledgesEntity entity = knowledgeLogic.selectWithTags(knowledgeId, getLoginedUser()); @@ -336,37 +349,40 @@ public Boundary list() throws Exception { // History表示 // TODO 履歴表示を毎回取得するのはイマイチ。いったんセッションに保存しておくのが良いかも - Cookie[] cookies = getRequest().getCookies(); - List historyIds = new ArrayList<>(); - if (cookies != null) { - for (Cookie cookie : cookies) { - if (cookie.getName().equals("KNOWLEDGE_HISTORY")) { - String history = cookie.getValue(); - LOG.debug("history: " + history); - if (history.indexOf(",") != -1) { - String[] splits = history.split(","); - for (String string : splits) { - historyIds.add(string); + try { + Cookie[] cookies = getRequest().getCookies(); + List historyIds = new ArrayList<>(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookie.getName().equals("KNOWLEDGE_HISTORY")) { + String history = cookie.getValue(); + if (history.indexOf(",") != -1) { + history = ""; // カンマ区切りにしていた場合、その値をクリア } - } else { - historyIds.add(history); + history = URLDecoder.decode(history, "UTF-8"); + LOG.debug("history: " + history); + if (history.indexOf(COOKIE_SEPARATOR) != -1) { + String[] splits = history.split(COOKIE_SEPARATOR); + for (String string : splits) { + if (StringUtils.isLong(string)) { + historyIds.add(string); + } + } + } else { + if (StringUtils.isLong(history)) { + historyIds.add(history); + } + } + break; } } } + List histories = knowledgeLogic.getKnowledges(historyIds, loginedUser); + LOG.trace("履歴取得完了"); + setAttribute("histories", histories); + } catch (UnsupportedEncodingException e) { + LOG.error("Cokkie error.", e); } - List histories = knowledgeLogic.getKnowledges(historyIds, loginedUser); - LOG.trace("履歴取得完了"); -// for (KnowledgesEntity knowledgesEntity : histories) { -// LOG.trace(" 文字数チェック"); -// knowledgesEntity.setContent(org.apache.commons.lang.StringUtils.abbreviate( -// knowledgesEntity.getContent(), 40)); -// LOG.trace(" 文字数チェック終了"); -// LOG.trace(" Samy"); -// knowledgesEntity.setContent(doSamy(knowledgesEntity.getContent())); -// LOG.trace(" Samy終了"); -// } - setAttribute("histories", histories); - LOG.trace("履歴表示修正"); setAttribute("offset", offset); setAttribute("previous", previous); From b41eccb553dc2fea47b5e5430ac1410822adbc04 Mon Sep 17 00:00:00 2001 From: koda Date: Thu, 26 Nov 2015 03:53:09 +0900 Subject: [PATCH 04/12] =?UTF-8?q?#164=20=E4=B8=80=E8=A6=A7=E3=81=AB?= =?UTF-8?q?=E6=9C=AC=E6=96=87=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=80=81=E9=96=B2=E8=A6=A7=E5=B1=A5=E6=AD=B4=E3=82=82?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB=E3=81=A0=E3=81=91=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/WEB-INF/views/open/knowledge/list.jsp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp index bf92c1a11..8c5d469fa 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp @@ -249,9 +249,11 @@ class="list-group-item">
  [<%= jspUtil.out("history.knowledgeId") %>] <%= jspUtil.out("history.title") %>
+ <%-- 一覧に本文を表示しないようにしたため、閲覧履歴もタイトルだけにする

<%= jspUtil.out("history.content", 0, 40) %>

+ --%> From 85a096a9aa22ef176b31b6f73da85b4a5df250b6 Mon Sep 17 00:00:00 2001 From: koda Date: Sat, 28 Nov 2015 01:34:46 +0900 Subject: [PATCH 05/12] =?UTF-8?q?#164=20=E6=97=A7=E9=96=B2=E8=A6=A7?= =?UTF-8?q?=E5=B1=A5=E6=AD=B4=E6=83=85=E5=A0=B1=E3=81=8C=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=80=81=E3=82=AF=E3=83=AA?= =?UTF-8?q?=E3=82=A2=E3=81=99=E3=82=8B=E3=81=AE=E3=81=A7=E3=81=AF=E7=84=A1?= =?UTF-8?q?=E3=81=8F=E3=80=81=E5=A4=89=E6=8F=9B=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../knowledge/control/open/KnowledgeControl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java index 013fb2bbb..fe72aa785 100644 --- a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java @@ -92,9 +92,10 @@ public Boundary view() throws InvalidParamException, ParseException { if (cookie.getName().equals("KNOWLEDGE_HISTORY")) { String history = cookie.getValue(); if (history.indexOf(",") != -1) { - history = ""; // カンマ区切りにしていた場合、その値をクリア + history = history.replaceAll(",", "-"); // 旧閲覧履歴情報が存在すれば、変換する + } else { + history = URLDecoder.decode(history, "UTF-8"); } - history = URLDecoder.decode(history, "UTF-8"); if (history.indexOf(COOKIE_SEPARATOR) != -1) { String[] historyIds = history.split(COOKIE_SEPARATOR); for (int i = 0; i < historyIds.length; i++) { @@ -357,9 +358,10 @@ public Boundary list() throws Exception { if (cookie.getName().equals("KNOWLEDGE_HISTORY")) { String history = cookie.getValue(); if (history.indexOf(",") != -1) { - history = ""; // カンマ区切りにしていた場合、その値をクリア + history = history.replaceAll(",", "-"); + } else { + history = URLDecoder.decode(history, "UTF-8"); } - history = URLDecoder.decode(history, "UTF-8"); LOG.debug("history: " + history); if (history.indexOf(COOKIE_SEPARATOR) != -1) { String[] splits = history.split(COOKIE_SEPARATOR); From 220f0018ee200d9d76ed8507c76c558090cc7695 Mon Sep 17 00:00:00 2001 From: koda Date: Sat, 28 Nov 2015 01:45:37 +0900 Subject: [PATCH 06/12] =?UTF-8?q?#164=20=E3=82=B3=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=81=AE=E5=8F=AF=E8=AA=AD=E6=80=A7=E5=90=91=E4=B8=8A=E3=81=AE?= =?UTF-8?q?=E3=81=9F=E3=82=81=E3=80=81=E9=96=B2=E8=A6=A7=E5=B1=A5=E6=AD=B4?= =?UTF-8?q?=E5=AF=BE=E8=B1=A1=E3=81=AECookie=E4=BB=A5=E5=A4=96=E3=81=A7?= =?UTF-8?q?=E3=81=82=E3=82=8C=E3=81=B0=E3=82=B9=E3=82=AD=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=82=B3=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=AE=E8=A8=98=E8=BC=89=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/open/KnowledgeControl.java | 79 +++++++++---------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java index fe72aa785..9e0267319 100644 --- a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java @@ -37,7 +37,6 @@ import org.support.project.knowledge.logic.MarkdownLogic; import org.support.project.knowledge.logic.TagLogic; import org.support.project.knowledge.logic.TargetLogic; -import org.support.project.knowledge.logic.TemplateLogic; import org.support.project.knowledge.logic.UploadedFileLogic; import org.support.project.knowledge.vo.LikeCount; import org.support.project.knowledge.vo.MarkDown; @@ -89,29 +88,29 @@ public Boundary view() throws InvalidParamException, ParseException { Cookie[] cookies = getRequest().getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { - if (cookie.getName().equals("KNOWLEDGE_HISTORY")) { - String history = cookie.getValue(); - if (history.indexOf(",") != -1) { - history = history.replaceAll(",", "-"); // 旧閲覧履歴情報が存在すれば、変換する - } else { - history = URLDecoder.decode(history, "UTF-8"); - } - if (history.indexOf(COOKIE_SEPARATOR) != -1) { - String[] historyIds = history.split(COOKIE_SEPARATOR); - for (int i = 0; i < historyIds.length; i++) { - if (!ids.contains(historyIds[i]) && StringUtils.isLong(historyIds[i])) { - ids.add(historyIds[i]); - } - if (ids.size() >= COOKIE_COUNT) { - break; - } + if (!cookie.getName().equals("KNOWLEDGE_HISTORY")) { + continue; + } + String history = cookie.getValue(); + if (history.indexOf(",") != -1) { + history = history.replaceAll(",", COOKIE_SEPARATOR); // 旧閲覧履歴情報が存在すれば、変換する + } else { + history = URLDecoder.decode(history, "UTF-8"); + } + if (history.indexOf(COOKIE_SEPARATOR) != -1) { + String[] historyIds = history.split(COOKIE_SEPARATOR); + for (int i = 0; i < historyIds.length; i++) { + if (!ids.contains(historyIds[i]) && StringUtils.isLong(historyIds[i])) { + ids.add(historyIds[i]); } - } else { - if (!ids.contains(history)) { - ids.add(history); + if (ids.size() >= COOKIE_COUNT) { + break; } } - break; + } else { + if (!ids.contains(history)) { + ids.add(history); + } } } String cookieHistory = String.join(COOKIE_SEPARATOR, ids); @@ -355,27 +354,27 @@ public Boundary list() throws Exception { List historyIds = new ArrayList<>(); if (cookies != null) { for (Cookie cookie : cookies) { - if (cookie.getName().equals("KNOWLEDGE_HISTORY")) { - String history = cookie.getValue(); - if (history.indexOf(",") != -1) { - history = history.replaceAll(",", "-"); - } else { - history = URLDecoder.decode(history, "UTF-8"); - } - LOG.debug("history: " + history); - if (history.indexOf(COOKIE_SEPARATOR) != -1) { - String[] splits = history.split(COOKIE_SEPARATOR); - for (String string : splits) { - if (StringUtils.isLong(string)) { - historyIds.add(string); - } - } - } else { - if (StringUtils.isLong(history)) { - historyIds.add(history); + if (!cookie.getName().equals("KNOWLEDGE_HISTORY")) { + continue; + } + String history = cookie.getValue(); + if (history.indexOf(",") != -1) { + history = history.replaceAll(",", COOKIE_SEPARATOR); + } else { + history = URLDecoder.decode(history, "UTF-8"); + } + LOG.debug("history: " + history); + if (history.indexOf(COOKIE_SEPARATOR) != -1) { + String[] splits = history.split(COOKIE_SEPARATOR); + for (String string : splits) { + if (StringUtils.isLong(string)) { + historyIds.add(string); } } - break; + } else { + if (StringUtils.isLong(history)) { + historyIds.add(history); + } } } } From ebf9acbc1da0757d0cb930b36be6abbece41f7ef Mon Sep 17 00:00:00 2001 From: koda Date: Mon, 30 Nov 2015 23:00:20 +0900 Subject: [PATCH 07/12] =?UTF-8?q?#162=20=E3=83=8A=E3=83=AC=E3=83=83?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E7=B7=A8=E9=9B=86=E6=A8=A9=E9=99=90=E3=83=81?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=82=AF=E3=81=A7=E3=80=81=E3=83=8A=E3=83=AC?= =?UTF-8?q?=E3=83=83=E3=82=B8=E3=81=AE=E7=99=BB=E9=8C=B2=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=81=AF=E5=B8=B8=E3=81=AB=E7=B7=A8=E9=9B=86=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E3=81=A8=E5=88=A4=E5=AE=9A=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/support/project/knowledge/logic/KnowledgeLogic.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java index 1c556767a..8567d5573 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java @@ -1229,6 +1229,11 @@ public boolean isEditor(LoginedUser loginedUser, KnowledgesEntity entity, List Date: Mon, 30 Nov 2015 23:01:08 +0900 Subject: [PATCH 08/12] =?UTF-8?q?#162=20=E3=83=8A=E3=83=AC=E3=83=83?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E7=99=BB=E9=8C=B2=E8=80=85=E3=81=AF=E3=80=81?= =?UTF-8?q?=E5=B8=B8=E3=81=AB=E7=B7=A8=E9=9B=86=E5=8F=AF=E8=83=BD=E3=81=AA?= =?UTF-8?q?=E3=81=AE=E3=81=A7=E3=80=81=E5=85=B1=E5=90=8C=E7=B7=A8=E9=9B=86?= =?UTF-8?q?=E8=80=85=E3=81=AB=E7=99=BB=E9=8C=B2=E8=80=85=E3=82=92=E3=82=BB?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=81=99=E3=82=8B=E3=81=93=E3=81=A8=E3=82=92?= =?UTF-8?q?=E3=82=84=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/project/knowledge/logic/KnowledgeLogic.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java index 8567d5573..67fb3409b 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java @@ -199,7 +199,6 @@ public KnowledgesEntity update(KnowledgesEntity entity, List tags, L editUsersDao.deleteOnKnowledgeId(entity.getKnowledgeId()); editGroupsDao.deleteOnKnowledgeId(entity.getKnowledgeId()); - // アクセス権を登録 saveAccessUser(entity, loginedUser, targets); // 編集権を登録 @@ -295,12 +294,6 @@ private void saveEditorsUser(KnowledgesEntity entity, LoginedUser loginedUser, L KnowledgeEditUsersDao editUsersDao = KnowledgeEditUsersDao.get(); KnowledgeEditGroupsDao editGroupsDao = KnowledgeEditGroupsDao.get(); - // ナレッジにアクセス可能なユーザに、自分自身をセット - KnowledgeEditUsersEntity editUsersEntity = new KnowledgeEditUsersEntity(); - editUsersEntity.setKnowledgeId(entity.getKnowledgeId()); - editUsersEntity.setUserId(loginedUser.getLoginUser().getUserId()); - editUsersDao.save(editUsersEntity); - // 編集権限を設定 if (editors != null && !editors.isEmpty()) { for (int i = 0; i < editors.size(); i++) { @@ -318,7 +311,7 @@ private void saveEditorsUser(KnowledgesEntity entity, LoginedUser loginedUser, L && loginedUser.getUserId().intValue() != id.intValue() && ALL_USER != id.intValue() ) { - editUsersEntity = new KnowledgeEditUsersEntity(); + KnowledgeEditUsersEntity editUsersEntity = new KnowledgeEditUsersEntity(); editUsersEntity.setKnowledgeId(entity.getKnowledgeId()); editUsersEntity.setUserId(id); editUsersDao.save(editUsersEntity); From fe7c1455de2e50a140ac5b09b3640fd45e916a72 Mon Sep 17 00:00:00 2001 From: koda Date: Mon, 30 Nov 2015 23:03:26 +0900 Subject: [PATCH 09/12] =?UTF-8?q?#119=20=E4=BF=9D=E5=AD=98=E5=BE=8C?= =?UTF-8?q?=E3=80=81=E3=82=BF=E3=82=B0=E3=81=AE=E9=81=B8=E6=8A=9E=E7=8A=B6?= =?UTF-8?q?=E6=85=8B=E3=81=8C=E5=A4=89=E6=9B=B4=E3=81=95=E3=82=8C=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 登録/更新画面をAjaxによる保存に変更し、画面遷移を伴うデータ保存をやめた --- .../control/protect/KnowledgeControl.java | 77 +++++-------------- .../views/protect/knowledge/view_add.jsp | 23 +++++- .../views/protect/knowledge/view_edit.jsp | 19 +++-- src/main/webapp/js/knowledge-edit.js | 70 ++++++++++++++++- 4 files changed, 123 insertions(+), 66 deletions(-) diff --git a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java index bf13e1cf0..1024b3dce 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java @@ -133,6 +133,7 @@ public Boundary view_edit() throws InvalidParamException { /** * 登録する + * APIによる保存とし、画面遷移は行わない * @return * @throws Exception * @throws ParseException @@ -157,20 +158,12 @@ public Boundary add(KnowledgesEntity entity) throws Exception, ParseException { setAttribute("tagitems", tagitems); List fileNos = new ArrayList(); - Object obj = getParam("files", Object.class); - if (obj != null) { - if (obj instanceof String) { - String string = (String) obj; + String[] filesArray = getParam("files", String[].class); + if (filesArray != null) { + for (String string : filesArray) { if (StringUtils.isLong(string)) { fileNos.add(new Long(string)); } - } else if (obj instanceof List) { - List strings = (List) obj; - for (String string : strings) { - if (StringUtils.isLong(string)) { - fileNos.add(new Long(string)); - } - } } } @@ -191,20 +184,8 @@ public Boundary add(KnowledgesEntity entity) throws Exception, ParseException { List errors = entity.validate(); if (!errors.isEmpty()) { - setResult(null, errors); - // バリデーションエラーが発生した場合、設定されていた添付ファイルの情報は再取得 - List files = fileLogic.selectOnFileNos(fileNos, getRequest().getContextPath()); - Iterator iterator = files.iterator(); - while (iterator.hasNext()) { - UploadFile uploadFile = (UploadFile) iterator.next(); - if (uploadFile.getKnowlegeId() != null) { - // 新規登録なのに、添付ファイルが既にナレッジに紐づいている(おかしい) - iterator.remove(); - } - } - setAttribute("files", files); - - return forward("view_add.jsp"); + //入力エラー + return sendValidateError(errors); } LOG.trace("save"); String tags = super.getParam("tagNames"); @@ -217,11 +198,13 @@ public Boundary add(KnowledgesEntity entity) throws Exception, ParseException { setAttribute("files", files); addMsgSuccess("message.success.insert"); - return forward("view_edit.jsp"); +// return forward("view_edit.jsp"); + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, String.valueOf(entity.getKnowledgeId()), "message.success.insert"); } /** * 更新する + * APIによる保存とし、画面遷移は行わない * @return * @throws Exception */ @@ -244,20 +227,12 @@ public Boundary update(KnowledgesEntity entity) throws Exception { setAttribute("tagitems", tagitems); List fileNos = new ArrayList(); - Object obj = getParam("files", Object.class); - if (obj != null) { - if (obj instanceof String) { - String string = (String) obj; + String[] filesArray = getParam("files", String[].class); + if (filesArray != null) { + for (String string : filesArray) { if (StringUtils.isLong(string)) { fileNos.add(new Long(string)); } - } else if (obj instanceof List) { - List strings = (List) obj; - for (String string : strings) { - if (StringUtils.isLong(string)) { - fileNos.add(new Long(string)); - } - } } } @@ -279,22 +254,8 @@ public Boundary update(KnowledgesEntity entity) throws Exception { KnowledgesDao dao = Container.getComp(KnowledgesDao.class); List errors = entity.validate(); if (!errors.isEmpty()) { - setResult(null, errors); - - // バリデーションエラーが発生した場合、設定されていた添付ファイルの情報は再取得 - List files = fileLogic.selectOnFileNos(fileNos, getRequest().getContextPath()); - Iterator iterator = files.iterator(); - while (iterator.hasNext()) { - UploadFile uploadFile = (UploadFile) iterator.next(); - if (uploadFile.getKnowlegeId() != null - && uploadFile.getKnowlegeId().longValue() != entity.getKnowledgeId().longValue()) { - // ナレッジIDが空でなく、かつ、更新中のナレッジ以外に紐づいている添付ファイルはおかしいので削除 - iterator.remove(); - } - } - setAttribute("files", files); - - return forward("view_edit.jsp"); + //入力エラー + return sendValidateError(errors); } KnowledgesEntity check = dao.selectOnKey(entity.getKnowledgeId()); @@ -305,8 +266,11 @@ public Boundary update(KnowledgesEntity entity) throws Exception { if (!knowledgeLogic.isEditor(super.getLoginedUser(), check, editors)) { setAttribute("edit", false); addMsgWarn("knowledge.edit.noaccess"); - //return forward("/open/knowledge/view.jsp"); - return devolution(HttpMethod.get, "open.Knowledge/view", String.valueOf(entity.getKnowledgeId())); +// return devolution(HttpMethod.get, "open.Knowledge/view", String.valueOf(entity.getKnowledgeId())); + + errors = new ArrayList<>(); + errors.add(new ValidateError("knowledge.edit.noaccess")); + return sendValidateError(errors); } LOG.trace("save"); @@ -320,7 +284,8 @@ public Boundary update(KnowledgesEntity entity) throws Exception { List files = fileLogic.selectOnKnowledgeIdWithoutCommentFiles(entity.getKnowledgeId(), getRequest().getContextPath()); setAttribute("files", files); - return forward("view_edit.jsp"); + // return forward("view_edit.jsp"); + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, String.valueOf(entity.getKnowledgeId()), "message.success.update"); } /** diff --git a/src/main/webapp/WEB-INF/views/protect/knowledge/view_add.jsp b/src/main/webapp/WEB-INF/views/protect/knowledge/view_add.jsp index 35fda5ac7..ab703ea7c 100644 --- a/src/main/webapp/WEB-INF/views/protect/knowledge/view_add.jsp +++ b/src/main/webapp/WEB-INF/views/protect/knowledge/view_add.jsp @@ -37,6 +37,8 @@ var _REMOVE_FILE = '<%= jspUtil.label("knowledge.edit.label.delete.upload") %>'; var _FAIL_REMOVE_FILE = '<%= jspUtil.label("knowledge.edit.label.fail.delete.upload") %>'; var _CONFIRM = '<%= jspUtil.label("knowledge.edit.label.confirm.delete") %>'; var _SET_IMAGE_LABEL= '<%= jspUtil.label("knowledge.edit.set.image.path") %>'; +var _LABEL_UPDATE = '<%= jspUtil.label("label.update") %>'; +var _UPDATE_TITLE = '<%= jspUtil.label("knowledge.edit.title") %>'; selectedGroups.push({label: '<%= jspUtil.out("group.label") %>', value: '<%= jspUtil.out("group.value") %>'}); @@ -57,9 +59,9 @@ _TAGS.push('<%= jspUtil.out("tagitem.tagName") %>'); -

<%= jspUtil.label("knowledge.add.title") %>

+

<%= jspUtil.label("knowledge.add.title") %>

-
+
@@ -204,6 +206,8 @@ _TAGS.push('<%= jspUtil.out("tagitem.tagName") %>');

+ + " /> " /> " /> @@ -211,8 +215,17 @@ _TAGS.push('<%= jspUtil.out("tagitem.tagName") %>');
- + + + + <%= jspUtil.out("params") %>" + class="btn btn-warning hide" role="button" id="cancelButton"> +  <%= jspUtil.label("label.cancel") %> + + <%= jspUtil.out("params") %>" class="btn btn-success" role="button"> <%= jspUtil.label("label.backlist") %> @@ -333,6 +346,10 @@ _TAGS.push('<%= jspUtil.out("tagitem.tagName") %>'); + + " id="knowledgeIdForDelete" /> +
+
diff --git a/src/main/webapp/WEB-INF/views/protect/knowledge/view_edit.jsp b/src/main/webapp/WEB-INF/views/protect/knowledge/view_edit.jsp index 8c8081abe..239c43ef4 100644 --- a/src/main/webapp/WEB-INF/views/protect/knowledge/view_edit.jsp +++ b/src/main/webapp/WEB-INF/views/protect/knowledge/view_edit.jsp @@ -38,6 +38,8 @@ var _REMOVE_FILE = '<%= jspUtil.label("knowledge.edit.label.delete.upload") %>'; var _FAIL_REMOVE_FILE = '<%= jspUtil.label("knowledge.edit.label.fail.delete.upload") %>'; var _CONFIRM = '<%= jspUtil.label("knowledge.edit.label.confirm.delete") %>'; var _SET_IMAGE_LABEL= '<%= jspUtil.label("knowledge.edit.set.image.path") %>'; +var _LABEL_UPDATE = '<%= jspUtil.label("label.update") %>'; +var _UPDATE_TITLE = '<%= jspUtil.label("knowledge.edit.title") %>'; selectedGroups.push({label: '<%= jspUtil.out("group.label") %>', value: '<%= jspUtil.out("group.value") %>'}); @@ -59,7 +61,7 @@ _TAGS.push('<%= jspUtil.out("tagitem.tagName") %>'); -

<%= jspUtil.label("knowledge.edit.title") %>

+

<%= jspUtil.label("knowledge.edit.title") %>

@@ -224,14 +226,17 @@ _TAGS.push('<%= jspUtil.out("tagitem.tagName") %>');
- + - - + <%= jspUtil.out("params") %>" - class="btn btn-warning" role="button"> <%= jspUtil.label("label.cancel") %> + class="btn btn-warning" role="button" id="cancelButton"> +  <%= jspUtil.label("label.cancel") %> + <%= jspUtil.out("params") %>" class="btn btn-success" role="button"> <%= jspUtil.label("label.backlist") %> @@ -343,6 +348,10 @@ _TAGS.push('<%= jspUtil.out("tagitem.tagName") %>'); + + " id="knowledgeIdForDelete" /> + + diff --git a/src/main/webapp/js/knowledge-edit.js b/src/main/webapp/js/knowledge-edit.js index 26f37af6f..4adedfa24 100644 --- a/src/main/webapp/js/knowledge-edit.js +++ b/src/main/webapp/js/knowledge-edit.js @@ -202,6 +202,72 @@ $(document).ready(function() { }); changeTemplate(); + + // 保存処理 + // フォームのサブミットは禁止 + $('#knowledgeForm').submit(function(event) { + console.log('submit'); + // 操作対象のフォーム要素を取得 + var $form = $(this); + // ページ遷移を禁止して、Ajaxで保存 + event.preventDefault(); + + // 送信ボタンを取得 + // (後で使う: 二重送信を防止する。) + var $button = $form.find('button'); + + // 送信 + $.ajax({ + url: $form.attr('action'), + type: $form.attr('method'), + data: $form.serialize(), + timeout: 10000, // 単位はミリ秒 + + // 送信前 + beforeSend: function(xhr, settings) { + // ボタンを無効化し、二重送信を防止 + $button.attr('disabled', true); + }, + // 応答後 + complete: function(xhr, textStatus) { + // ボタンを有効化し、再送信を許可 + $button.attr('disabled', false); + }, + + // 通信成功時の処理 + success: function(result, textStatus, xhr) { + // 入力値を初期化 + console.log(result); + $.notify(result.message, 'info'); + + $form.attr('action', _CONTEXT + '/protect.knowledge/update'); + + var knowledgeId = result.result; + $('#knowledgeId').val(knowledgeId); + $('#knowledgeIdForDelete').val(knowledgeId); + $('#savebutton').html(' ' + _LABEL_UPDATE); + $('#title_msg').text(_UPDATE_TITLE); + $('#deleteButton').removeClass('hide'); + $('#cancelButton').removeClass('hide'); + $('#cancelButton').attr('href', _CONTEXT + '/open.knowledge/view/' + knowledgeId); + }, + // 通信失敗時の処理 + error: function(xhr, textStatus, error) { + // 入力値を初期化 + console.log(xhr.responseJSON); + var msg = xhr.responseJSON; + if (msg.children) { + for (var i = 0; i < msg.children.length; i++) { + var child = msg.children[i]; + console.log(child); + $.notify(child.message, 'warn'); + } + } + } + }); + return false; + }); + }); var getGroups = function(keyword, offset, listId, pageId, selectFunc) { @@ -397,8 +463,8 @@ var emojiSelect = function(id) { function deleteKnowledge() { bootbox.confirm(_CONFIRM, function(result) { if (result) { - $('#knowledgeForm').attr('action', _CONTEXT + '/protect.knowledge/delete'); - $('#knowledgeForm').submit(); + $('#knowledgeDeleteForm').attr('action', _CONTEXT + '/protect.knowledge/delete'); + $('#knowledgeDeleteForm').submit(); } }); }; From 715b33d480329f96b5a72c83938401bdf7454238 Mon Sep 17 00:00:00 2001 From: koda Date: Tue, 1 Dec 2015 22:21:15 +0900 Subject: [PATCH 10/12] =?UTF-8?q?#73=20=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E6=8A=98=E3=82=8A=E3=81=9F=E3=81=9F=E3=82=93?= =?UTF-8?q?=E3=81=A7=E9=9D=9E=E8=A1=A8=E7=A4=BA=EF=BC=8F=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=82=92=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E3=82=89=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/protect/KnowledgeControl.java | 48 ++++++++++++++++++- src/main/resources/appresource.properties | 5 ++ src/main/resources/appresource_ja.properties | 5 ++ .../WEB-INF/views/open/knowledge/view.jsp | 44 +++++++++++++---- src/main/webapp/css/knowledge-view.css | 6 +++ src/main/webapp/js/knowledge-view.js | 30 +++++++++++- 6 files changed, 128 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java index 1024b3dce..f3f10f1c5 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java @@ -642,7 +642,53 @@ public Boundary stock() throws IOException, InvalidParamException { } } return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, "saved", "message.success.save"); - }; + }; + + + /** + * コメントを折りたたみ + * @return + * @throws IOException + * @throws InvalidParamException + */ + @Post + public Boundary collapse() throws IOException, InvalidParamException { + Long commentNo = getParam("commentNo", Long.class); + Integer collapse = getParam("collapse", Integer.class); + + CommentsDao commentsDao = CommentsDao.get(); + CommentsEntity db = commentsDao.selectOnKey(commentNo); + + // 権限チェック(コメントの編集は、システム管理者 or コメントの登録者 or ナレッジ編集者 + LoginedUser loginedUser = super.getLoginedUser(); + if (loginedUser == null) { + // ログインしていないユーザに編集権限は無し + return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); + } + if (!loginedUser.isAdmin() && + loginedUser.getUserId().intValue() != db.getInsertUser().intValue()) { + KnowledgesEntity check = KnowledgesDao.get().selectOnKey(db.getKnowledgeId()); + if (check == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT_FOUND"); + } + List editors = TargetLogic.get().selectEditorsOnKnowledgeId(db.getKnowledgeId()); + if (!knowledgeLogic.isEditor(super.getLoginedUser(), check, editors)) { + return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); + } + } + + // ステータス更新 + db.setCommentStatus(collapse); + commentsDao.physicalUpdate(db); // 更新履歴は付けないで更新 + + if (collapse == 1) { + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, String.valueOf(commentNo), "knowledge.view.comment.collapse.on"); + } else { + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, String.valueOf(commentNo), "knowledge.view.comment.collapse.off"); + } + } + + } diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index 087b4a58d..41dc94344 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -202,6 +202,11 @@ knowledge.view.back.list=Back to list knowledge.view.comment=Add Comment knowledge.view.comment.with.login=Add Comment(Sign in) knowledge.view.stock.modal.title=Stock +knowledge.view.comment.collapse=Collapse +knowledge.view.comment.open=Open +knowledge.view.comment.collapsed=Collapsed +knowledge.view.comment.collapse.on=Collapsed +knowledge.view.comment.collapse.off=Opened knowledge.search.title=Search Knowledge knowledge.search.placeholder=Search keyword knowledge.search.keyword=Keyword diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index d49152125..3b84ad43b 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -202,6 +202,11 @@ knowledge.view.back.list=一覧に戻る knowledge.view.comment=コメントを追加 knowledge.view.comment.with.login=コメントを追加(サインイン) knowledge.view.stock.modal.title=ストックする +knowledge.view.comment.collapse=非表示 +knowledge.view.comment.open=表示 +knowledge.view.comment.collapsed=非表示 +knowledge.view.comment.collapse.on=非表示にしました +knowledge.view.comment.collapse.off=表示します knowledge.search.title=ナレッジ検索 knowledge.search.placeholder=キーワードでナレッジを検索 knowledge.search.keyword=検索キーワード diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp index 79fa9bc43..81dd4340e 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp @@ -1,3 +1,4 @@ +<%@page import="javax.swing.JSplitPane"%> <%@page import="org.support.project.knowledge.entity.KnowledgesEntity"%> <%@page import="org.support.project.knowledge.entity.CommentsEntity"%> <%@page import="org.support.project.knowledge.logic.KnowledgeLogic"%> @@ -218,13 +219,23 @@ Knowledge - [<%= jspUtil.out("knowledgeId") %>] <%= jspUtil.out("title", JspUtil <% if (jspUtil.isAdmin() || jspUtil.is(jspUtil.id(), "comment.insertUser") || (boolean) request.getAttribute("edit")) { %>   - Edit + <%= jspUtil.label("label.edit") %> +   + +   + <% } %>
-
+
" @@ -244,9 +255,14 @@ Knowledge - [<%= jspUtil.out("knowledgeId") %>] <%= jspUtil.out("title", JspUtil
-
+ +
+ <%= jspUtil.label("knowledge.view.comment.collapsed") %> +
+
+ <% } else { %>
@@ -254,8 +270,18 @@ Knowledge - [<%= jspUtil.out("knowledgeId") %>] <%= jspUtil.out("title", JspUtil <% if (jspUtil.isAdmin() || jspUtil.is(jspUtil.id(), "comment.insertUser") || (boolean) request.getAttribute("edit")) { %>   - Edit + <%= jspUtil.label("label.edit") %> +   + +   + <% } %> [<%= jspUtil.label("label.registration") %>] @@ -267,7 +293,7 @@ Knowledge - [<%= jspUtil.out("knowledgeId") %>] <%= jspUtil.out("title", JspUtil
-
+
" @@ -275,7 +301,6 @@ Knowledge - [<%= jspUtil.out("knowledgeId") %>] <%= jspUtil.out("title", JspUtil
<%= jspUtil.out("comment.comment", JspUtil.ESCAPE_NONE) %> -
@@ -286,11 +311,14 @@ Knowledge - [<%= jspUtil.out("knowledgeId") %>] <%= jspUtil.out("title", JspUtil
-
- <% } %> +
+ <%= jspUtil.label("knowledge.view.comment.collapsed") %> +
+
+ <% } %>
diff --git a/src/main/webapp/css/knowledge-view.css b/src/main/webapp/css/knowledge-view.css index bc989503b..9cb982ddf 100644 --- a/src/main/webapp/css/knowledge-view.css +++ b/src/main/webapp/css/knowledge-view.css @@ -133,3 +133,9 @@ Comments margin-bottom: 25px; overflow: hidden; } + + +.collapse_comment { + padding-bottom: 10px; + color: gray; +} \ No newline at end of file diff --git a/src/main/webapp/js/knowledge-view.js b/src/main/webapp/js/knowledge-view.js index 5a6a5facd..c3ffb0b64 100644 --- a/src/main/webapp/js/knowledge-view.js +++ b/src/main/webapp/js/knowledge-view.js @@ -474,4 +474,32 @@ var saveStocks = function(knowledgeId) { }); }; - +var collapse = function(comment_id, collapseFlag) { + if (collapseFlag) { + $('#comment_' + comment_id).addClass('hide'); + $('#comment_collapse_' + comment_id).removeClass('hide'); + $('#collapse_on_' + comment_id).addClass('hide'); + $('#collapse_off_' + comment_id).removeClass('hide'); + } else { + $('#comment_' + comment_id).removeClass('hide'); + $('#comment_collapse_' + comment_id).addClass('hide'); + $('#collapse_on_' + comment_id).removeClass('hide'); + $('#collapse_off_' + comment_id).addClass('hide'); + } + // 保存 + var url = _CONTEXT + '/protect.knowledge/collapse/'; + console.log(stocksInfo); + $.ajax({ + type : 'POST', + url : url, + data : 'commentNo=' + comment_id + '&collapse=' + collapseFlag, + scriptCharset: 'utf-8', + success : function(datas, dataType) { + console.log(datas); + $.notify(datas.message, 'success'); + }, + error: function(XMLHttpRequest, textStatus, errorThrown){ + $.notify('[fail] collapse', 'warn'); + } + }); +}; From 6955b6e8f27803231e0fc8a8a13580f23689deeb Mon Sep 17 00:00:00 2001 From: koda Date: Thu, 3 Dec 2015 06:45:47 +0900 Subject: [PATCH 11/12] =?UTF-8?q?#73=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E5=87=BA=E5=8A=9B=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/js/knowledge-view.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/webapp/js/knowledge-view.js b/src/main/webapp/js/knowledge-view.js index c3ffb0b64..2bcf0a874 100644 --- a/src/main/webapp/js/knowledge-view.js +++ b/src/main/webapp/js/knowledge-view.js @@ -488,7 +488,6 @@ var collapse = function(comment_id, collapseFlag) { } // 保存 var url = _CONTEXT + '/protect.knowledge/collapse/'; - console.log(stocksInfo); $.ajax({ type : 'POST', url : url, From c104c42ddd6c076adc1f2eeffe64c1ea6adb712b Mon Sep 17 00:00:00 2001 From: koda Date: Fri, 4 Dec 2015 06:01:12 +0900 Subject: [PATCH 12/12] =?UTF-8?q?#178=20Release0.7.0=20pre2=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=83=AA=E3=83=BC=E3=82=B9=E3=81=AE=E3=81=9F=E3=82=81?= =?UTF-8?q?=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E6=96=87?= =?UTF-8?q?=E5=AD=97=E5=88=97=E3=81=AE=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/appresource.properties | 2 +- src/main/resources/appresource_ja.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index 41dc94344..d33afe02d 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -55,7 +55,7 @@ message.allready.started=Allready started. message.confirm.delete=Are you sure you want to delete? # Common Label -label.version=0.7.0 Pre1 +label.version=0.7.0 Pre2 label.login=Sign in label.previous = Previous label.next=Next diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index 3b84ad43b..8932a039b 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -55,7 +55,7 @@ message.allready.started=すでに開始済です message.confirm.delete=本当に削除しますか? # Common Label -label.version=0.7.0 Pre1 +label.version=0.7.0 Pre2 label.login=サインイン label.previous = 前へ label.next = 次へ