Bug 37637 - Use the REST API to display items on the staff edit items view
Summary: Use the REST API to display items on the staff edit items view
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Sam Lau
QA Contact: Testopia
URL:
Keywords:
Depends on: 33568 37639
Blocks: 34832
  Show dependency treegraph
 
Reported: 2024-08-13 20:20 UTC by Sam Lau
Modified: 2024-09-24 20:00 UTC (History)
6 users (show)

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


Attachments
Bug 37637: Use the API to load the items table (34.48 KB, patch)
2024-08-19 21:10 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37637: Hide the timestamp column by default (677 bytes, patch)
2024-08-19 21:10 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37637: Hide the timestamp column by default (731 bytes, patch)
2024-08-20 20:42 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 37637: Use the API to load the items table (25.48 KB, patch)
2024-08-27 22:43 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 37637: Hide the timestamp column by default (733 bytes, patch)
2024-08-27 22:43 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 37637: (follow-up) Fix action menu (5.43 KB, patch)
2024-09-24 20:00 UTC, Lucas Gass
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Lau 2024-08-13 20:20:36 UTC
Currently, the additems table is rendered using the DB, which can cause performance issues for large amounts of items. It makes sense to switch to using the REST API (/api/v1/biblios/{biblionumber}/items)
Comment 1 Jonathan Druart 2024-08-14 15:41:18 UTC
Hi Sam, this seems like a huge work. Please share with us your plan before starting :)
Comment 2 Sam Lau 2024-08-14 16:12:51 UTC
(In reply to Jonathan Druart from comment #1)
> Hi Sam, this seems like a huge work. Please share with us your plan before
> starting :)

Sure. Firstly, we need to remove all of the body code for building the table using a for loop in additem.tt and fixup the headers as well. Then in the cataloging_additem.js, we would need to build the table using kohaTable with '/api/v1/biblios/' + biblionumber + '/items?' as the ajax url. Then for the columns we can simply grab the responses from the api, and make necessary render or function changes for certain ones. For example, the actions button will need to  have a custom data function to ensure the button functionality still works. Also, the home and holding libraries (among other things) need to be rendered as a string rather than the code. Also need to hide the columns that have no data upon loading. That's pretty much the big stuff
Comment 3 Katrin Fischer 2024-08-14 17:11:46 UTC
This table does handle column visibility a bit different than others - not sure it needs to stay that way, but worth looking into when tackling the project maybe.
Comment 4 Jonathan Druart 2024-08-15 12:37:34 UTC
I was wondering we could reuse what have been done on bug 33568.
Comment 5 Sam Lau 2024-08-15 14:04:37 UTC
(In reply to Jonathan Druart from comment #4)
> I was wondering we could reuse what have been done on bug 33568.

Yes, a lot of that is being reused.
Comment 6 Sam Lau 2024-08-19 21:10:35 UTC
Created attachment 170482 [details] [review]
Bug 37637: Use the API to load the items table

This patch removes the previous use of the database to load the additem table and instead uses the API.

To test:
1) Test the current datatable behavior: visit an item's detail page and select 'Edit' then 'Edit items'
2) Apply the patches, restart_all, reset_all, clear caches, etc.
3) Again, test the table behaviors. Try adding items, using the actions, filtering and sorting the items, etc.
Comment 7 Sam Lau 2024-08-19 21:10:37 UTC
Created attachment 170483 [details] [review]
Bug 37637: Hide the timestamp column by default
Comment 8 Sam Lau 2024-08-19 21:13:20 UTC
Here are some initial patches in need of review and heavy testing. Any feedback would be greatly appreciated. 

(In reply to Katrin Fischer from comment #3)
> This table does handle column visibility a bit different than others - not
> sure it needs to stay that way, but worth looking into when tackling the
> project maybe.

I decided to switch the way this table handled column visibility to match that of the items table on the details page. I find this to be an improvement but if anyone disagrees, let me know.
Comment 9 ByWater Sandboxes 2024-08-20 20:42:55 UTC
Created attachment 170507 [details] [review]
Bug 37637: Hide the timestamp column by default

Signed-off-by: Catrina <catrina@bywatersolutions.com>
Comment 10 Catrina Berka 2024-08-20 20:43:42 UTC
Adding items, filtering and sorting all work for me as expected.
Comment 11 Lucas Gass 2024-08-27 22:28:56 UTC
Doesn't apply cleanly anymore.
Comment 12 Lucas Gass 2024-08-27 22:43:45 UTC
Created attachment 170789 [details] [review]
Bug 37637: Use the API to load the items table

This patch removes the previous use of the database to load the additem table and instead uses the API.

To test:
1) Test the current datatable behavior: visit an item's detail page and select 'Edit' then 'Edit items'
2) Apply the patches, restart_all, reset_all, clear caches, etc.
3) Again, test the table behaviors. Try adding items, using the actions, filtering and sorting the items, etc.
Comment 13 Lucas Gass 2024-08-27 22:43:48 UTC
Created attachment 170790 [details] [review]
Bug 37637: Hide the timestamp column by default

Signed-off-by: Catrina <catrina@bywatersolutions.com>
Comment 14 Lucas Gass 2024-08-27 22:44:28 UTC
Rebased, but still needs more work due to Bootstrap changes. Action buttons no longer work.
Comment 15 Lucas Gass 2024-08-27 22:47:09 UTC
Also, just like the catalog detail page the date_last_seen should be datetime. ( See 37688)
Comment 16 Jonathan Druart 2024-09-03 12:04:43 UTC
The header is broken:
https://snipboard.io/8pyjWM.jpg
=> Library columns should have a dropdown list for the filter
=> Headers are missing

https://snipboard.io/zhOF5j.jpg
=> Column list is missing labels

"Home library" actually displays barcodes.

Please fix those obvious errors and I will try to come back.
Comment 17 Jonathan Druart 2024-09-03 12:05:30 UTC
"Actions" menu is not opening
Comment 18 Lucas Gass 2024-09-24 20:00:03 UTC
Created attachment 171953 [details] [review]
Bug 37637: (follow-up) Fix action menu