Bug 36327 - Items view - Deletion of items is broken
Summary: Items view - Deletion of items is broken
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Pedro Amorim
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 36192
  Show dependency treegraph
 
Reported: 2024-03-15 10:05 UTC by Pedro Amorim
Modified: 2024-04-17 15:02 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00


Attachments
Bug 36327: Preparation: Update form (2.30 KB, patch)
2024-03-15 10:55 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 36327: Clean-up old unused code that results in error (1.25 KB, patch)
2024-03-15 10:55 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 36327: Delete link is no longer a GET href (1.45 KB, patch)
2024-03-15 10:55 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 36327: Update handling of item delete (2.41 KB, patch)
2024-03-15 10:55 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 36327: Preparation: Update form (2.38 KB, patch)
2024-03-15 13:01 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 36327: Clean-up old unused code that results in error (1.32 KB, patch)
2024-03-15 13:01 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 36327: Delete link is no longer a GET href (1.53 KB, patch)
2024-03-15 13:01 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 36327: Update handling of item delete (2.48 KB, patch)
2024-03-15 13:01 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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