This line in the MARC modification template is problematic because if "ActionsLoop" doesn't exist it creates a JS error. var mmtas = [% ActionsLoop.json | $raw %] Normally the solution would be to wrap the variable in quotes: var mmtas = "[% ActionsLoop.json | $raw %]"; ...but that causes an error if ActionsLoop *is* defined. We need some logic for determining how the script is generated.
Created attachment 121280 [details] [review] Bug 28423: JavaScript error on MARC modifications page This patch makes a minor change to the MARC modifications template so that the "mmtas" variable isn't defined if there is no JSON to be assigned as its value. To test, apply the patch and go to Administration -> MARC modification templates. - If necessary, add a template with at least one action. - Check the browser console, there should be no errors. - Click the "Edit" button corresponding to one of the template actions. - The details of the action should load correctly in the edit form and there should be no errors in the console.
Created attachment 121303 [details] [review] Bug 28423: JavaScript error on MARC modifications page This patch makes a minor change to the MARC modifications template so that the "mmtas" variable isn't defined if there is no JSON to be assigned as its value. To test, apply the patch and go to Administration -> MARC modification templates. - If necessary, add a template with at least one action. - Check the browser console, there should be no errors. - Click the "Edit" button corresponding to one of the template actions. - The details of the action should load correctly in the edit form and there should be no errors in the console. Signed-off-by: David Nind <david@davidnind.com>
Testing notes (koha-testing-docker): - Error message in the browser console when going to Staff interface home > Tools > Catalog > MARC modification templates before applying the patch was: "Uncaught SyntaxError: expected expression, got end of script" - Adding and editing new templates worked as expected - After applying the patch there was no console error
Created attachment 121327 [details] [review] Bug 28423: JavaScript error on MARC modifications page This patch makes a minor change to the MARC modifications template so that the "mmtas" variable isn't defined if there is no JSON to be assigned as its value. To test, apply the patch and go to Administration -> MARC modification templates. - If necessary, add a template with at least one action. - Check the browser console, there should be no errors. - Click the "Edit" button corresponding to one of the template actions. - The details of the action should load correctly in the edit form and there should be no errors in the console. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Pushed to master for 21.11, thanks to everybody involved!
Pushed to 21.05.x for 21.05.02
Pushed to 20.11.x for 20.11.08
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.