Bug 36327

Summary: Items view - Deletion of items is broken
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: CatalogingAssignee: Pedro Amorim <pedro.amorim>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, m.de.rooy, martin.renvoize, nick, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36326
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00
Circulation function:
Bug Depends on:    
Bug Blocks: 36192    
Attachments: Bug 36327: Preparation: Update form
Bug 36327: Clean-up old unused code that results in error
Bug 36327: Delete link is no longer a GET href
Bug 36327: Update handling of item delete
Bug 36327: Preparation: Update form
Bug 36327: Clean-up old unused code that results in error
Bug 36327: Delete link is no longer a GET href
Bug 36327: Update handling of item delete

Description Pedro Amorim 2024-03-15 10:05:12 UTC
k-t-d
1) visit a biblio details view:
http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=230
2) Click anywhere on one of the items rows
3) Notice 2 actions show up "Edit item" and "Delete item"
4) Click "delete item"
5) Notice nothing happens in the UI
6) Notice console throws the following error:
cataloging_additem_23.1200007.js:29 Uncaught ReferenceError: confirm_deletion is not defined
    at HTMLAnchorElement.<anonymous> (cataloging_additem_23.1200007.js:29:17)
    at HTMLAnchorElement.dispatch (jquery-3.6.0.min_23.1200007.js:2:43064)
    at v.handle (jquery-3.6.0.min_23.1200007.js:2:41048)
Comment 1 Pedro Amorim 2024-03-15 10:55:34 UTC
Created attachment 163195 [details] [review]
Bug 36327: Preparation: Update form

Each delete form now contains the itemnumber to better unambiguosly identify the the itemnumber it refers to
The delete button now carries the itemnumber it refers to
Comment 2 Pedro Amorim 2024-03-15 10:55:38 UTC
Created attachment 163196 [details] [review]
Bug 36327: Clean-up old unused code that results in error
Comment 3 Pedro Amorim 2024-03-15 10:55:41 UTC
Created attachment 163197 [details] [review]
Bug 36327: Delete link is no longer a GET href
Comment 4 Pedro Amorim 2024-03-15 10:55:45 UTC
Created attachment 163198 [details] [review]
Bug 36327: Update handling of item delete

This needs to be rewritten to .on('click') because the delete item link relevant to this patchset is appended to the dom, this is how we guarantee this event listener is attached to the appended link.
This also ensures the same item deletion logic is applied for both button: The delete button from the left 'Actions' dropdown and the 'Delete item' link that pops up when anywhere in the row is clicked

1) visit a biblio details view:
http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=230
2) Click anywhere on one of the items rows
3) Notice 2 actions show up "Edit item" and "Delete item"
4) Click "delete item"
5) Notice nothing happens in the UI
6) Notice console throws the following error:
cataloging_additem_23.1200007.js:29 Uncaught ReferenceError: confirm_deletion is not defined
    at HTMLAnchorElement.<anonymous> (cataloging_additem_23.1200007.js:29:17)
    at HTMLAnchorElement.dispatch (jquery-3.6.0.min_23.1200007.js:2:43064)
    at v.handle (jquery-3.6.0.min_23.1200007.js:2:41048)
7) Apply patches
8) Notice console error no longer shows
9) Notice delete confirmation is shown, notice clicking it deletes the correct item.
10) Notice the delete item link anywhere in the item row has the same behavior as the 'Delete' option under 'Actions' on the leftmost column of the table
Comment 5 Jonathan Druart 2024-03-15 13:01:03 UTC
Created attachment 163228 [details] [review]
Bug 36327: Preparation: Update form

Each delete form now contains the itemnumber to better unambiguosly identify the the itemnumber it refers to
The delete button now carries the itemnumber it refers to

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2024-03-15 13:01:06 UTC
Created attachment 163229 [details] [review]
Bug 36327: Clean-up old unused code that results in error

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Jonathan Druart 2024-03-15 13:01:08 UTC
Created attachment 163230 [details] [review]
Bug 36327: Delete link is no longer a GET href

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Jonathan Druart 2024-03-15 13:01:11 UTC
Created attachment 163231 [details] [review]
Bug 36327: Update handling of item delete

This needs to be rewritten to .on('click') because the delete item link relevant to this patchset is appended to the dom, this is how we guarantee this event listener is attached to the appended link.
This also ensures the same item deletion logic is applied for both button: The delete button from the left 'Actions' dropdown and the 'Delete item' link that pops up when anywhere in the row is clicked

1) visit a biblio details view:
http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=230
2) Click anywhere on one of the items rows
3) Notice 2 actions show up "Edit item" and "Delete item"
4) Click "delete item"
5) Notice nothing happens in the UI
6) Notice console throws the following error:
cataloging_additem_23.1200007.js:29 Uncaught ReferenceError: confirm_deletion is not defined
    at HTMLAnchorElement.<anonymous> (cataloging_additem_23.1200007.js:29:17)
    at HTMLAnchorElement.dispatch (jquery-3.6.0.min_23.1200007.js:2:43064)
    at v.handle (jquery-3.6.0.min_23.1200007.js:2:41048)
7) Apply patches
8) Notice console error no longer shows
9) Notice delete confirmation is shown, notice clicking it deletes the correct item.
10) Notice the delete item link anywhere in the item row has the same behavior as the 'Delete' option under 'Actions' on the leftmost column of the table

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Katrin Fischer 2024-03-20 17:33:40 UTC
There are some new and some pre-existing translatability issues with this one, I filed a separate bug:
Bug 36377 - Fix translatability issues in koha-backend.js
Comment 10 Katrin Fischer 2024-03-20 17:40:33 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 11 Fridolin Somers 2024-03-21 14:01:32 UTC
Does this depend on Bug 34478 ?
Comment 12 Pedro Amorim 2024-03-25 11:00:08 UTC
(In reply to Fridolin Somers from comment #11)
> Does this depend on Bug 34478 ?

I set this as blocking bug 36192 to relate to the CSRF.
I'm unsure and confused as what it should be, block bug 36192 or depend on bug 34478?
Comment 13 Fridolin Somers 2024-04-17 15:02:56 UTC
I dont reproduce on 23.11.x so surely depend on bug 34478
I dont backport