A panel for showing notifications in the system
Change-Id: Ie4282393812c2c4b804548cfad564b0aad273ea3
This commit is contained in:
parent
4fd9a45938
commit
c15e48023d
src/main/java/se/su/dsv/scipro/project/panels
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id="container">
|
||||
<div wicket:id="notificationsListView">
|
||||
<div wicket:id="infoText"></div>
|
||||
<a href="#" wicket:id="readNotification">Read Notification</a>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,80 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.project.panels;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.NotificationDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Notification;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan <aschan@dsv.su.se>
|
||||
*
|
||||
*/
|
||||
public class NotificationsPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SpringBean
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public NotificationsPanel(String id) {
|
||||
super(id);
|
||||
|
||||
final IModel<List<Notification>> notificaitonsModel = new LoadableDetachableModel<List<Notification>>() {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected List<Notification> load() {
|
||||
return notificationDao.getNotifications(SciProSession.get().getUser());
|
||||
}
|
||||
};
|
||||
final WebMarkupContainer webMarkupContainer = new WebMarkupContainer("container");
|
||||
webMarkupContainer.setOutputMarkupId(true);
|
||||
add(webMarkupContainer);
|
||||
ListView<Notification> notifications = new ListView<Notification>("notificationsListView", notificaitonsModel) {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<Notification> item) {
|
||||
item.add(new Label("infoText", item.getModel().getObject().getInfoText()));
|
||||
item.add(new AjaxLink<Void>("readNotification") {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
Notification notification = item.getModel().getObject();
|
||||
notification.getSubscribers().remove(SciProSession.get().getUser());
|
||||
notificationDao.save(notification);
|
||||
notificaitonsModel.detach();
|
||||
target.addComponent(webMarkupContainer);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
webMarkupContainer.add(notifications);
|
||||
}
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div class="margin rounded-border">
|
||||
<form wicket:id="sendForm">
|
||||
<textarea wicket:id="textArea"></textarea>
|
||||
<div>
|
||||
<button type="submit" wicket:id="ajaxButton">
|
||||
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt="" />Send
|
||||
Message
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div wicket:id="container" class="margin clear">
|
||||
<div wicket:id="boardMessageDataView" class="rounded-border">
|
||||
<span wicket:id="messageUser" class="small"> </span>
|
||||
<span wicket:id="messageDate" class="small"></span>
|
||||
<span><a href="#"
|
||||
wicket:id="delete" class="right-corner-resource"> <img class="icon-12"
|
||||
src="images/icons/delete_16x16.png" alt="Delete" title="Delete" />
|
||||
</a>
|
||||
</span>
|
||||
<div wicket:id="messageLabel" class="margin"></div>
|
||||
<div>
|
||||
<a href="#" wicket:id="showComments"><span
|
||||
wicket:id="commentNumber"></span> </a>
|
||||
</div>
|
||||
<div wicket:id="commentContainer">
|
||||
<div wicket:id="commentThread"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div wicket:id="pagingNavigator"></div>
|
||||
</div>
|
||||
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user