Bug 17387 - Add an undelete feature for items/biblios
Summary: Add an undelete feature for items/biblios
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jacob O'Mara
QA Contact: Nick Clemens (kidclamp)
URL: https://github.com/Jacobomara901/Koha...
Keywords:
: 13556 (view as bug list)
Depends on:
Blocks: 41295
  Show dependency treegraph
 
Reported: 2016-09-30 21:01 UTC by Nick Clemens (kidclamp)
Modified: 2025-11-25 05:48 UTC (History)
29 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 17387: add restore functionality to Old::Biblio/Item (4.72 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted items restore api (11.34 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted biblios restore api (2.86 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: update swagger for deleted biblios/items restore (964 bytes, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore item/biblio tests (8.96 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: reindex biblio/item on restore (2.66 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: item cannot be restored if associated biblio does not exist (3.23 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records page (16.51 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add pagination headers and support comma-delimited Accept headers (2.34 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add biblio embed to deleteditems return (2.36 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal warning for items with deleted biblios (5.71 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add items embed to deleted biblios API (1.85 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal for restoring biblios with item selection (14.93 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add sidebar date filtering for item/biblio restore (5.97 KB, patch)
2025-10-30 16:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add links for restore item/biblio to cataloguing (2.64 KB, patch)
2025-10-30 16:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records permission as child of cataloguing perms (4.62 KB, patch)
2025-10-30 16:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore functionality to Old::Biblio/Item (4.72 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted items restore api (11.34 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted biblios restore api (2.86 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: update swagger for deleted biblios/items restore (964 bytes, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore item/biblio tests (8.96 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: reindex biblio/item on restore (2.66 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: item cannot be restored if associated biblio does not exist (3.23 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records page (16.51 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add pagination headers and support comma-delimited Accept headers (2.34 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add biblio embed to deleteditems return (2.36 KB, patch)
2025-10-30 17:38 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal warning for items with deleted biblios (5.41 KB, patch)
2025-10-30 17:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add items embed to deleted biblios API (1.85 KB, patch)
2025-10-30 17:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal for restoring biblios with item selection (13.73 KB, patch)
2025-10-30 17:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add sidebar date filtering for item/biblio restore (5.97 KB, patch)
2025-10-30 17:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add links for restore item/biblio to cataloguing (2.64 KB, patch)
2025-10-30 17:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records permission as child of cataloguing perms (4.62 KB, patch)
2025-10-30 17:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore functionality to Old::Biblio/Item (4.77 KB, patch)
2025-10-31 09:50 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add deleted items restore api (11.38 KB, patch)
2025-10-31 09:50 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add deleted biblios restore api (2.90 KB, patch)
2025-10-31 09:50 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: update swagger for deleted biblios/items restore (1012 bytes, patch)
2025-10-31 09:50 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add restore item/biblio tests (9.00 KB, patch)
2025-10-31 09:50 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: reindex biblio/item on restore (2.70 KB, patch)
2025-10-31 09:50 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: item cannot be restored if associated biblio does not exist (3.27 KB, patch)
2025-10-31 09:50 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add restore records page (16.55 KB, patch)
2025-10-31 09:50 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add pagination headers and support comma-delimited Accept headers (2.39 KB, patch)
2025-10-31 09:51 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add biblio embed to deleteditems return (2.40 KB, patch)
2025-10-31 09:51 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add modal warning for items with deleted biblios (5.46 KB, patch)
2025-10-31 09:51 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add items embed to deleted biblios API (1.90 KB, patch)
2025-10-31 09:51 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add modal for restoring biblios with item selection (13.78 KB, patch)
2025-10-31 09:51 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add sidebar date filtering for item/biblio restore (6.01 KB, patch)
2025-10-31 09:51 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add links for restore item/biblio to cataloguing (2.68 KB, patch)
2025-10-31 09:51 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add restore records permission as child of cataloguing perms (4.66 KB, patch)
2025-10-31 09:51 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 17387: add restore functionality to Old::Biblio/Item (4.72 KB, patch)
2025-11-04 19:34 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted items restore api (11.34 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted biblios restore api (2.86 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: update swagger for deleted biblios/items restore (964 bytes, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore item/biblio tests (8.96 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: reindex biblio/item on restore (2.66 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: item cannot be restored if associated biblio does not exist (3.23 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records page (16.51 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add pagination headers and support comma-delimited Accept headers (2.34 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add biblio embed to deleteditems return (2.36 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal warning for items with deleted biblios (5.41 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add items embed to deleted biblios API (1.85 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal for restoring biblios with item selection (13.79 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add sidebar date filtering for item/biblio restore (5.97 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add links for restore item/biblio to cataloguing (3.92 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records permission as child of cataloguing perms (5.10 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add logging for biblio/item restore (5.93 KB, patch)
2025-11-04 19:35 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore functionality to Old::Biblio/Item (4.72 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted items restore api (11.34 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted biblios restore api (2.86 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: update swagger for deleted biblios/items restore (964 bytes, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore item/biblio tests (8.96 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: reindex biblio/item on restore (2.66 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: item cannot be restored if associated biblio does not exist (3.23 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records page (16.51 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add pagination headers and support comma-delimited Accept headers (2.34 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add biblio embed to deleteditems return (2.36 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal warning for items with deleted biblios (5.41 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add items embed to deleted biblios API (1.85 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal for restoring biblios with item selection (13.79 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add sidebar date filtering for item/biblio restore (5.97 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add links for restore item/biblio to cataloguing (3.92 KB, patch)
2025-11-05 15:39 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records permission as child of cataloguing perms (5.10 KB, patch)
2025-11-05 15:40 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add logging for biblio/item restore (5.93 KB, patch)
2025-11-05 15:40 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: (follow-up) take library groups in to account for permissions check (12.70 KB, patch)
2025-11-05 15:40 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: (follow-up) restore tests should account for new library groups checks (8.90 KB, patch)
2025-11-05 15:40 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore functionality to Old::Biblio/Item (4.72 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted items restore api (11.34 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add deleted biblios restore api (2.86 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: update swagger for deleted biblios/items restore (964 bytes, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore item/biblio tests (8.96 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: reindex biblio/item on restore (2.66 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: item cannot be restored if associated biblio does not exist (3.23 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records page (16.51 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add pagination headers and support comma-delimited Accept headers (2.34 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add biblio embed to deleteditems return (2.36 KB, patch)
2025-11-05 15:59 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal warning for items with deleted biblios (5.41 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add items embed to deleted biblios API (1.85 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add modal for restoring biblios with item selection (13.79 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add sidebar date filtering for item/biblio restore (5.97 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add links for restore item/biblio to cataloguing (3.92 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add restore records permission as child of cataloguing perms (5.10 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: add logging for biblio/item restore (5.93 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: (follow-up) take library groups in to account for permissions check (12.83 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review
Bug 17387: (follow-up) restore tests should account for new library groups checks (8.90 KB, patch)
2025-11-05 16:00 UTC, Jacob O'Mara
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2016-09-30 21:01:34 UTC
Some libraries would like to be able to restore items accidentally deleted. 

This should be possible, rows can be copied over as long as there are checks in place for unique ids.
Comment 1 George Williams (NEKLS) 2017-12-01 21:03:43 UTC
This is a great idea.
Comment 2 Rocio Dressler 2018-04-05 17:47:56 UTC
Agreed! I've heard interest in this feature from other libraries.
Comment 3 davewood 2023-04-14 09:22:21 UTC
I have written this code already and would like to add the feature.
Comment 4 David Cook 2023-04-16 23:57:32 UTC
(In reply to davewood from comment #3)
> I have written this code already and would like to add the feature.

If you haven't already, take a look at the following:

https://koha-community.org/get-involved/for-developers/

If you need help attaching patches, I'd suggest hopping on IRC or the Koha Developers List: https://koha-community.org/support/
Comment 5 Katrin Fischer 2023-06-30 08:28:58 UTC
We'd be also interested in this. Items seem a little less complicated, maybe they would make a good starting point.
Comment 6 Katrin Fischer 2023-06-30 17:12:35 UTC
*** Bug 13556 has been marked as a duplicate of this bug. ***
Comment 7 Michaela Sieber 2024-08-27 11:19:13 UTC
Yes, this should be a core feature!

Maybe the InLibro Plugin is a good start ?

https://github.com/inLibro/koha-plugin-undelete-records
Comment 8 David Cook 2024-09-04 23:48:32 UTC
(In reply to Michaela Sieber from comment #7)
> Yes, this should be a core feature!
> 
> Maybe the InLibro Plugin is a good start ?
> 
> https://github.com/inLibro/koha-plugin-undelete-records

I ended up using this as inspiration for a pure SQL undelete for 1 bib record (and attached items) I needed to undelete. 

I should look at biblio_metadata again, as it seems that the ID wasn't able to be restored. Had to use a new ID... which is reminiscent of that autoincrement bug. Hmm... it was an old database. (I noticed the InLibro code also gets a new ID for restoring biblio_metadata, so must be a more common issue?)
Comment 9 David Cook 2024-09-04 23:50:14 UTC
Of course, "undelete" only works for the bib record and items themselves. Other tables using foreign keys will have cascading deletes. So the data in the "linktracker" table for instance cannot be restored. It's permanently deleted. 

Given how many people seem to accidentally delete things... I reckon that soft delete feature would be handy. (Of course, it would be a mountain of work to refactor Koha to handle soft deletes...)
Comment 10 Enica Davis 2024-10-10 14:03:07 UTC
Plug-in for InLibro also doesn't work for 24.05. :(

We are still getting a lot of request about this from libraries.
Comment 11 Joseph Alway 2025-02-27 21:46:49 UTC
Some sort of undelete function would be great. However, I can just pull the record from an old backup of our catalog. Thankfully I've not needed to do this very often.
Comment 12 Jacob O'Mara 2025-10-30 16:38:07 UTC
Created attachment 188670 [details] [review]
Bug 17387: add restore functionality to Old::Biblio/Item

TEST PLAN: Item/Biblio Undelete Feature

  SETUP:
  - Apply patches and update database
  - Give test user "Restore deleted records" permission under Cataloging
permissions
  - Delete at least one bibliographic record with items attached
  - Delete at least one standalone item

  TESTING:

  Navigate to Cataloging:
  - Go to Cataloging home page
  - Click "Restore deleted records" link (should be visible with
permission)

  Test Restore Records Page:
  - Verify two tables appear: "Deleted bibliographic records" and
"Deleted items"
  - Verify deleted records appear in tables with biblio ID, title,
barcode, deleted date

  Test Date Filtering:
  - In left sidebar, enter date range in "Deleted from" and "Deleted to"
fields
  - Click "Apply" button - tables should filter by date range
  - Click "Clear" button - filter should reset

  Test Item Restore:
  - Find a deleted item in the items table (with existing biblio)
  - Click "Restore" button in Actions column
  - Verify success message appears and item disappears from table
  - Search catalog for the restored item - confirm it's back

  Test Biblio Warning Modal:
  - Find a deleted item whose biblio is also deleted
  - Click "Restore" button on the item
  - Modal appears warning "bibliographic record is deleted"
  - Click "Restore biblio" - biblio restores, modal closes
  - Click "Restore" on the item again - item now restores successfully
  - Verify both records are back in catalog

  Test Biblio with Items Restore:
  - Find deleted biblio with multiple deleted items
  - Click "Restore" button for the biblio
  - Modal shows checkboxes for each deleted item
  - Select some items (not all), click "Restore with selected items"
  - Verify biblio and selected items restore
  - Unselected items remain in deleted items table

  Permission Testing:
  - Remove "Restore deleted records" permission from user
  - Verify "Restore deleted records" link no longer appears in
Cataloging home
Comment 13 Jacob O'Mara 2025-10-30 16:38:10 UTC
Created attachment 188671 [details] [review]
Bug 17387: add deleted items restore api
Comment 14 Jacob O'Mara 2025-10-30 16:38:13 UTC
Created attachment 188672 [details] [review]
Bug 17387: add deleted biblios restore api
Comment 15 Jacob O'Mara 2025-10-30 16:38:17 UTC
Created attachment 188673 [details] [review]
Bug 17387: update swagger for deleted biblios/items restore
Comment 16 Jacob O'Mara 2025-10-30 16:38:21 UTC
Created attachment 188674 [details] [review]
Bug 17387: add restore item/biblio tests
Comment 17 Jacob O'Mara 2025-10-30 16:38:24 UTC
Created attachment 188675 [details] [review]
Bug 17387: reindex biblio/item on restore
Comment 18 Jacob O'Mara 2025-10-30 16:38:28 UTC
Created attachment 188676 [details] [review]
Bug 17387: item cannot be restored if associated biblio does not exist
Comment 19 Jacob O'Mara 2025-10-30 16:38:31 UTC
Created attachment 188677 [details] [review]
Bug 17387: add restore records page
Comment 20 Jacob O'Mara 2025-10-30 16:38:35 UTC
Created attachment 188678 [details] [review]
Bug 17387: add pagination headers and support comma-delimited Accept headers
Comment 21 Jacob O'Mara 2025-10-30 16:38:38 UTC
Created attachment 188679 [details] [review]
Bug 17387: add biblio embed to deleteditems return
Comment 22 Jacob O'Mara 2025-10-30 16:38:41 UTC
Created attachment 188680 [details] [review]
Bug 17387: add modal warning for items with deleted biblios
Comment 23 Jacob O'Mara 2025-10-30 16:38:46 UTC
Created attachment 188681 [details] [review]
Bug 17387: add items embed to deleted biblios API
Comment 24 Jacob O'Mara 2025-10-30 16:38:50 UTC
Created attachment 188682 [details] [review]
Bug 17387: add modal for restoring biblios with item selection
Comment 25 Jacob O'Mara 2025-10-30 16:38:55 UTC
Created attachment 188683 [details] [review]
Bug 17387: add sidebar date filtering for item/biblio restore
Comment 26 Jacob O'Mara 2025-10-30 16:39:00 UTC
Created attachment 188684 [details] [review]
Bug 17387: add links for restore item/biblio to cataloguing
Comment 27 Jacob O'Mara 2025-10-30 16:39:03 UTC
Created attachment 188685 [details] [review]
Bug 17387: add restore records permission as child of cataloguing perms
Comment 28 Jacob O'Mara 2025-10-30 17:38:22 UTC
Created attachment 188686 [details] [review]
Bug 17387: add restore functionality to Old::Biblio/Item

TEST PLAN: Item/Biblio Undelete Feature

  SETUP:
  - Apply patches and update database
  - Give test user "Restore deleted records" permission under Cataloging
permissions
  - Delete at least one bibliographic record with items attached
  - Delete at least one standalone item

  TESTING:

  Navigate to Cataloging:
  - Go to Cataloging home page
  - Click "Restore deleted records" link (should be visible with
permission)

  Test Restore Records Page:
  - Verify two tables appear: "Deleted bibliographic records" and
"Deleted items"
  - Verify deleted records appear in tables with biblio ID, title,
barcode, deleted date

  Test Date Filtering:
  - In left sidebar, enter date range in "Deleted from" and "Deleted to"
fields
  - Click "Apply" button - tables should filter by date range
  - Click "Clear" button - filter should reset

  Test Item Restore:
  - Find a deleted item in the items table (with existing biblio)
  - Click "Restore" button in Actions column
  - Verify success message appears and item disappears from table
  - Search catalog for the restored item - confirm it's back

  Test Biblio Warning Modal:
  - Find a deleted item whose biblio is also deleted
  - Click "Restore" button on the item
  - Modal appears warning "bibliographic record is deleted"
  - Click "Restore biblio" - biblio restores, modal closes
  - Click "Restore" on the item again - item now restores successfully
  - Verify both records are back in catalog

  Test Biblio with Items Restore:
  - Find deleted biblio with multiple deleted items
  - Click "Restore" button for the biblio
  - Modal shows checkboxes for each deleted item
  - Select some items (not all), click "Restore with selected items"
  - Verify biblio and selected items restore
  - Unselected items remain in deleted items table

  Permission Testing:
  - Remove "Restore deleted records" permission from user
  - Verify "Restore deleted records" link no longer appears in
Cataloging home
Comment 29 Jacob O'Mara 2025-10-30 17:38:25 UTC
Created attachment 188687 [details] [review]
Bug 17387: add deleted items restore api
Comment 30 Jacob O'Mara 2025-10-30 17:38:29 UTC
Created attachment 188688 [details] [review]
Bug 17387: add deleted biblios restore api
Comment 31 Jacob O'Mara 2025-10-30 17:38:32 UTC
Created attachment 188689 [details] [review]
Bug 17387: update swagger for deleted biblios/items restore
Comment 32 Jacob O'Mara 2025-10-30 17:38:35 UTC
Created attachment 188690 [details] [review]
Bug 17387: add restore item/biblio tests
Comment 33 Jacob O'Mara 2025-10-30 17:38:39 UTC
Created attachment 188691 [details] [review]
Bug 17387: reindex biblio/item on restore
Comment 34 Jacob O'Mara 2025-10-30 17:38:43 UTC
Created attachment 188692 [details] [review]
Bug 17387: item cannot be restored if associated biblio does not exist
Comment 35 Jacob O'Mara 2025-10-30 17:38:46 UTC
Created attachment 188693 [details] [review]
Bug 17387: add restore records page
Comment 36 Jacob O'Mara 2025-10-30 17:38:51 UTC
Created attachment 188694 [details] [review]
Bug 17387: add pagination headers and support comma-delimited Accept headers
Comment 37 Jacob O'Mara 2025-10-30 17:38:59 UTC
Created attachment 188695 [details] [review]
Bug 17387: add biblio embed to deleteditems return
Comment 38 Jacob O'Mara 2025-10-30 17:39:03 UTC
Created attachment 188696 [details] [review]
Bug 17387: add modal warning for items with deleted biblios
Comment 39 Jacob O'Mara 2025-10-30 17:39:12 UTC
Created attachment 188697 [details] [review]
Bug 17387: add items embed to deleted biblios API
Comment 40 Jacob O'Mara 2025-10-30 17:39:21 UTC
Created attachment 188698 [details] [review]
Bug 17387: add modal for restoring biblios with item selection
Comment 41 Jacob O'Mara 2025-10-30 17:39:34 UTC
Created attachment 188699 [details] [review]
Bug 17387: add sidebar date filtering for item/biblio restore
Comment 42 Jacob O'Mara 2025-10-30 17:39:44 UTC
Created attachment 188700 [details] [review]
Bug 17387: add links for restore item/biblio to cataloguing
Comment 43 Jacob O'Mara 2025-10-30 17:39:53 UTC
Created attachment 188701 [details] [review]
Bug 17387: add restore records permission as child of cataloguing perms
Comment 44 Marcel de Rooy 2025-10-31 07:32:43 UTC
Promising! Thx
Comment 45 Biblibre Sandboxes 2025-10-31 09:50:36 UTC
Created attachment 188780 [details] [review]
Bug 17387: add restore functionality to Old::Biblio/Item

TEST PLAN: Item/Biblio Undelete Feature

  SETUP:
  - Apply patches and update database
  - Give test user "Restore deleted records" permission under Cataloging
permissions
  - Delete at least one bibliographic record with items attached
  - Delete at least one standalone item

  TESTING:

  Navigate to Cataloging:
  - Go to Cataloging home page
  - Click "Restore deleted records" link (should be visible with
permission)

  Test Restore Records Page:
  - Verify two tables appear: "Deleted bibliographic records" and
"Deleted items"
  - Verify deleted records appear in tables with biblio ID, title,
barcode, deleted date

  Test Date Filtering:
  - In left sidebar, enter date range in "Deleted from" and "Deleted to"
fields
  - Click "Apply" button - tables should filter by date range
  - Click "Clear" button - filter should reset

  Test Item Restore:
  - Find a deleted item in the items table (with existing biblio)
  - Click "Restore" button in Actions column
  - Verify success message appears and item disappears from table
  - Search catalog for the restored item - confirm it's back

  Test Biblio Warning Modal:
  - Find a deleted item whose biblio is also deleted
  - Click "Restore" button on the item
  - Modal appears warning "bibliographic record is deleted"
  - Click "Restore biblio" - biblio restores, modal closes
  - Click "Restore" on the item again - item now restores successfully
  - Verify both records are back in catalog

  Test Biblio with Items Restore:
  - Find deleted biblio with multiple deleted items
  - Click "Restore" button for the biblio
  - Modal shows checkboxes for each deleted item
  - Select some items (not all), click "Restore with selected items"
  - Verify biblio and selected items restore
  - Unselected items remain in deleted items table

  Permission Testing:
  - Remove "Restore deleted records" permission from user
  - Verify "Restore deleted records" link no longer appears in
Cataloging home

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 46 Biblibre Sandboxes 2025-10-31 09:50:39 UTC
Created attachment 188781 [details] [review]
Bug 17387: add deleted items restore api

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 47 Biblibre Sandboxes 2025-10-31 09:50:42 UTC
Created attachment 188782 [details] [review]
Bug 17387: add deleted biblios restore api

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 48 Biblibre Sandboxes 2025-10-31 09:50:46 UTC
Created attachment 188783 [details] [review]
Bug 17387: update swagger for deleted biblios/items restore

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 49 Biblibre Sandboxes 2025-10-31 09:50:49 UTC
Created attachment 188784 [details] [review]
Bug 17387: add restore item/biblio tests

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 50 Biblibre Sandboxes 2025-10-31 09:50:52 UTC
Created attachment 188785 [details] [review]
Bug 17387: reindex biblio/item on restore

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 51 Biblibre Sandboxes 2025-10-31 09:50:55 UTC
Created attachment 188786 [details] [review]
Bug 17387: item cannot be restored if associated biblio does not exist

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 52 Biblibre Sandboxes 2025-10-31 09:50:58 UTC
Created attachment 188787 [details] [review]
Bug 17387: add restore records page

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 53 Biblibre Sandboxes 2025-10-31 09:51:02 UTC
Created attachment 188788 [details] [review]
Bug 17387: add pagination headers and support comma-delimited Accept headers

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 54 Biblibre Sandboxes 2025-10-31 09:51:05 UTC
Created attachment 188789 [details] [review]
Bug 17387: add biblio embed to deleteditems return

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 55 Biblibre Sandboxes 2025-10-31 09:51:08 UTC
Created attachment 188790 [details] [review]
Bug 17387: add modal warning for items with deleted biblios

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 56 Biblibre Sandboxes 2025-10-31 09:51:11 UTC
Created attachment 188791 [details] [review]
Bug 17387: add items embed to deleted biblios API

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 57 Biblibre Sandboxes 2025-10-31 09:51:15 UTC
Created attachment 188792 [details] [review]
Bug 17387: add modal for restoring biblios with item selection

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 58 Biblibre Sandboxes 2025-10-31 09:51:18 UTC
Created attachment 188793 [details] [review]
Bug 17387: add sidebar date filtering for item/biblio restore

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 59 Biblibre Sandboxes 2025-10-31 09:51:21 UTC
Created attachment 188794 [details] [review]
Bug 17387: add links for restore item/biblio to cataloguing

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 60 Biblibre Sandboxes 2025-10-31 09:51:24 UTC
Created attachment 188795 [details] [review]
Bug 17387: add restore records permission as child of cataloguing perms

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Comment 61 Michaela Sieber 2025-10-31 10:12:28 UTC
Hi Jacob,

I've tested everythink and it worked as expected, thats why I sign off.

BUT : what I really miss is the logging about the undelete action.

The deletions are logged in the action logs and if we now do an undelete this should be logged as well.

I think this is not to hard to implement but I recommend it very much!


Unfortunately there seems to be a Bug in Main with the cataloguing permissions. Even if my user has the whole module permission  (editcatalogue) including various batch options I only see the fast cataloging Button as option, means I also could not use the Button on the catloguing home page for tests with my restricted user.

so I tested just via URL .../restore-records.pl 

Maybe interesting for other testers...
Comment 62 Andrew Fuerste-Henry 2025-10-31 13:25:38 UTC
Echoing Michaela, the action logs really shoud record the un-delete.
Comment 63 Andrew Fuerste-Henry 2025-10-31 13:41:02 UTC
(In reply to Michaela Sieber from comment #61) 
> Unfortunately there seems to be a Bug in Main with the cataloguing
> permissions. Even if my user has the whole module permission 
> (editcatalogue) including various batch options I only see the fast
> cataloging Button as option, means I also could not use the Button on the
> catloguing home page for tests with my restricted user.

I've filed Bug 41160 for this.
Comment 64 Andrew Fuerste-Henry 2025-10-31 13:55:54 UTC
(In reply to Andrew Fuerste-Henry from comment #63)
> (In reply to Michaela Sieber from comment #61) 
> > Unfortunately there seems to be a Bug in Main with the cataloguing
> > permissions. Even if my user has the whole module permission 
> > (editcatalogue) including various batch options I only see the fast
> > cataloging Button as option, means I also could not use the Button on the
> > catloguing home page for tests with my restricted user.
> 
> I've filed Bug 41160 for this.

Hmm, Lucas has wisely pointed on that all of the other buttons on the cataloging home page and tied to Tools permissions. Which makes sense because they were previously all on the Tools page. Updating my bug, but also wanted to mention it here.
Comment 65 Jacob O'Mara 2025-11-04 16:53:23 UTC
I completely agree, we should track this in the action_logs. I will get this added as a follow up shortly. Didn't even cross my mind!

In terms of the permissions issues, would you prefer I change the permissions to match the other tools on the cataloguing page in the interim for consistency?
Comment 66 Andrew Fuerste-Henry 2025-11-04 17:11:50 UTC
(In reply to Jacob O'Mara from comment #65)
> I completely agree, we should track this in the action_logs. I will get this
> added as a follow up shortly. Didn't even cross my mind!
> 
> In terms of the permissions issues, would you prefer I change the
> permissions to match the other tools on the cataloguing page in the interim
> for consistency?

Yes, I think it makes sense to put this permission under Tools with the other cataloging tools for now. Thanks!
Comment 67 Michaela Sieber 2025-11-04 17:17:00 UTC

Thank You!

And yes, I think it would be better to have the new permission in the tools section as well as all the other batch tools.

The more I think about it I don't think it will be an interim solution ;-)
It makes sense that batch tools are not part of the cataloguing permissions. 
These are powerful tools for advanced users, I don't think we can "just migrate" them into the existing module permission
Comment 68 Jacob O'Mara 2025-11-04 19:34:57 UTC
Created attachment 189046 [details] [review]
Bug 17387: add restore functionality to Old::Biblio/Item

TEST PLAN: Item/Biblio Undelete Feature

  SETUP:
  - Apply patches and update database
  - Give test user "Restore deleted records" permission under Cataloging
permissions
  - Delete at least one bibliographic record with items attached
  - Delete at least one standalone item

  TESTING:

  Navigate to Cataloging:
  - Go to Cataloging home page
  - Click "Restore deleted records" link (should be visible with
permission)

  Test Restore Records Page:
  - Verify two tables appear: "Deleted bibliographic records" and
"Deleted items"
  - Verify deleted records appear in tables with biblio ID, title,
barcode, deleted date

  Test Date Filtering:
  - In left sidebar, enter date range in "Deleted from" and "Deleted to"
fields
  - Click "Apply" button - tables should filter by date range
  - Click "Clear" button - filter should reset

  Test Item Restore:
  - Find a deleted item in the items table (with existing biblio)
  - Click "Restore" button in Actions column
  - Verify success message appears and item disappears from table
  - Search catalog for the restored item - confirm it's back

  Test Biblio Warning Modal:
  - Find a deleted item whose biblio is also deleted
  - Click "Restore" button on the item
  - Modal appears warning "bibliographic record is deleted"
  - Click "Restore biblio" - biblio restores, modal closes
  - Click "Restore" on the item again - item now restores successfully
  - Verify both records are back in catalog

  Test Biblio with Items Restore:
  - Find deleted biblio with multiple deleted items
  - Click "Restore" button for the biblio
  - Modal shows checkboxes for each deleted item
  - Select some items (not all), click "Restore with selected items"
  - Verify biblio and selected items restore
  - Unselected items remain in deleted items table

  Permission Testing:
  - Remove "Restore deleted records" permission from user
  - Verify "Restore deleted records" link no longer appears in
Cataloging home
Comment 69 Jacob O'Mara 2025-11-04 19:35:01 UTC
Created attachment 189047 [details] [review]
Bug 17387: add deleted items restore api
Comment 70 Jacob O'Mara 2025-11-04 19:35:05 UTC
Created attachment 189048 [details] [review]
Bug 17387: add deleted biblios restore api
Comment 71 Jacob O'Mara 2025-11-04 19:35:08 UTC
Created attachment 189049 [details] [review]
Bug 17387: update swagger for deleted biblios/items restore
Comment 72 Jacob O'Mara 2025-11-04 19:35:12 UTC
Created attachment 189050 [details] [review]
Bug 17387: add restore item/biblio tests
Comment 73 Jacob O'Mara 2025-11-04 19:35:15 UTC
Created attachment 189051 [details] [review]
Bug 17387: reindex biblio/item on restore
Comment 74 Jacob O'Mara 2025-11-04 19:35:19 UTC
Created attachment 189052 [details] [review]
Bug 17387: item cannot be restored if associated biblio does not exist
Comment 75 Jacob O'Mara 2025-11-04 19:35:22 UTC
Created attachment 189053 [details] [review]
Bug 17387: add restore records page
Comment 76 Jacob O'Mara 2025-11-04 19:35:26 UTC
Created attachment 189054 [details] [review]
Bug 17387: add pagination headers and support comma-delimited Accept headers
Comment 77 Jacob O'Mara 2025-11-04 19:35:30 UTC
Created attachment 189055 [details] [review]
Bug 17387: add biblio embed to deleteditems return
Comment 78 Jacob O'Mara 2025-11-04 19:35:33 UTC
Created attachment 189056 [details] [review]
Bug 17387: add modal warning for items with deleted biblios
Comment 79 Jacob O'Mara 2025-11-04 19:35:37 UTC
Created attachment 189057 [details] [review]
Bug 17387: add items embed to deleted biblios API
Comment 80 Jacob O'Mara 2025-11-04 19:35:41 UTC
Created attachment 189058 [details] [review]
Bug 17387: add modal for restoring biblios with item selection
Comment 81 Jacob O'Mara 2025-11-04 19:35:44 UTC
Created attachment 189059 [details] [review]
Bug 17387: add sidebar date filtering for item/biblio restore
Comment 82 Jacob O'Mara 2025-11-04 19:35:48 UTC
Created attachment 189060 [details] [review]
Bug 17387: add links for restore item/biblio to cataloguing
Comment 83 Jacob O'Mara 2025-11-04 19:35:51 UTC
Created attachment 189061 [details] [review]
Bug 17387: add restore records permission as child of cataloguing perms
Comment 84 Jacob O'Mara 2025-11-04 19:35:55 UTC
Created attachment 189062 [details] [review]
Bug 17387: add logging for biblio/item restore

This adds RESTORE action for biblios and items to the action log
Comment 85 Jacob O'Mara 2025-11-04 19:37:04 UTC
Done and done! Thanks for the input, both.
Comment 86 Andrew Fuerste-Henry 2025-11-04 21:29:13 UTC
With apologies for throwing a wrench into thing: This needs to respect limits to item editing based on library groups. As is, this allows a user to restore items from other library groups that they would not be able to modify or delete.

To recreate with KTD data:
- Create a library group with "Limit item editing by group" selected
- Add Centerville to your group
- Grant permissions to Midway patron Henry Acevedo: catalogue, edit_catalogue, edit_items, items_batchdel, items_batchmod, records_restore

- Log in as Henry, go to biblio 344 (E street shuffle), which contains a mix of Centerville and Midway items
- Confirm you cannot edit or delete the Centerville items from the bib record
- Confirm you cannot edit or delete the Centerville items from the batch item tools

- Log in as a superlibrarian
- Delete biblio 344 and all attached items

- Log in as Henry
- Confirm you can restore biblio 344 and all attached items

With that Groups setup and those permissions, Henry should be allowed to restore the biblio and the Midway item, but not the Centerville items
Comment 87 Jacob O'Mara 2025-11-05 15:39:08 UTC
Created attachment 189082 [details] [review]
Bug 17387: add restore functionality to Old::Biblio/Item

TEST PLAN: Item/Biblio Undelete Feature

  SETUP:
  - Apply patches and update database
  - Give test user "Restore deleted records" permission under Cataloging
permissions
  - Delete at least one bibliographic record with items attached
  - Delete at least one standalone item

  TESTING:

  Navigate to Cataloging:
  - Go to Cataloging home page
  - Click "Restore deleted records" link (should be visible with
permission)

  Test Restore Records Page:
  - Verify two tables appear: "Deleted bibliographic records" and
"Deleted items"
  - Verify deleted records appear in tables with biblio ID, title,
barcode, deleted date

  Test Date Filtering:
  - In left sidebar, enter date range in "Deleted from" and "Deleted to"
fields
  - Click "Apply" button - tables should filter by date range
  - Click "Clear" button - filter should reset

  Test Item Restore:
  - Find a deleted item in the items table (with existing biblio)
  - Click "Restore" button in Actions column
  - Verify success message appears and item disappears from table
  - Search catalog for the restored item - confirm it's back

  Test Biblio Warning Modal:
  - Find a deleted item whose biblio is also deleted
  - Click "Restore" button on the item
  - Modal appears warning "bibliographic record is deleted"
  - Click "Restore biblio" - biblio restores, modal closes
  - Click "Restore" on the item again - item now restores successfully
  - Verify both records are back in catalog

  Test Biblio with Items Restore:
  - Find deleted biblio with multiple deleted items
  - Click "Restore" button for the biblio
  - Modal shows checkboxes for each deleted item
  - Select some items (not all), click "Restore with selected items"
  - Verify biblio and selected items restore
  - Unselected items remain in deleted items table

  Permission Testing:
  - Remove "Restore deleted records" permission from user
  - Verify "Restore deleted records" link no longer appears in
Cataloging home
Comment 88 Jacob O'Mara 2025-11-05 15:39:12 UTC
Created attachment 189083 [details] [review]
Bug 17387: add deleted items restore api
Comment 89 Jacob O'Mara 2025-11-05 15:39:16 UTC
Created attachment 189084 [details] [review]
Bug 17387: add deleted biblios restore api
Comment 90 Jacob O'Mara 2025-11-05 15:39:19 UTC
Created attachment 189085 [details] [review]
Bug 17387: update swagger for deleted biblios/items restore
Comment 91 Jacob O'Mara 2025-11-05 15:39:23 UTC
Created attachment 189086 [details] [review]
Bug 17387: add restore item/biblio tests
Comment 92 Jacob O'Mara 2025-11-05 15:39:26 UTC
Created attachment 189087 [details] [review]
Bug 17387: reindex biblio/item on restore
Comment 93 Jacob O'Mara 2025-11-05 15:39:30 UTC
Created attachment 189088 [details] [review]
Bug 17387: item cannot be restored if associated biblio does not exist
Comment 94 Jacob O'Mara 2025-11-05 15:39:33 UTC
Created attachment 189089 [details] [review]
Bug 17387: add restore records page
Comment 95 Jacob O'Mara 2025-11-05 15:39:37 UTC
Created attachment 189090 [details] [review]
Bug 17387: add pagination headers and support comma-delimited Accept headers
Comment 96 Jacob O'Mara 2025-11-05 15:39:40 UTC
Created attachment 189091 [details] [review]
Bug 17387: add biblio embed to deleteditems return
Comment 97 Jacob O'Mara 2025-11-05 15:39:44 UTC
Created attachment 189092 [details] [review]
Bug 17387: add modal warning for items with deleted biblios
Comment 98 Jacob O'Mara 2025-11-05 15:39:48 UTC
Created attachment 189093 [details] [review]
Bug 17387: add items embed to deleted biblios API
Comment 99 Jacob O'Mara 2025-11-05 15:39:51 UTC
Created attachment 189094 [details] [review]
Bug 17387: add modal for restoring biblios with item selection
Comment 100 Jacob O'Mara 2025-11-05 15:39:55 UTC
Created attachment 189095 [details] [review]
Bug 17387: add sidebar date filtering for item/biblio restore
Comment 101 Jacob O'Mara 2025-11-05 15:39:58 UTC
Created attachment 189096 [details] [review]
Bug 17387: add links for restore item/biblio to cataloguing
Comment 102 Jacob O'Mara 2025-11-05 15:40:02 UTC
Created attachment 189097 [details] [review]
Bug 17387: add restore records permission as child of cataloguing perms
Comment 103 Jacob O'Mara 2025-11-05 15:40:06 UTC
Created attachment 189098 [details] [review]
Bug 17387: add logging for biblio/item restore

This adds RESTORE action for biblios and items to the action log
Comment 104 Jacob O'Mara 2025-11-05 15:40:10 UTC
Created attachment 189099 [details] [review]
Bug 17387: (follow-up) take library groups in to account for permissions check
Comment 105 Jacob O'Mara 2025-11-05 15:40:13 UTC
Created attachment 189100 [details] [review]
Bug 17387: (follow-up) restore tests should account for new library groups checks
Comment 106 Jacob O'Mara 2025-11-05 15:42:35 UTC
Good spot. Follow up added and moved back to Signed off/Needs QA.
Thanks for taking a look so quickly!
Comment 107 Lucas Gass (lukeg) 2025-11-05 15:49:25 UTC
This is going to break xt/api.t tests:


xt/api.t ........................................ 1/8 
#   Failed test at xt/api.t line 93.
#          got: '2'
#     expected: '0'
# $VAR1 = [
#           {
#             'name' => 'body',
#             'route' => '/deleted/biblios/{biblio_id}',
#             'type' => 'parameter',
#             'verb' => 'put'
#           },
#           {
#             'verb' => 'put',
#             'type' => 'response',
#             'name' => '200',
#             'route' => '/deleted/biblios/{biblio_id}'
#           }
#         ];
Comment 108 Jacob O'Mara 2025-11-05 15:59:23 UTC
Created attachment 189101 [details] [review]
Bug 17387: add restore functionality to Old::Biblio/Item

TEST PLAN: Item/Biblio Undelete Feature

  SETUP:
  - Apply patches and update database
  - Give test user "Restore deleted records" permission under Cataloging
permissions
  - Delete at least one bibliographic record with items attached
  - Delete at least one standalone item

  TESTING:

  Navigate to Cataloging:
  - Go to Cataloging home page
  - Click "Restore deleted records" link (should be visible with
permission)

  Test Restore Records Page:
  - Verify two tables appear: "Deleted bibliographic records" and
"Deleted items"
  - Verify deleted records appear in tables with biblio ID, title,
barcode, deleted date

  Test Date Filtering:
  - In left sidebar, enter date range in "Deleted from" and "Deleted to"
fields
  - Click "Apply" button - tables should filter by date range
  - Click "Clear" button - filter should reset

  Test Item Restore:
  - Find a deleted item in the items table (with existing biblio)
  - Click "Restore" button in Actions column
  - Verify success message appears and item disappears from table
  - Search catalog for the restored item - confirm it's back

  Test Biblio Warning Modal:
  - Find a deleted item whose biblio is also deleted
  - Click "Restore" button on the item
  - Modal appears warning "bibliographic record is deleted"
  - Click "Restore biblio" - biblio restores, modal closes
  - Click "Restore" on the item again - item now restores successfully
  - Verify both records are back in catalog

  Test Biblio with Items Restore:
  - Find deleted biblio with multiple deleted items
  - Click "Restore" button for the biblio
  - Modal shows checkboxes for each deleted item
  - Select some items (not all), click "Restore with selected items"
  - Verify biblio and selected items restore
  - Unselected items remain in deleted items table

  Permission Testing:
  - Remove "Restore deleted records" permission from user
  - Verify "Restore deleted records" link no longer appears in
Cataloging home
Comment 109 Jacob O'Mara 2025-11-05 15:59:27 UTC
Created attachment 189102 [details] [review]
Bug 17387: add deleted items restore api
Comment 110 Jacob O'Mara 2025-11-05 15:59:31 UTC
Created attachment 189103 [details] [review]
Bug 17387: add deleted biblios restore api
Comment 111 Jacob O'Mara 2025-11-05 15:59:35 UTC
Created attachment 189104 [details] [review]
Bug 17387: update swagger for deleted biblios/items restore
Comment 112 Jacob O'Mara 2025-11-05 15:59:38 UTC
Created attachment 189105 [details] [review]
Bug 17387: add restore item/biblio tests
Comment 113 Jacob O'Mara 2025-11-05 15:59:42 UTC
Created attachment 189106 [details] [review]
Bug 17387: reindex biblio/item on restore
Comment 114 Jacob O'Mara 2025-11-05 15:59:46 UTC
Created attachment 189107 [details] [review]
Bug 17387: item cannot be restored if associated biblio does not exist
Comment 115 Jacob O'Mara 2025-11-05 15:59:49 UTC
Created attachment 189108 [details] [review]
Bug 17387: add restore records page
Comment 116 Jacob O'Mara 2025-11-05 15:59:53 UTC
Created attachment 189109 [details] [review]
Bug 17387: add pagination headers and support comma-delimited Accept headers
Comment 117 Jacob O'Mara 2025-11-05 15:59:57 UTC
Created attachment 189110 [details] [review]
Bug 17387: add biblio embed to deleteditems return
Comment 118 Jacob O'Mara 2025-11-05 16:00:01 UTC
Created attachment 189111 [details] [review]
Bug 17387: add modal warning for items with deleted biblios
Comment 119 Jacob O'Mara 2025-11-05 16:00:05 UTC
Created attachment 189112 [details] [review]
Bug 17387: add items embed to deleted biblios API
Comment 120 Jacob O'Mara 2025-11-05 16:00:09 UTC
Created attachment 189113 [details] [review]
Bug 17387: add modal for restoring biblios with item selection
Comment 121 Jacob O'Mara 2025-11-05 16:00:12 UTC
Created attachment 189114 [details] [review]
Bug 17387: add sidebar date filtering for item/biblio restore
Comment 122 Jacob O'Mara 2025-11-05 16:00:16 UTC
Created attachment 189115 [details] [review]
Bug 17387: add links for restore item/biblio to cataloguing
Comment 123 Jacob O'Mara 2025-11-05 16:00:20 UTC
Created attachment 189116 [details] [review]
Bug 17387: add restore records permission as child of cataloguing perms
Comment 124 Jacob O'Mara 2025-11-05 16:00:24 UTC
Created attachment 189117 [details] [review]
Bug 17387: add logging for biblio/item restore

This adds RESTORE action for biblios and items to the action log
Comment 125 Jacob O'Mara 2025-11-05 16:00:27 UTC
Created attachment 189118 [details] [review]
Bug 17387: (follow-up) take library groups in to account for permissions check
Comment 126 Jacob O'Mara 2025-11-05 16:00:31 UTC
Created attachment 189119 [details] [review]
Bug 17387: (follow-up) restore tests should account for new library groups checks
Comment 127 Anneli Österman 2025-11-14 06:53:54 UTC
Question about child records / component parts. Is there a way to identify if the bibliographic record had child records /  component parts that also needs to be restored? The linkage between monographic record and component record is in the component records field 773 (in MARC21). Or do the restorer just have to know that there are child records too? I did not see any indication that listed record is a child record or that monographic record has child records.
Comment 128 Martin Renvoize (ashimema) 2025-11-24 12:51:18 UTC
(In reply to Anneli Österman from comment #127)
> Question about child records / component parts. Is there a way to identify
> if the bibliographic record had child records /  component parts that also
> needs to be restored? The linkage between monographic record and component
> record is in the component records field 773 (in MARC21). Or do the restorer
> just have to know that there are child records too? I did not see any
> indication that listed record is a child record or that monographic record
> has child records.

I don't think we took that into account right now and I think it should be treated as it's own development on top of this.  Could you submit a new bug depending on this one with your needs and requirements Anneli?
Comment 129 Anneli Österman 2025-11-25 05:48:40 UTC
Thank you Martin for your answer. I added a new bug https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41295 about the component parts.