From f63482a8dafc2398c8825a37cae163565b25910c Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 28 May 2020 11:39:46 -0400 Subject: [PATCH] disable support tickets' 'remove' button while removal is in progress --- www/admin/inner.js | 11 +++++++++-- www/support/ui.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/www/admin/inner.js b/www/admin/inner.js index 98d44d684..2ff62cf1f 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -255,7 +255,10 @@ define([ if (msg.type !== 'TICKET') { return; } if (!$ticket.length) { - $ticket = APP.support.makeTicket($div, content, function () { + $ticket = APP.support.makeTicket($div, content, function (hideButton) { + // the ticket will still be displayed until the worker confirms its deletion + // so make it unclickable in the meantime + hideButton.setAttribute('disabled', true); var error = false; nThen(function (w) { hashesById[id].forEach(function (d) { @@ -267,7 +270,11 @@ define([ })); }); }).nThen(function () { - if (!error) { $ticket.remove(); } + if (!error) { return void $ticket.remove(); } + // if deletion failed then reactivate the button and warn + hideButton.removeAttribute('disabled'); + // and show a generic error message + UI.alert(Messages.error); }); }); } diff --git a/www/support/ui.js b/www/support/ui.js index dda07c657..ac61bfe7f 100644 --- a/www/support/ui.js +++ b/www/support/ui.js @@ -173,7 +173,7 @@ define([ classes: 'btn-danger' }, function() { if (typeof(onHide) !== "function") { return; } - onHide(); + onHide(hide); // XXX }); $(answer).click(function () {