From 975c2b3071ab7d7dbecfab81abf3f263d5162916 Mon Sep 17 00:00:00 2001 From: Koda Date: Mon, 21 Aug 2017 23:32:06 +0900 Subject: [PATCH] #349 Add mark all as read button on notification list page --- .../control/protect/NotificationControl.java | 10 +++++++++ .../knowledge/logic/NotificationLogic.java | 13 +++++++++++ src/main/resources/appresource.properties | 1 + src/main/resources/appresource_ja.properties | 1 + .../views/protect/notification/list.jsp | 22 +++++++++++++++++-- src/main/webapp/js/notification-list.js | 21 ++++++++++++++++++ 6 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 src/main/webapp/js/notification-list.js diff --git a/src/main/java/org/support/project/knowledge/control/protect/NotificationControl.java b/src/main/java/org/support/project/knowledge/control/protect/NotificationControl.java index 5c002972d..1714078ec 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/NotificationControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/NotificationControl.java @@ -7,6 +7,7 @@ import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.entity.NotificationsEntity; import org.support.project.web.exception.InvalidParamException; @@ -75,4 +76,13 @@ public Boundary next() throws InvalidParamException { setAttribute("no", no); return forward("view.jsp"); } + + @Post + public Boundary markread() { + String no = getAttribute("no", ""); + NotificationLogic.get().markAllAsRead(no, getLoginUserId()); + return send("OK"); + } + + } diff --git a/src/main/java/org/support/project/knowledge/logic/NotificationLogic.java b/src/main/java/org/support/project/knowledge/logic/NotificationLogic.java index 080eb4b68..b83eb3ce8 100644 --- a/src/main/java/org/support/project/knowledge/logic/NotificationLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/NotificationLogic.java @@ -3,6 +3,8 @@ import java.util.Iterator; import java.util.List; +import org.support.project.aop.Aspect; +import org.support.project.common.util.StringUtils; import org.support.project.di.Container; import org.support.project.knowledge.logic.notification.AcceptCheckUserNotification; import org.support.project.knowledge.logic.notification.AddUserNotification; @@ -128,4 +130,15 @@ public NotificationsEntity next(long no, LoginedUser loginedUser, boolean all) { notification.convNotification(notificationsEntity, loginedUser, TARGET.detail); return notificationsEntity; } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void markAllAsRead(String no, Integer userID) { + String[] nos = no.split(","); + for (String n : nos) { + if (StringUtils.isInteger(n)) { + int num = Integer.parseInt(n); + super.setStatus(userID, num, NotificationLogic.STATUS_READED); + } + } + } } diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index e87dcb45c..59d000938 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -117,6 +117,7 @@ label.unread=Unread label.read=Read label.save.draft=Save draft label.delete.draft=Delete draft +label.mark.all.as.read=Mark all as read label.public.view= [Public] label.protect.view= [Protection] diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index 6ec5b0e97..c9b742b26 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -117,6 +117,7 @@ label.unread=未読 label.read=既読 label.save.draft=下書き保存 label.delete.draft=下書き削除 +label.mark.all.as.read=既読にする label.public.view= [公開] label.protect.view= [保護] diff --git a/src/main/webapp/WEB-INF/views/protect/notification/list.jsp b/src/main/webapp/WEB-INF/views/protect/notification/list.jsp index 310aa8c3f..60221836f 100644 --- a/src/main/webapp/WEB-INF/views/protect/notification/list.jsp +++ b/src/main/webapp/WEB-INF/views/protect/notification/list.jsp @@ -10,16 +10,27 @@ + + + + + +

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

+
<%= jspUtil.label("knowledge.notification.list.only.unread") %> @@ -36,6 +47,13 @@ <%= jspUtil.label("knowledge.notification.list.all") %> +
+
+ +