From 95eb208901caa0d9b86c86e9a0013e418d3b3a96 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Sat, 19 Mar 2022 11:13:48 +0000 Subject: [PATCH] Confirmation before deleting subscriptions --- public/js/subscription-manager.js | 15 +++++++++++++-- src/views/subscription-manager.html.ecr | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/public/js/subscription-manager.js b/public/js/subscription-manager.js index 8e49c05..fad4e56 100644 --- a/public/js/subscription-manager.js +++ b/public/js/subscription-manager.js @@ -100,10 +100,21 @@ const component = () => { return `${key}${type}${value}`; }, - action(event, type) { + actionHandler(event, type) { + const id = $(event.currentTarget).closest("tr").attr("sid"); + if (type !== 'delete') return this.action(id, type); + UIkit.modal.confirm('Are you sure you want to delete the subscription? This cannot be undone.', { + labels: { + ok: 'Yes, delete it', + cancel: 'Cancel' + } + }).then(() => { + this.action(id, type); + }); + }, + action(id, type) { if (this.loading) return; this.loading = true; - const id = $(event.currentTarget).closest("tr").attr("sid"); fetch( `${base_url}api/admin/plugin/subscriptions${type === 'update' ? '/update' : ''}?${new URLSearchParams( { diff --git a/src/views/subscription-manager.html.ecr b/src/views/subscription-manager.html.ecr index 02f04e9..b1b49cd 100644 --- a/src/views/subscription-manager.html.ecr +++ b/src/views/subscription-manager.html.ecr @@ -42,8 +42,8 @@ - - + +