To recreate: Create at least 2 SMTP servers Click "Delete" for server 1 => You get a successful message (OK) Click "Delete" for server 2 => You get a successful message (OK) => You get also an alert message about server 1 (KO) The DELETE route is called twice (one per Delete button you clicked)
Created attachment 114434 [details] [review] Bug 27250: Prevent DELETE to be called several times on SMTP servers admin page The on click event is not replaced but added. We must unbind it before adding the second one To recreate: Create at least 2 SMTP servers Click "Delete" for server 1 => You get a successful message (OK) Click "Delete" for server 2 => You get a successful message (OK) => You get also an alert message about server 1 (KO) The DELETE route is called twice (one per Delete button you clicked)
Created attachment 114480 [details] [review] [ALTERNATE] 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
Created attachment 114484 [details] [review] 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>
Created attachment 114569 [details] [review] 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> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Pushed to master for 21.05, thanks to everybody involved!
Pushed to 20.11.x for 20.11.01
Missing dependencies, not backported to 20.05