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") %> + + + + +<%= jspUtil.label("label.mark.all.as.read") %> + + @@ -65,7 +83,7 @@ ?all=true" > - #<%= jspUtil.out("notification.no") %> + @<%= jspUtil.out("notification.no") %> [<%= jspUtil.label("label.unread") %>] <%= jspUtil.out("notification.title") %> @@ -76,7 +94,7 @@ ?all=true" > - #<%= jspUtil.out("notification.no") %> + @<%= jspUtil.out("notification.no") %> <%= jspUtil.out("notification.title") %> <%= jspUtil.date("notification.insertDatetime") %> diff --git a/src/main/webapp/js/notification-list.js b/src/main/webapp/js/notification-list.js new file mode 100644 index 000000000..f3c1d60f6 --- /dev/null +++ b/src/main/webapp/js/notification-list.js @@ -0,0 +1,21 @@ +$(document).ready(function() { + $('#btnMarkAllAsRead').click(function() { + console.log(UNREAD_LIST); + if (UNREAD_LIST.length > 0) { + var data = { + no: UNREAD_LIST.join(',') + }; + $.ajax({ + url: _CONTEXT + '/protect.notification/markread', + type: 'POST', + data: data, + timeout: 10000, + }).done(function(result, textStatus, xhr) { + console.log(result); + location.reload(); + }).fail(function(xhr, textStatus, error) { + console.log(error); + }); + } + }); +}); \ No newline at end of file
<%= jspUtil.date("notification.insertDatetime") %>