diff options
author | BUISSON Christian <cbuisson@deltadore.com> | 2014-04-15 15:21:33 +0200 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-05-01 16:14:14 -0400 |
commit | 3380373c3123f875f50e48b0290c84dfae0519e4 (patch) | |
tree | 41c63acaa6741da4883fb1cff54cfad23b751a97 /src/main/java/com/gitblit/wicket/pages | |
parent | c9de84169e407fbf1963e7ad0e1f3f3e57cfae24 (diff) | |
download | gitblit-3380373c3123f875f50e48b0290c84dfae0519e4.tar.gz gitblit-3380373c3123f875f50e48b0290c84dfae0519e4.zip |
First Step in My Tickets
Diffstat (limited to 'src/main/java/com/gitblit/wicket/pages')
3 files changed, 179 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html new file mode 100644 index 00000000..bbb2b96b --- /dev/null +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html @@ -0,0 +1,50 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" + xml:lang="en" + lang="en"> + +<body> + <wicket:extend> + <table> + <span>Responsible Tickets</span> + <tbody> + <tr wicket:id="responsibleTickets"> + <td><span wicket:id="ticketName"></span></td> + <td><span wicket:id="ticketDescription"></span></td> + </tr> + </tbody> + </table> + + <table> + <span>Author Tickets</span> + <tbody> + <tr wicket:id="authorTickets"> + <td><span wicket:id="ticketName"></span></td> + <td><span wicket:id="ticketDescription"></span></td> + </tr> + </tbody> + </table> + + <table> + <span>Voted Tickets</span> + <tbody> + <tr wicket:id="votedTickets"> + <td><span wicket:id="ticketName"></span></td> + <td><span wicket:id="ticketDescription"></span></td> + </tr> + </tbody> + </table> + + <table> + <span>Watched Tickets</span> + <tbody> + <tr wicket:id="watchedTickets"> + <td><span wicket:id="ticketName"></span></td> + <td><span wicket:id="ticketDescription"></span></td> + </tr> + </tbody> + </table> + </wicket:extend> +</body> +</html>
\ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java new file mode 100644 index 00000000..509b00ca --- /dev/null +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java @@ -0,0 +1,128 @@ +package com.gitblit.wicket.pages; + +import java.util.ArrayList; +import java.util.List; + +import com.gitblit.models.UserModel; +import com.gitblit.models.TicketModel; +import com.gitblit.tickets.ITicketService; +import com.gitblit.wicket.GitBlitWebApp; +import com.gitblit.wicket.GitBlitWebSession; +import com.gitblit.wicket.panels.LinkPanel; + +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.PageParameters; + +public class MyTicketsPage extends RootPage { + + public MyTicketsPage(PageParameters params) + { + this(); + } + + public MyTicketsPage() + { + super(); + setupPage("", ""); + + UserModel currentUser = GitBlitWebSession.get().getUser(); + if (currentUser == null) { + currentUser = UserModel.ANONYMOUS; + } + String username = currentUser.getName(); + + ITicketService tickets = GitBlitWebApp.get().tickets(); + List<TicketModel> returnedTickets = tickets.getTickets(null); + + List<TicketModel> responsibleTickets = new ArrayList<TicketModel>(); + List<TicketModel> authorTickets = new ArrayList<TicketModel>(); + List<TicketModel> votedTickets = new ArrayList<TicketModel>(); + List<TicketModel> watchedTickets = new ArrayList<TicketModel>(); + for(int i = 0; i < returnedTickets.size(); i++) + { + TicketModel ticket = returnedTickets.get(i); + if(ticket.isOpen()) + { + if(ticket.isResponsible(username)) + { + responsibleTickets.add(ticket); + } + if(ticket.isAuthor(username)) + { + authorTickets.add(ticket); + } + if(ticket.isVoter(username)) + { + votedTickets.add(ticket); + } + if(ticket.isWatching(username)) + { + watchedTickets.add(ticket); + } + } + } + + ListView<TicketModel> responsibleView = new ListView<TicketModel>("responsibleTickets", responsibleTickets) + { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final ListItem<TicketModel> item) + { + final TicketModel ticket = item.getModelObject(); + String ticketUrl = app().tickets().getTicketUrl(ticket); + item.add(new LinkPanel("ticketName", "", ticket.title, ticketUrl)); + item.add(new Label("ticketDescription", ticket.body)); + } + }; + + ListView<TicketModel> authorView = new ListView<TicketModel>("authorTickets", authorTickets) + { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final ListItem<TicketModel> item) + { + final TicketModel ticket = item.getModelObject(); + String ticketUrl = app().tickets().getTicketUrl(ticket); + item.add(new LinkPanel("ticketName", "", ticket.title, ticketUrl)); + item.add(new Label("ticketDescription", ticket.body)); + } + }; + + ListView<TicketModel> votedView = new ListView<TicketModel>("votedTickets", votedTickets) + { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final ListItem<TicketModel> item) + { + final TicketModel ticket = item.getModelObject(); + String ticketUrl = app().tickets().getTicketUrl(ticket); + item.add(new LinkPanel("ticketName", "", ticket.title, ticketUrl)); + item.add(new Label("ticketDescription", ticket.body)); + } + }; + + ListView<TicketModel> watchedView = new ListView<TicketModel>("watchedTickets", watchedTickets) + { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final ListItem<TicketModel> item) + { + final TicketModel ticket = item.getModelObject(); + String ticketUrl = app().tickets().getTicketUrl(ticket); + item.add(new LinkPanel("ticketName", "", ticket.title, ticketUrl)); + item.add(new Label("ticketDescription", ticket.body)); + } + }; + + add(responsibleView); + add(authorView); + add(votedView); + add(watchedView); + } +} diff --git a/src/main/java/com/gitblit/wicket/pages/RootPage.java b/src/main/java/com/gitblit/wicket/pages/RootPage.java index 5ccc3a4c..ec413b19 100644 --- a/src/main/java/com/gitblit/wicket/pages/RootPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RootPage.java @@ -173,6 +173,7 @@ public abstract class RootPage extends BasePage { pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class,
getRootPageParameters()));
pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));
+ pages.add(new PageRegistration("gb.mytickets", MyTicketsPage.class, getRootPageParameters()));
if (app().settings().getBoolean(Keys.web.allowLuceneIndexing, true)) {
pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));
}
|