From 85775acd760c668a73f9febf80009832ddf91af9 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 5 Mar 2014 11:41:34 -0500 Subject: Delegate closed ticket changes to the Edit Ticket page --- .../java/com/gitblit/wicket/pages/TicketPage.html | 15 +- .../java/com/gitblit/wicket/pages/TicketPage.java | 283 +++++++++++---------- 2 files changed, 160 insertions(+), 138 deletions(-) (limited to 'src') diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.html b/src/main/java/com/gitblit/wicket/pages/TicketPage.html index 2e0288a5..6fcf96c8 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.html +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.html @@ -136,8 +136,8 @@ pt push - - + +
@@ -167,6 +167,17 @@ pt push + + +
+ +
+ +
+
+
+ +
diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.java b/src/main/java/com/gitblit/wicket/pages/TicketPage.java index 07382ad9..3f92eaa0 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.java @@ -328,159 +328,170 @@ public class TicketPage extends TicketBasePage { * UPDATE FORM (DISCUSSION TAB) */ if (isAuthenticated && app().tickets().isAcceptingTicketUpdates(repository)) { - Fragment controls = new Fragment("controls", "controlsFragment", this); - - - /* - * STATUS - */ - List choices = new ArrayList(); - if (ticket.isClosed()) { - // re-open - choices.addAll(Arrays.asList(TicketModel.Status.Open)); - } else if (ticket.isProposal()) { - choices.addAll(Arrays.asList(TicketModel.Status.proposalWorkflow)); - } else if (ticket.isBug()) { - choices.addAll(Arrays.asList(TicketModel.Status.bugWorkflow)); - } else { - choices.addAll(Arrays.asList(TicketModel.Status.requestWorkflow)); - } - choices.remove(ticket.status); + if (ticket.isOpen()) { + /* + * OPEN TICKET + */ + Fragment controls = new Fragment("controls", "openControlsFragment", this); + + /* + * STATUS + */ + List choices = new ArrayList(); + if (ticket.isProposal()) { + choices.addAll(Arrays.asList(TicketModel.Status.proposalWorkflow)); + } else if (ticket.isBug()) { + choices.addAll(Arrays.asList(TicketModel.Status.bugWorkflow)); + } else { + choices.addAll(Arrays.asList(TicketModel.Status.requestWorkflow)); + } + choices.remove(ticket.status); - ListDataProvider workflowDp = new ListDataProvider(choices); - DataView statusView = new DataView("newStatus", workflowDp) { - private static final long serialVersionUID = 1L; + ListDataProvider workflowDp = new ListDataProvider(choices); + DataView statusView = new DataView("newStatus", workflowDp) { + private static final long serialVersionUID = 1L; - @Override - public void populateItem(final Item item) { - SimpleAjaxLink link = new SimpleAjaxLink("link", item.getModel()) { + @Override + public void populateItem(final Item item) { + SimpleAjaxLink link = new SimpleAjaxLink("link", item.getModel()) { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override - public void onClick(AjaxRequestTarget target) { - Status status = getModel().getObject(); - Change change = new Change(user.username); - change.setField(Field.status, status); - if (!ticket.isWatching(user.username)) { - change.watch(user.username); + @Override + public void onClick(AjaxRequestTarget target) { + Status status = getModel().getObject(); + Change change = new Change(user.username); + change.setField(Field.status, status); + if (!ticket.isWatching(user.username)) { + change.watch(user.username); + } + TicketModel update = app().tickets().updateTicket(repository, ticket.number, change); + app().tickets().createNotifier().sendMailing(update); + setResponsePage(TicketsPage.class, getPageParameters()); } - TicketModel update = app().tickets().updateTicket(repository, ticket.number, change); - app().tickets().createNotifier().sendMailing(update); - setResponsePage(TicketsPage.class, getPageParameters()); - } - }; - String css = getStatusClass(item.getModel().getObject()); - WicketUtils.setCssClass(link, css); - item.add(link); + }; + String css = getStatusClass(item.getModel().getObject()); + WicketUtils.setCssClass(link, css); + item.add(link); + } + }; + controls.add(statusView); + + /* + * RESPONSIBLE LIST + */ + Set userlist = new TreeSet(ticket.getParticipants()); + for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) { + if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) { + userlist.add(rp.registrant); + } } - }; - controls.add(statusView); - - /* - * RESPONSIBLE LIST - */ - Set userlist = new TreeSet(ticket.getParticipants()); - for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) { - if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) { - userlist.add(rp.registrant); + List responsibles = new ArrayList(); + if (!StringUtils.isEmpty(ticket.responsible)) { + // exclude the current responsible + userlist.remove(ticket.responsible); } - } - List responsibles = new ArrayList(); - if (!StringUtils.isEmpty(ticket.responsible)) { - // exclude the current responsible - userlist.remove(ticket.responsible); - } - for (String username : userlist) { - UserModel u = app().users().getUserModel(username); - if (u != null) { - responsibles.add(new TicketResponsible(u)); + for (String username : userlist) { + UserModel u = app().users().getUserModel(username); + if (u != null) { + responsibles.add(new TicketResponsible(u)); + } } - } - Collections.sort(responsibles); - responsibles.add(new TicketResponsible(ESC_NIL, "", "")); - ListDataProvider responsibleDp = new ListDataProvider(responsibles); - DataView responsibleView = new DataView("newResponsible", responsibleDp) { - private static final long serialVersionUID = 1L; - - @Override - public void populateItem(final Item item) { - SimpleAjaxLink link = new SimpleAjaxLink("link", item.getModel()) { - - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - TicketResponsible responsible = getModel().getObject(); - Change change = new Change(user.username); - change.setField(Field.responsible, responsible.username); - if (!StringUtils.isEmpty(responsible.username)) { - if (!ticket.isWatching(responsible.username)) { - change.watch(responsible.username); + Collections.sort(responsibles); + responsibles.add(new TicketResponsible(ESC_NIL, "", "")); + ListDataProvider responsibleDp = new ListDataProvider(responsibles); + DataView responsibleView = new DataView("newResponsible", responsibleDp) { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final Item item) { + SimpleAjaxLink link = new SimpleAjaxLink("link", item.getModel()) { + + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + TicketResponsible responsible = getModel().getObject(); + Change change = new Change(user.username); + change.setField(Field.responsible, responsible.username); + if (!StringUtils.isEmpty(responsible.username)) { + if (!ticket.isWatching(responsible.username)) { + change.watch(responsible.username); + } } + if (!ticket.isWatching(user.username)) { + change.watch(user.username); + } + TicketModel update = app().tickets().updateTicket(repository, ticket.number, change); + app().tickets().createNotifier().sendMailing(update); + setResponsePage(TicketsPage.class, getPageParameters()); } - if (!ticket.isWatching(user.username)) { - change.watch(user.username); - } - TicketModel update = app().tickets().updateTicket(repository, ticket.number, change); - app().tickets().createNotifier().sendMailing(update); - setResponsePage(TicketsPage.class, getPageParameters()); + }; + item.add(link); + } + }; + controls.add(responsibleView); + + /* + * MILESTONE LIST + */ + List milestones = app().tickets().getMilestones(repository, Status.Open); + if (!StringUtils.isEmpty(ticket.milestone)) { + for (TicketMilestone milestone : milestones) { + if (milestone.name.equals(ticket.milestone)) { + milestones.remove(milestone); + break; } - }; - item.add(link); - } - }; - controls.add(responsibleView); - - /* - * MILESTONE LIST - */ - List milestones = app().tickets().getMilestones(repository, Status.Open); - if (!StringUtils.isEmpty(ticket.milestone)) { - for (TicketMilestone milestone : milestones) { - if (milestone.name.equals(ticket.milestone)) { - milestones.remove(milestone); - break; } } - } - milestones.add(new TicketMilestone(ESC_NIL)); - ListDataProvider milestoneDp = new ListDataProvider(milestones); - DataView milestoneView = new DataView("newMilestone", milestoneDp) { - private static final long serialVersionUID = 1L; - - @Override - public void populateItem(final Item item) { - SimpleAjaxLink link = new SimpleAjaxLink("link", item.getModel()) { + milestones.add(new TicketMilestone(ESC_NIL)); + ListDataProvider milestoneDp = new ListDataProvider(milestones); + DataView milestoneView = new DataView("newMilestone", milestoneDp) { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final Item item) { + SimpleAjaxLink link = new SimpleAjaxLink("link", item.getModel()) { + + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) { + TicketMilestone milestone = getModel().getObject(); + Change change = new Change(user.username); + if (NIL.equals(milestone.name) || ESC_NIL.equals(milestone.name)) { + change.setField(Field.milestone, ""); + } else { + change.setField(Field.milestone, milestone.name); + } + if (!ticket.isWatching(user.username)) { + change.watch(user.username); + } + TicketModel update = app().tickets().updateTicket(repository, ticket.number, change); + app().tickets().createNotifier().sendMailing(update); + setResponsePage(TicketsPage.class, getPageParameters()); + } + }; + item.add(link); + } + }; + controls.add(milestoneView); - private static final long serialVersionUID = 1L; + String editHref = urlFor(EditTicketPage.class, params).toString(); + controls.add(new ExternalLink("editLink", editHref, getString("gb.edit"))); - @Override - public void onClick(AjaxRequestTarget target) { - TicketMilestone milestone = getModel().getObject(); - Change change = new Change(user.username); - if (NIL.equals(milestone.name) || ESC_NIL.equals(milestone.name)) { - change.setField(Field.milestone, ""); - } else { - change.setField(Field.milestone, milestone.name); - } - if (!ticket.isWatching(user.username)) { - change.watch(user.username); - } - TicketModel update = app().tickets().updateTicket(repository, ticket.number, change); - app().tickets().createNotifier().sendMailing(update); - setResponsePage(TicketsPage.class, getPageParameters()); - } - }; - item.add(link); - } - }; - controls.add(milestoneView); + add(controls); + } else { + /* + * CLOSED TICKET + */ + Fragment controls = new Fragment("controls", "closedControlsFragment", this); - String editHref = urlFor(EditTicketPage.class, params).toString(); - controls.add(new ExternalLink("editLink", editHref, getString("gb.edit"))); + String editHref = urlFor(EditTicketPage.class, params).toString(); + controls.add(new ExternalLink("editLink", editHref, getString("gb.edit"))); - add(controls); + add(controls); + } } else { add(new Label("controls").setVisible(false)); } -- cgit v1.2.3