Bugzilla – Attachment 114484 Details for
Bug 27250
DELETE calls are stacked on the SMTP servers admin page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27250: Fix stacked event listeners in SMTP delete modal
Bug-27250-Fix-stacked-event-listeners-in-SMTP-dele.patch (text/plain), 4.14 KB, created by
Jonathan Druart
on 2020-12-17 16:00:21 UTC
(
hide
)
Description:
Bug 27250: Fix stacked event listeners in SMTP delete modal
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-12-17 16:00:21 UTC
Size:
4.14 KB
patch
obsolete
>From 1936a5b08be8d8f1331440eaad8bdc009ab35298 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 17 Dec 2020 11:53:16 -0300 >Subject: [PATCH] Bug 27250: Fix stacked event listeners in SMTP delete modal > >There is a design issue on the click event listener that makes the modal >get added new event listeners on each row being deleted. This makes the >page call all the event listeners and generates an error. > >This patch replaces the flawed logic (adding the event listener inside >the event listener). It makes the event listener be defined at startup >time, and make the .on('click') action just pass information around as >required. > >To test: >1. Create at least 2 SMTP servers >2. Open the browser inspector, on the network tab >3. Click "Delete" for server 1 >=> SUCCESS: You get a successful message (OK) >4. Click "Delete" for server 2 >=> SUCCESS: You get a successful message (OK) >=> FAIL: You get also an alert message about server 1 (KO) >=> FAIL: The inspector shows more than one AJAX call has been made >5. Apply this patch and reload the page >6. Repeat 3-4 >=> SUCCESS: Everything goes smooth this time >7. Sign off :-D > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/en/modules/admin/smtp_servers.tt | 37 +++++++++++-------- > 1 file changed, 22 insertions(+), 15 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt >index 66975366db..ca915b2038 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt >@@ -366,23 +366,30 @@ SMTP servers > $("#delete_confirm_dialog").html( > _("You are about to delete the '%s' SMTP server.").format(smtp_server_name) > ); >+ $("#delete_confirm_modal_button").data('smtp-server-id', smtp_server_id); >+ $("#delete_confirm_modal_button").data('smtp-server-name', smtp_server_name); >+ }); > >- $("#delete_confirm_modal_button").on( "click", function () { >- $.ajax({ >- method: "DELETE", >- url: "/api/v1/config/smtp_servers/"+smtp_server_id >- }).success(function() { >- $("#delete_confirm_modal").modal('hide'); >- window.smtp_servers.api().ajax.reload(function (data) { >- if (data.recordsTotal == 0) { >- $("#smtp_servers_wrapper").hide(); >- } >- $("#smtp_action_result_dialog").hide(); >- $("#smtp_delete_success").html(_("Server '%s' deleted successfully.").format(smtp_server_name)).show(); >- }); >- }).error(function () { >- $("#smtp_delete_error").html(_("Error deleting server '%s'. Check the logs.").format(smtp_server_name)).show(); >+ $("#delete_confirm_modal_button").on( "click", function () { >+ >+ var smtp_server_id = $(this).data('smtp-server-id'); >+ var smtp_server_name = $(this).data('smtp-server-name'); >+ >+ $.ajax({ >+ method: "DELETE", >+ url: "/api/v1/config/smtp_servers/"+smtp_server_id >+ }).success(function() { >+ window.smtp_servers.api().ajax.reload(function (data) { >+ if (data.recordsTotal == 0) { >+ $("#smtp_servers_wrapper").hide(); >+ } >+ $("#smtp_action_result_dialog").hide(); >+ $("#smtp_delete_success").html(_("Server '%s' deleted successfully.").format(smtp_server_name)).show(); > }); >+ }).fail(function () { >+ $("#smtp_delete_error").html(_("Error deleting server '%s'. Check the logs.").format(smtp_server_name)).show(); >+ }).done(function () { >+ $("#delete_confirm_modal").modal('hide'); > }); > }); > }); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27250
:
114434
|
114480
|
114484
|
114569