Bug 33335 - MARC overlay rules broken because of "categorycode.categorycode " which contains "-"
Summary: MARC overlay rules broken because of "categorycode.categorycode " which conta...
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Marius
QA Contact: Marcel de Rooy
URL:
Keywords:
: 33449 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-03-24 21:02 UTC by Marius
Modified: 2023-07-20 04:27 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.06,22.05.14


Attachments
the page half loaded (31.18 KB, image/png)
2023-03-24 21:02 UTC, Marius
Details
Bug 33335: fix marc overlay rules accept '-' (1.67 KB, patch)
2023-03-28 16:17 UTC, Marius
Details | Diff | Splinter Review
Bug 33335: Fix JavaScript error on the MARC overlay rules page (2.89 KB, patch)
2023-04-07 06:36 UTC, David Nind
Details | Diff | Splinter Review
Bug 33335: Use To.json to serialize (2.28 KB, patch)
2023-05-02 14:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33335: Use To.json to serialize (2.37 KB, patch)
2023-05-12 07:25 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33335: Fix JavaScript error on the MARC overlay rules page (2.98 KB, patch)
2023-05-12 08:38 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 33335: Use To.json to serialize (2.46 KB, patch)
2023-05-12 08:38 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 33335: (QA follow-up) Polishing and comments (1.90 KB, patch)
2023-05-12 08:38 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marius 2023-03-24 21:02:08 UTC
Created attachment 148696 [details]
the page half loaded

The "MARC overlay rules" page becomes inaccessible if in the DB there is in the "categories" table a "categorycode" which contains a "-". This happens because of the javascript function on the page "marc-overlay-rules.tt" line 469. The problem that is caused is the "SyntaxError: missing : after property id".

Plan test:

1- Go to Administration->Patron categories
2- Make sure you don't already have a patron categories that contains a "-"
3- Go to Administration->Record matching rules
4- Everything should be displayed as it does
5- Return to Patron categories
6- Add a new category
      In the category code put a "-" and save
7- Return to Record matching rules
      The page should be half loaded as in the photo

The solution should not prevent the user from putting "-" in the category code but the Record matching rules accept the category code with "-".
Comment 1 Marius 2023-03-28 16:17:09 UTC
Created attachment 148841 [details] [review]
Bug 33335: fix marc overlay rules accept '-'
Comment 2 Marius 2023-03-28 17:04:36 UTC
I add a patch to solve this problem. The patch has to make sure that even if there is a categorycode with "-" it will be able to display it.

testing plan:
1- Go to Administration->Patron categories
2- Make sure you don't already have a boss categories that contains a "-"
3- Go to Administration->Record matching rules
4- Everything should be displayed as it does
5- Return to Patron categories
6- Add a new category
       In the category code put a "-" and save
7- Return to Record matching rules
       The page should be half loaded as in the photo
8- Apply this patch
9- Repeat the step 7, everything should work on the Record matching rules page
Comment 3 David Nind 2023-04-07 06:36:27 UTC
Created attachment 149253 [details] [review]
Bug 33335: Fix JavaScript error on the MARC overlay rules page

The "MARC overlay rules" page doesn't display or work correctly
if a patron category code contains a "-".

This happens because of the JavaScript function in
"marc-overlay-rules.tt" line 469. This causes an error
"Uncaught SyntaxError: missing : after property id".

Test plan:
1. Go to Administration > Patron categories.
2. Make sure you don't have a patron category code that contains
   a "-".
3. Go to Administration > Record overlay rules.
4. The table should display correctly, and you can add, edit
   and delete rules.
5. Return to Patron categories.
6. Add a new patron category with a "-" in the patron category code.
7. Return to Record overlay rules page:
   => The page doesn't display and load correctly (see the attached
      image) - the normal DataTables header and footer aren't
      displayed, and you can't add, edit or delete overlay rules.
  => If you turn on web developer tools, an error is displayed in the
     console: "Uncaught SyntaxError: missing : after property id".
8. Apply the patch.
9. Repeat the step 7, the Record overlay rules page should now
   display correctly and you should be able to add, edit and
   delete rules.
10. Sign off.

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2023-04-07 06:41:48 UTC
Comment on attachment 148841 [details] [review]
Bug 33335: fix marc overlay rules accept '-'

I have edited the commit message to include the test plan - feel free to update if I haven't covered it correctly.

Normally, the commit message should include the test plan - see https://wiki.koha-community.org/wiki/Commit_messages

Also, I'm not sure what I did when I signed off, for some reason the original patch wasn't obsoleted.
Comment 5 David Nind 2023-04-07 06:43:01 UTC
I have changed the assignee to Marius.
Comment 6 Jonathan Druart 2023-05-02 14:28:08 UTC
Created attachment 150521 [details] [review]
Bug 33335: Use To.json to serialize
Comment 7 Jonathan Druart 2023-05-02 14:29:00 UTC
Why did you remove '*'?
Also the indentation is not preserved. Attached a patch, feel free to drop it if you disagree with it.
Comment 8 Jonathan Druart 2023-05-10 10:07:05 UTC
*** Bug 33449 has been marked as a duplicate of this bug. ***
Comment 9 Marcel de Rooy 2023-05-11 14:42:04 UTC
Two things:

As already commented, we lost the * => * now. Please add it back.
And the To.JSON approach does not guarantee a correct sort order which we did have.
If you add the *,* in js you will probably loose the sort order which you could not lean on anyway.
Comment 10 Jonathan Druart 2023-05-12 07:25:56 UTC
Created attachment 151116 [details] [review]
Bug 33335: Use To.json to serialize
Comment 11 Jonathan Druart 2023-05-12 07:26:35 UTC
My last try here.
Comment 12 Marcel de Rooy 2023-05-12 08:38:52 UTC
Created attachment 151119 [details] [review]
Bug 33335: Fix JavaScript error on the MARC overlay rules page

The "MARC overlay rules" page doesn't display or work correctly
if a patron category code contains a "-".

This happens because of the JavaScript function in
"marc-overlay-rules.tt" line 469. This causes an error
"Uncaught SyntaxError: missing : after property id".

Test plan:
1. Go to Administration > Patron categories.
2. Make sure you don't have a patron category code that contains
   a "-".
3. Go to Administration > Record overlay rules.
4. The table should display correctly, and you can add, edit
   and delete rules.
5. Return to Patron categories.
6. Add a new patron category with a "-" in the patron category code.
7. Return to Record overlay rules page:
   => The page doesn't display and load correctly (see the attached
      image) - the normal DataTables header and footer aren't
      displayed, and you can't add, edit or delete overlay rules.
  => If you turn on web developer tools, an error is displayed in the
     console: "Uncaught SyntaxError: missing : after property id".
8. Apply the patch.
9. Repeat the step 7, the Record overlay rules page should now
   display correctly and you should be able to add, edit and
   delete rules.
10. Sign off.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 13 Marcel de Rooy 2023-05-12 08:38:55 UTC
Created attachment 151120 [details] [review]
Bug 33335: Use To.json to serialize

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 14 Marcel de Rooy 2023-05-12 08:38:57 UTC
Created attachment 151121 [details] [review]
Bug 33335: (QA follow-up) Polishing and comments

Just send the codes and descriptions only to client.
Adding a few comments to the reduce construction.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 15 Tomás Cohen Arazi 2023-05-12 20:54:33 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 16 Matt Blenkinsop 2023-05-15 13:08:51 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 17 Lucas Gass 2023-06-15 19:39:21 UTC
Backported to 22.05.x for upcoming 22.05.14
Comment 18 Danyon Sewell 2023-07-20 04:27:48 UTC
Not backporting for 21.11.x