Bug 38257 - Several functionalities broken in cart pop up
Summary: Several functionalities broken in cart pop up
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Emmi Takkinen
QA Contact: Aleisha Amohia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-24 11:43 UTC by Emmi Takkinen
Modified: 2024-12-18 11:37 UTC (History)
4 users (show)

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


Attachments
Bug 38257: Fix cart pop up functionalities (1.77 KB, patch)
2024-10-24 12:12 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 38257: Fix cart pop up functionalities (1.78 KB, patch)
2024-10-28 10:16 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 38257: Do not use js_includes.inc in two different files (1.33 KB, patch)
2024-10-28 10:16 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 38257: Do not use js_includes.inc in two different files (1.39 KB, patch)
2024-10-29 16:53 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 38257: Fix cart pop up functionalities (1.83 KB, patch)
2024-10-31 20:08 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 38257: Do not use js_includes.inc in two different files (1.45 KB, patch)
2024-10-31 20:08 UTC, Aleisha Amohia
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Emmi Takkinen 2024-10-24 11:43:28 UTC
For some reason change made in bug 37033 to cart pop up has broken its functionalities. All following functionalities are now broken:

- More details
- Send
- Download
- Print
- Empty and close
- Remove
- Add to a list
- Place hold
- Batch modify
- Batch delete

To reproduce:
1. Search for items and add one or more search results to your cart.
2. Open cart.
3. Attempt to use one functionality mentioned above.
=> Either nothing happens or table is loaded again with no items in table. However items are still displayed in cart when it's opened again.

Also following errors are displayed in browsers console:

> Uncaught TypeError: antiClickjack is null
> Uncaught TypeError: $(...).dataTable is not a function

Removing line [% INCLUDE 'intranet-bottom.inc' popup_window=1 %] from basket.tt fixes the problem, but then plugin intranet_js won't work.
Comment 1 Emmi Takkinen 2024-10-24 11:49:52 UTC
Welp, it seems this one was easy to tackle. Moving line [% INCLUDE 'intranet-bottom.inc' popup_window=1 %] above other include lines fixes the issue. However we still need to make sure that this doesn't cause same problem which bug 37033 fixed.
Comment 2 Emmi Takkinen 2024-10-24 12:12:27 UTC
Created attachment 173263 [details] [review]
Bug 38257: Fix cart pop up functionalities

Almost all functionalities in cart pop up were broken
due changes made in bug 37033. Also following errors
were displayed in browsers console:

> Uncaught TypeError: antiClickjack is null
> Uncaught TypeError: $(...).dataTable is not a function

This happens because when 'intranet-bottom.inc' is loaded
after other .inc files in page.

To test:
1. Search for items and add one or more search results to your cart.
2. Open cart.
3. Attempt to use one or more functionalities (download, remove item etc.).
=> Either nothing happens or table is loaded again with no items in
table. However items are still displayed in cart when it's opened again.
4. Apply this patch, restart services if needed.
5. Again attempt to download, remove items, print etc. from cart
=> Everything should now work as expected.

Sponsored-by: Koha-Suomi Oy
Comment 3 Emmi Takkinen 2024-10-24 12:12:56 UTC
Lari tested this and plugins should still work as expected.
Comment 4 Emmi Takkinen 2024-10-25 11:18:57 UTC
There is still a problem with Download button.
Comment 5 Emmi Takkinen 2024-10-28 10:16:00 UTC
Created attachment 173488 [details] [review]
Bug 38257: Fix cart pop up functionalities

Almost all functionalities in cart pop up were broken
due changes made in bug 37033. Also following errors
were displayed in browsers console:

> Uncaught TypeError: antiClickjack is null
> Uncaught TypeError: $(...).dataTable is not a function

This happens because when 'intranet-bottom.inc' is loaded
after other .inc files in page.

To test:
1. Search for items and add one or more search results to your cart.
2. Open cart.
3. Attempt to use one or more functionalities (download, remove item etc.).
=> Either nothing happens or table is loaded again with no items in
table. However items are still displayed in cart when it's opened again.
4. Apply this patch, restart services if needed.
5. Again attempt to download, remove items, print etc. from cart
=> Everything should now work as expected.

Sponsored-by: Koha-Suomi Oy
Comment 6 Emmi Takkinen 2024-10-28 10:16:33 UTC
Created attachment 173489 [details] [review]
Bug 38257: Do not use js_includes.inc in two different files

Downloading cart didn't work because js_includes.inc file
was included both in basket.tt and intranet-bottom.inc.
This patch removes related codeline from basket.tt.

To test:
1. Search for items and add one or more search results to your cart.
2. Open cart.
3. Attempt to download items from your cart.
=> Either nothing happens.
4. Apply this patch, restart services if needed.
5. Again attempt to download.
=> Download menu should now work as expected.

Sponsored-by: Koha-Suomi Oy
Comment 7 Biblibre Sandboxes 2024-10-29 16:53:42 UTC
Created attachment 173683 [details] [review]
Bug 38257: Do not use js_includes.inc in two different files

Downloading cart didn't work because js_includes.inc file
was included both in basket.tt and intranet-bottom.inc.
This patch removes related codeline from basket.tt.

To test:
1. Search for items and add one or more search results to your cart.
2. Open cart.
3. Attempt to download items from your cart.
=> Either nothing happens.
4. Apply this patch, restart services if needed.
5. Again attempt to download.
=> Download menu should now work as expected.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Sam Sowanick <sam.sowanick@corvallisoregon.gov>
Comment 8 Aleisha Amohia 2024-10-31 04:41:57 UTC
Sorry team I'm not able to reproduce the bug at all. 

Can you provide more information about what might cause the cart to break so I can properly test this?
Comment 9 Emmi Takkinen 2024-10-31 08:23:29 UTC
(In reply to Aleisha Amohia from comment #8)
> Sorry team I'm not able to reproduce the bug at all. 
> 
> Can you provide more information about what might cause the cart to break so
> I can properly test this?

Are you testing with item search cart or e.g. acquisitions cart? This is related to the former one. In bug 37033 we added this line to basket.tt file:

>[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]

It was added after other include and asset files in the same file:

>[% INCLUDE js_includes.inc %]
>[% INCLUDE 'datatables.inc' %]
>[% Asset.js("js/cart.js") | $raw %]
>[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]

It seems that this prevents those other files from working properly, leading to every functionality of the cart not working and following errors in browsers console (last one strongly suggest that datatables.inc is not loaded properly):

> Uncaught TypeError: antiClickjack is null
> Uncaught TypeError: $(...).dataTable is not a function

Moving intranet-bottom.inc as before all those other files fixed most of the functionalities, but downloading the cart was still not working. In intranet-bottom.inc file js_includes.inc is also declared at the bottom of the file. So my guess is that somehow declaring js_includes.inc both in intranet-bottom.inc and basket.tt prevents js_includes.inc from working. After moving it from basket.tt, downloading started working again.
Comment 10 Aleisha Amohia 2024-10-31 20:08:05 UTC
Created attachment 173835 [details] [review]
Bug 38257: Fix cart pop up functionalities

Almost all functionalities in cart pop up were broken
due changes made in bug 37033. Also following errors
were displayed in browsers console:

> Uncaught TypeError: antiClickjack is null
> Uncaught TypeError: $(...).dataTable is not a function

This happens because when 'intranet-bottom.inc' is loaded
after other .inc files in page.

To test:
1. Search for items and add one or more search results to your cart.
2. Open cart.
3. Attempt to use one or more functionalities (download, remove item etc.).
=> Either nothing happens or table is loaded again with no items in
table. However items are still displayed in cart when it's opened again.
4. Apply this patch, restart services if needed.
5. Again attempt to download, remove items, print etc. from cart
=> Everything should now work as expected.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Comment 11 Aleisha Amohia 2024-10-31 20:08:08 UTC
Created attachment 173836 [details] [review]
Bug 38257: Do not use js_includes.inc in two different files

Downloading cart didn't work because js_includes.inc file
was included both in basket.tt and intranet-bottom.inc.
This patch removes related codeline from basket.tt.

To test:
1. Search for items and add one or more search results to your cart.
2. Open cart.
3. Attempt to download items from your cart.
=> Either nothing happens.
4. Apply this patch, restart services if needed.
5. Again attempt to download.
=> Download menu should now work as expected.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Sam Sowanick <sam.sowanick@corvallisoregon.gov>
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Comment 12 Katrin Fischer 2024-11-07 16:33:54 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 13 Lucas Gass (lukeg) 2024-12-05 21:54:15 UTC
Backported to 24.05.x for upcoming 24.05.06
Comment 14 Fridolin Somers 2024-12-18 11:37:14 UTC
Looks like this does not impact 23.11.x