From db040113c4c3b450b535360624baa6053599ad43 Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 9 May 2014 08:00:14 -0400 Subject: [PATCH] Add confirm milestone deletion prompt --- .../com/gitblit/wicket/GitBlitWebApp.properties | 2 ++ .../gitblit/wicket/pages/EditMilestonePage.java | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties index d0c2d48c..12430ade 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties @@ -676,6 +676,8 @@ gb.myTickets = my tickets gb.yourAssignedTickets = assigned to you gb.newMilestone = new milestone gb.editMilestone = edit milestone +gb.deleteMilestone = Delete milestone \"{0}\"? +gb.milestoneDeleteFailed = Failed to delete milestone ''{0}''! gb.notifyChangedOpenTickets = send notification for changed open tickets gb.overdue = overdue gb.openMilestones = open milestones diff --git a/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java b/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java index d6f58e7b..4ed77d83 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java @@ -15,6 +15,7 @@ */ package com.gitblit.wicket.pages; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -30,6 +31,7 @@ import org.apache.wicket.markup.html.form.CheckBox; import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; @@ -41,6 +43,7 @@ import com.gitblit.tickets.TicketMilestone; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.panels.BasePanel.JavascriptEventConfirmation; /** * Page for creating a new milestone. @@ -157,11 +160,12 @@ public class EditMilestonePage extends RepositoryPage { cancel.setDefaultFormProcessing(false); form.add(cancel); - Button delete = new Button("delete") { + Link delete = new Link("delete") { + private static final long serialVersionUID = 1L; @Override - public void onSubmit() { + public void onClick() { UserModel currentUser = GitBlitWebSession.get().getUser(); String createdBy = currentUser.username; boolean notify = notificationModel.getObject(); @@ -169,11 +173,14 @@ public class EditMilestonePage extends RepositoryPage { if (app().tickets().deleteMilestone(getRepositoryModel(), oldName, createdBy, notify)) { setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } else { - // TODO error processing + error(MessageFormat.format(getString("gb.milestoneDeleteFailed"), oldName)); } } }; - delete.setDefaultFormProcessing(false); + + delete.add(new JavascriptEventConfirmation("onclick", MessageFormat.format( + getString("gb.deleteMilestone"), oldName))); + form.add(delete); } -- 2.39.5