From: James Moger Date: Wed, 30 Apr 2014 21:15:31 +0000 (-0400) Subject: Show open milestone progress and change milestones list layout X-Git-Tag: v1.6.0~99^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Ftickets%2F17%2F17%2F2;p=gitblit.git Show open milestone progress and change milestones list layout --- diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties index e66e53a7..1394890f 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties @@ -675,4 +675,6 @@ gb.youDoNotHaveClonePermission = You are not permitted to clone this repository. gb.newMilestone = new milestone gb.editMilestone = edit milestone gb.notifyChangedOpenTickets = send notification for changed open tickets -gb.overdue = overdue \ No newline at end of file +gb.overdue = overdue +gb.openMilestones = open milestones +gb.closedMilestones = closed milestones \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/TicketsPage.html b/src/main/java/com/gitblit/wicket/pages/TicketsPage.html index e144bea1..a40d3126 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketsPage.html +++ b/src/main/java/com/gitblit/wicket/pages/TicketsPage.html @@ -141,15 +141,49 @@
+ +
+

+

+
+
+
+
+
+
+
-
-

- +

+

+
+
+
+
+
+ +

+ +
+
+ + +
+
+
+
+
+ , + , + +
+
+
+ diff --git a/src/main/java/com/gitblit/wicket/pages/TicketsPage.java b/src/main/java/com/gitblit/wicket/pages/TicketsPage.java index b7e392a2..5973d473 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketsPage.java @@ -660,27 +660,49 @@ public class TicketsPage extends TicketBasePage { } // milestones list - List allMilestones = new ArrayList(app().tickets().getMilestones(repositoryModel)); - Collections.sort(allMilestones, new Comparator() { + List openMilestones = new ArrayList(); + List closedMilestones = new ArrayList(); + for (TicketMilestone milestone : app().tickets().getMilestones(repositoryModel)) { + if (milestone.isOpen()) { + openMilestones.add(milestone); + } else { + closedMilestones.add(milestone); + } + } + Collections.sort(openMilestones, new Comparator() { + @Override + public int compare(TicketMilestone o1, TicketMilestone o2) { + return o2.due.compareTo(o1.due); + } + }); + + Collections.sort(closedMilestones, new Comparator() { @Override public int compare(TicketMilestone o1, TicketMilestone o2) { - if (o2.isOpen() && !o1.isOpen()) { - return 1; - } else if (o1.isOpen() && !o2.isOpen()) { - return -1; - } return o2.due.compareTo(o1.due); } }); - ListDataProvider allMilestonesDp = new ListDataProvider(allMilestones); - DataView milestonesList = new DataView("milestoneList", allMilestonesDp) { + + DataView openMilestonesList = milestoneList("openMilestonesList", openMilestones, acceptingUpdates); + add(openMilestonesList); + + DataView closedMilestonesList = milestoneList("closedMilestonesList", closedMilestones, acceptingUpdates); + add(closedMilestonesList); + } + + protected DataView milestoneList(String wicketId, List milestones, final boolean acceptingUpdates) { + ListDataProvider milestonesDp = new ListDataProvider(milestones); + DataView milestonesList = new DataView(wicketId, milestonesDp) { private static final long serialVersionUID = 1L; @Override public void populateItem(final Item item) { + Fragment entryPanel = new Fragment("entryPanel", "milestoneListFragment", this); + item.add(entryPanel); + final TicketMilestone tm = item.getModelObject(); - PageParameters params = queryParameters(null, tm.name, null, null, null, desc, 1); - item.add(new LinkPanel("milestoneName", null, tm.name, TicketsPage.class, params).setRenderBodyOnly(true)); + PageParameters params = queryParameters(null, tm.name, null, null, null, true, 1); + entryPanel.add(new LinkPanel("milestoneName", null, tm.name, TicketsPage.class, params).setRenderBodyOnly(true)); String css; String status = tm.status.name(); @@ -699,22 +721,47 @@ public class TicketsPage extends TicketBasePage { } Label stateLabel = new Label("milestoneState", status); WicketUtils.setCssClass(stateLabel, css); - item.add(stateLabel); + entryPanel.add(stateLabel); if (tm.due == null) { - item.add(new Label("milestoneDue", getString("gb.notSpecified"))); + entryPanel.add(new Label("milestoneDue", getString("gb.notSpecified"))); } else { - item.add(WicketUtils.createDatestampLabel("milestoneDue", tm.due, getTimeZone(), getTimeUtils())); + entryPanel.add(WicketUtils.createDatestampLabel("milestoneDue", tm.due, getTimeZone(), getTimeUtils())); } if (acceptingUpdates) { - item.add(new LinkPanel("editMilestone", null, getString("gb.edit"), EditMilestonePage.class, + entryPanel.add(new LinkPanel("editMilestone", null, getString("gb.edit"), EditMilestonePage.class, WicketUtils.newObjectParameter(repositoryName, tm.name))); } else { - item.add(new Label("editMilestone").setVisible(false)); + entryPanel.add(new Label("editMilestone").setVisible(false)); + } + + if (tm.isOpen()) { + // re-load milestone with query results + TicketMilestone m = app().tickets().getMilestone(getRepositoryModel(), tm.name); + + Fragment milestonePanel = new Fragment("milestonePanel", "openMilestoneFragment", this); + Label label = new Label("progress"); + WicketUtils.setCssStyle(label, "width:" + tm.getProgress() + "%;"); + milestonePanel.add(label); + + milestonePanel.add(new LinkPanel("openTickets", null, + MessageFormat.format(getString("gb.nOpenTickets"), m.getOpenTickets()), + TicketsPage.class, + queryParameters(null, tm.name, openStatii, null, null, true, 1))); + + milestonePanel.add(new LinkPanel("closedTickets", null, + MessageFormat.format(getString("gb.nClosedTickets"), m.getClosedTickets()), + TicketsPage.class, + queryParameters(null, tm.name, closedStatii, null, null, true, 1))); + + milestonePanel.add(new Label("totalTickets", MessageFormat.format(getString("gb.nTotalTickets"), m.getTotalTickets()))); + entryPanel.add(milestonePanel); + } else { + entryPanel.add(new Label("milestonePanel").setVisible(false)); } } }; - add(milestonesList); + return milestonesList; } protected PageParameters queryParameters(