summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/wicket/pages
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-03-05 11:41:34 -0500
committerJames Moger <james.moger@gitblit.com>2014-03-05 11:42:34 -0500
commit85775acd760c668a73f9febf80009832ddf91af9 (patch)
treeb184d4e35e1cfe9f10443b919755c589bc6698ad /src/main/java/com/gitblit/wicket/pages
parent0353c1fc521826c57a318affec4fbec7aa3b71e9 (diff)
downloadgitblit-85775acd760c668a73f9febf80009832ddf91af9.tar.gz
gitblit-85775acd760c668a73f9febf80009832ddf91af9.zip
Delegate closed ticket changes to the Edit Ticket page
Diffstat (limited to 'src/main/java/com/gitblit/wicket/pages')
-rw-r--r--src/main/java/com/gitblit/wicket/pages/TicketPage.html15
-rw-r--r--src/main/java/com/gitblit/wicket/pages/TicketPage.java283
2 files changed, 160 insertions, 138 deletions
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</pre>
</wicket:fragment>
-<!-- TICKET CONTROLS FRAGMENT -->
-<wicket:fragment wicket:id="controlsFragment">
+<!-- OPEN TICKET CONTROLS FRAGMENT -->
+<wicket:fragment wicket:id="openControlsFragment">
<div class="hidden-phone hidden-tablet">
<div class="btn-group" style="display:inline-block;">
<a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#"><wicket:message key="gb.status"></wicket:message> <span class="caret"></span></a>
@@ -167,6 +167,17 @@ pt push</pre>
</wicket:fragment>
+<!-- CLOSED TICKET CONTROLS FRAGMENT -->
+<wicket:fragment wicket:id="closedControlsFragment">
+ <div class="hidden-phone hidden-tablet">
+
+ <div class="btn-group" style="display:inline-block;">
+ <a class="btn btn-small" wicket:id="editLink"></a>
+ </div>
+ </div>
+</wicket:fragment>
+
+
<!-- STATUS INDICATOR FRAGMENT -->
<wicket:fragment wicket:id="ticketStatusFragment">
<div style="font-size:2.5em;padding-bottom: 5px;">
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<Status> choices = new ArrayList<Status>();
- 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<Status> choices = new ArrayList<Status>();
+ 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<Status> workflowDp = new ListDataProvider<Status>(choices);
- DataView<Status> statusView = new DataView<Status>("newStatus", workflowDp) {
- private static final long serialVersionUID = 1L;
+ ListDataProvider<Status> workflowDp = new ListDataProvider<Status>(choices);
+ DataView<Status> statusView = new DataView<Status>("newStatus", workflowDp) {
+ private static final long serialVersionUID = 1L;
- @Override
- public void populateItem(final Item<Status> item) {
- SimpleAjaxLink<Status> link = new SimpleAjaxLink<Status>("link", item.getModel()) {
+ @Override
+ public void populateItem(final Item<Status> item) {
+ SimpleAjaxLink<Status> link = new SimpleAjaxLink<Status>("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<String> userlist = new TreeSet<String>(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<String> userlist = new TreeSet<String>(ticket.getParticipants());
- for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {
- if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) {
- userlist.add(rp.registrant);
+ List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();
+ if (!StringUtils.isEmpty(ticket.responsible)) {
+ // exclude the current responsible
+ userlist.remove(ticket.responsible);
}
- }
- List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();
- 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<TicketResponsible> responsibleDp = new ListDataProvider<TicketResponsible>(responsibles);
- DataView<TicketResponsible> responsibleView = new DataView<TicketResponsible>("newResponsible", responsibleDp) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void populateItem(final Item<TicketResponsible> item) {
- SimpleAjaxLink<TicketResponsible> link = new SimpleAjaxLink<TicketResponsible>("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<TicketResponsible> responsibleDp = new ListDataProvider<TicketResponsible>(responsibles);
+ DataView<TicketResponsible> responsibleView = new DataView<TicketResponsible>("newResponsible", responsibleDp) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void populateItem(final Item<TicketResponsible> item) {
+ SimpleAjaxLink<TicketResponsible> link = new SimpleAjaxLink<TicketResponsible>("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<TicketMilestone> 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<TicketMilestone> 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<TicketMilestone> milestoneDp = new ListDataProvider<TicketMilestone>(milestones);
- DataView<TicketMilestone> milestoneView = new DataView<TicketMilestone>("newMilestone", milestoneDp) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void populateItem(final Item<TicketMilestone> item) {
- SimpleAjaxLink<TicketMilestone> link = new SimpleAjaxLink<TicketMilestone>("link", item.getModel()) {
+ milestones.add(new TicketMilestone(ESC_NIL));
+ ListDataProvider<TicketMilestone> milestoneDp = new ListDataProvider<TicketMilestone>(milestones);
+ DataView<TicketMilestone> milestoneView = new DataView<TicketMilestone>("newMilestone", milestoneDp) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void populateItem(final Item<TicketMilestone> item) {
+ SimpleAjaxLink<TicketMilestone> link = new SimpleAjaxLink<TicketMilestone>("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));
}