Bug 27767 - Number of elements in cart is not updated when records are deleted or merged
Summary: Number of elements in cart is not updated when records are deleted or merged
Status: ASSIGNED
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-24 01:30 UTC by David Nind
Modified: 2024-01-29 16:10 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:


Attachments
Bug 27767: Remove readCookieValue (1.52 KB, patch)
2021-03-03 10:39 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27767: Update the number of elements in cart if biblio is removed (10.75 KB, patch)
2021-03-03 10:39 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 David Nind 2021-02-24 01:30:06 UTC
Using the staff interface, if you use the 'Batch delete' option in the cart:
- the items are deleted, 
- they no longer appear in the list of items in the cart, 
- but the number of items shown as in the cart (next to the menu icon) stays the same (that is, it isn't reduced).

For example, 5 items added, 2 items batch deleted, only three items are listed in the cart, the number of items in the cart still shows as 5 (Cart (5)).

To replicate using the staff interface:
1. Add some items to a cart.
2. Note the number of items shown next to the cart menu icon in brackets.
3. Open the cart.
4. Select one or more items.
5. Select 'Batch delete'.
6. Delete the items.
7. Open the cart again.
8. The items deleted are no longer listed.
9. The number of items in the cart has not changed.
Comment 1 Jonathan Druart 2021-03-02 15:49:38 UTC
Also true if you remove a record from the detail page.
Comment 2 Jonathan Druart 2021-03-03 10:39:35 UTC
Created attachment 117561 [details] [review]
Bug 27767: Remove readCookieValue

This JS function is not used.
It seems that "quit" is not used either
Comment 3 Jonathan Druart 2021-03-03 10:39:38 UTC
Created attachment 117562 [details] [review]
Bug 27767: Update the number of elements in cart if biblio is removed

If a bibliographic record is added to the cart then removed (from the
detail page or using the batch delete tool), the number of elements in
the cart is never updated.

This patch reworks how the cookie "intranet_bib_list" is handled in
basket.js. The current code is really bad and error prone (parsing a string).
Here we are handling the biblionumbers using a JSON serialised array,
that makes everything much more simple.
Comment 4 Jonathan Druart 2021-03-03 10:44:31 UTC
This is just a start, there are much more to do here:
1. Continue to clean the code (addMultiple and delSelRecords for instance)
2. Confirm that the behaviour about the the parent flag (from readCookie) I removed is still working
3. Adapt code at the OPAC
4. Test everything (that's quite huge as it's used from different views)

I'd like a bit of help, anyone willing to code golf on this one?
Comment 5 Katrin Fischer 2023-07-01 17:20:37 UTC
The test plan talks about items, but the cart actually shows the number of records.

What works:

* Adding and removing from the detail page now updates the number

What doesn't work:

* Deleting the record doesn't update the cart number
* Batch deleting records
* Merging records
Comment 6 Victor Grousset/tuxayo 2023-11-06 20:43:49 UTC
Additional impact of the bug: downloading cart doesn't work (internal server error)
Mitigation: Empty cart to get rid of the invalid data. Valid records can be added to a list to easily re-add them after.