From e803737a4b48f201bcd95515286b36544a562bc1 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 25 Aug 2021 10:12:43 -0400 Subject: [PATCH] feat: add confirmation modal to topic event deletion --- public/language/en-GB/topic.json | 1 + public/src/client/topic/threadTools.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/public/language/en-GB/topic.json b/public/language/en-GB/topic.json index 0b431d12ba..4502452aa0 100644 --- a/public/language/en-GB/topic.json +++ b/public/language/en-GB/topic.json @@ -24,6 +24,7 @@ "edit": "Edit", "delete": "Delete", "delete-event": "Delete Event", + "delete-event-confirm": "Are you sure you want to delete this event?", "purge": "Purge", "restore": "Restore", "move": "Move", diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index f49d1f9b62..b678c6f3cc 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -53,12 +53,15 @@ define('forum/topic/threadTools', [ topicContainer.on('click', '[component="topic/event/delete"]', function () { const eventId = $(this).attr('data-topic-event-id'); const eventEl = $(this).parents('[component="topic/event"]'); - api.del(`/topics/${tid}/events/${eventId}`, {}) - .then(function () { - eventEl.remove(); - }) - .catch(app.alertError); - return false; + bootbox.confirm('[[topic:delete-event-confirm]]', (ok) => { + if (ok) { + api.del(`/topics/${tid}/events/${eventId}`, {}) + .then(function () { + eventEl.remove(); + }) + .catch(app.alertError); + } + }) }); // todo: should also use topicCommand, but no write api call exists for this yet