From 9ebee4e8a8ca358490265f5cefb530264626d5ac Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Wed, 12 Jul 2023 17:02:22 +0300 Subject: [PATCH] Bug 33929: Resolved issue with "Export"/"Import" button click error This patch addresses an error that occurred when clicking the "Export" button within the genre/form authority framework (the same issue was observed with the "Import" button). The error message displayed in the console was as follows: "Uncaught Error: Syntax error, unrecognized expression: #exportModal_GENRE/FFORM4" The error was caused by special symbols, particularly the "/" in the code of the auth type. To fix this, the patch is using a plugin designed to handle character filtering for HTML IDs, "$HtmlId", instead of "html" that kept "/" in "GENRE/FFORM4" which was causing this problem. --- .../prog/en/modules/admin/authtypes.tt | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt index 0b7e8ae57f..402b72c1ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt @@ -1,5 +1,6 @@ [% USE raw %] [% USE Asset %] +[% USE HtmlId %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -100,7 +101,7 @@ Authority types › Administration › Koha <span class="label">Authority type</span> <input type="hidden" name="op" value="add_validate" /> <input type="hidden" name="checked" value="0" /> - <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" />[% authority_type.authtypecode | html %] + <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | $HtmlId %]" />[% authority_type.authtypecode | $HtmlId %] [% ELSE %] <div class="hint">10 characters maximum</div> <label for="authtypecode" class="required">Authority type: </label> @@ -142,7 +143,7 @@ Authority types › Administration › Koha <p>This record is used <strong>[% authorities_using_it | html %]</strong> times</p> <a class="cancel" href="/cgi-bin/koha/admin/authtypes.pl">Back to the list</a> [% ELSE %] - <h1>Confirm deletion of authority structure definition for <span class="ex">'[% authority_type.authtypetext | html %]' ([% authority_type.authtypecode | html %])</span></h1> + <h1>Confirm deletion of authority structure definition for <span class="ex">'[% authority_type.authtypetext | html %]' ([% authority_type.authtypecode | $HtmlId %])</span></h1> <form action="/cgi-bin/koha/admin/authtypes.pl" method="post"> <input type="hidden" name="op" value="delete_confirmed" /> <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" /> @@ -183,33 +184,33 @@ Authority types › Administration › Koha <td>[% authority_type.auth_tag_to_report | html %]</td> <td> <div class="btn-group dropup"> - <a class="btn btn-default btn-xs dropdown-toggle" id="authtypeactions[% authority_type.authtypecode | html %]" role="button" data-toggle="dropdown" href="#"> + <a class="btn btn-default btn-xs dropdown-toggle" id="authtypeactions[% authority_type.authtypecode | $HtmlId %]" role="button" data-toggle="dropdown" href="#"> Actions <b class="caret"></b></a> - <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="authtypeactions[% authority_type.authtypecode | html %]"> + <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="authtypeactions[% authority_type.authtypecode | $HtmlId %]"> <li><a href="auth_tag_structure.pl?authtypecode=[% authority_type.authtypecode | uri %]" class="button parameters"><i class="fa-solid fa-eye"></i> MARC structure</a></li> <li><a href="/cgi-bin/koha/admin/authtypes.pl?op=add_form&authtypecode=[% authority_type.authtypecode | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li> [% IF authority_type.authtypecode %]<li><a href="/cgi-bin/koha/admin/authtypes.pl?op=delete_confirm&authtypecode=[% authority_type.authtypecode | uri %]"><i class="fa fa-trash-can"></i> Delete</a></li>[% END %] <!-- Button to trigger modal --> - <li><a href="#" data-toggle="modal" data-target="#exportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" title="Export authority type (fields, subfields) to a spreadsheet file (.csv, .ods)"><i class="fa fa-upload"></i> Export</a></li> + <li><a href="#" data-toggle="modal" data-target="#exportModal_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]" title="Export authority type (fields, subfields) to a spreadsheet file (.csv, .ods)"><i class="fa fa-upload"></i> Export</a></li> <!-- Button to trigger modal --> - <li><a href="#" data-toggle="modal" data-target="#importModal_[% authority_type.authtypecode | html %][% loop.count | html %]" title="Import authority type (fields, subfields) from a spreadsheet file (.csv, .ods)"><i class="fa fa-download"></i> Import</a></li> + <li><a href="#" data-toggle="modal" data-target="#importModal_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]" title="Import authority type (fields, subfields) from a spreadsheet file (.csv, .ods)"><i class="fa fa-download"></i> Import</a></li> </ul> </div> <!-- Modal for export --> - <div class="modal" id="exportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" aria-hidden="true"> + <div class="modal" id="exportModal_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> - <h3 id="exportLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]">Export [% authority_type.authtypetext | html %] authority type</h3> + <h3 id="exportLabelexportModal_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]">Export [% authority_type.authtypetext | html %] authority type</h3> </div> - <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_[% authority_type.authtypecode | html %]" method="get" target="_blank" class="form_export"> + <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_[% authority_type.authtypecode | $HtmlId %]" method="get" target="_blank" class="form_export"> <div class="modal-body"> <fieldset> - <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" /> - <p><label for="csv_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | html %]" value="csv" id="csv_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]" checked="checked" /> Export to CSV spreadsheet</label></p> - <p><label for="ods_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | html %]" value="ods" id="ods_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]" /> Export to OpenDocument spreadsheet format</label></p> + <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | $HtmlId %]" /> + <p><label for="csv_type_export_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | $HtmlId %]" value="csv" id="csv_type_export_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]" checked="checked" /> Export to CSV spreadsheet</label></p> + <p><label for="ods_type_export_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | $HtmlId %]" value="ods" id="ods_type_export_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]" /> Export to OpenDocument spreadsheet format</label></p> </fieldset> </div> <div class="modal-footer"> @@ -222,19 +223,19 @@ Authority types › Administration › Koha </div> <!-- Modal for import --> - <div class="modal" id="importModal_[% authority_type.authtypecode | html %][% loop.count | html %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" aria-hidden="true"> + <div class="modal" id="importModal_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> - <h3 id="importLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]">Import [% authority_type.authtypecode | html %] authority type (fields and subfields) from a spreadsheet file (.csv, .ods)</h3> + <h3 id="importLabelexportModal_[% authority_type.authtypecode | $HtmlId %][% loop.count | html %]">Import [% authority_type.authtypecode | html %] authority type (fields and subfields) from a spreadsheet file (.csv, .ods)</h3> </div> - <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_i_[% authority_type.authtypecode | html %]" id="form_i_[% authority_type.authtypecode | html %]" method="post" enctype="multipart/form-data" class="form_import"> + <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_i_[% authority_type.authtypecode | $HtmlId %]" id="form_i_[% authority_type.authtypecode | $HtmlId %]" method="post" enctype="multipart/form-data" class="form_import"> <div class="modal-body"> - <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" /> + <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | $HtmlId %]" /> <input type="hidden" name="action" value="import" /> - <p><label for="file_import_[% authority_type.authtypecode | html %]">Upload file:</label> <input type="file" name="file_import_[% authority_type.authtypecode | html %]" id="file_import_[% authority_type.authtypecode | html %]" class="input_import" /></p> - <div id="importing_[% authority_type.authtypecode | html %]" style="display:none" class="importing"><img src="[% interface | html %]/[% theme | html %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div> + <p><label for="file_import_[% authority_type.authtypecode | $HtmlId %]">Upload file:</label> <input type="file" name="file_import_[% authority_type.authtypecode | $HtmlId %]" id="file_import_[% authority_type.authtypecode | $HtmlId %]" class="input_import" /></p> + <div id="importing_[% authority_type.authtypecode | $HtmlId %]" style="display:none" class="importing"><img src="[% interface | html %]/[% theme | html %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-default">Import</button> -- 2.41.0