From b955afac623bc875f9db2ea2ba85f5c156bb037f Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 18 Mar 2026 11:30:30 -0400 Subject: [PATCH] Bug 42128: Remove event attribute from admin-icon-selection.inc This patch removes the "onmousedown" event attribute from admin-icon-selection.inc, an include used in itemtypes.tt and authorised_values.tt. I took this opportunity to create separate JS files for both of those templates and added the event handler to the JS. To test, apply the patch and go to Administration. - Go to Item types and add or edit an item type. - In the icon selection section, select one of the built-in icons. - Switch to the "Remove image" tab. - Click the text input. The corresponding radio button should be selected. - Go to Authorized values and perform the same test. Sponsored-by: Athens County Public Libraries Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Lucas Gass --- .../prog/en/includes/admin-icon-selection.inc | 4 +- .../en/modules/admin/authorised_values.tt | 48 +----------------- .../prog/en/modules/admin/itemtypes.tt | 36 +------------ .../prog/js/pages/authorised_values.js | 50 +++++++++++++++++++ .../intranet-tmpl/prog/js/pages/itemtypes.js | 32 ++++++++++++ 5 files changed, 86 insertions(+), 84 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/pages/authorised_values.js create mode 100644 koha-tmpl/intranet-tmpl/prog/js/pages/itemtypes.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-icon-selection.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-icon-selection.inc index 189a737e67..2f352a72c8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-icon-selection.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-icon-selection.inc @@ -74,11 +74,11 @@ [% IF image_location.match('^http') %] - + [% ELSE %] - + [% END %] [% END %] [% END # /tab_panels %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt index 0a6f7f728c..232a11d1f3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt @@ -403,53 +403,7 @@ [% Asset.js("js/admin-menu.js") | $raw %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'select2.inc' %] - + [% Asset.js("js/pages/authorised_values.js") | $raw %] [% END %] [% BLOCK category_descriptions %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index f5bd2e4ffc..46e67b69ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -554,41 +554,7 @@ table_settings['columns'].shift(); // Remove item type image column from configuration [% END %] - + [% Asset.js("js/pages/itemtypes.js") | $raw %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/authorised_values.js b/koha-tmpl/intranet-tmpl/prog/js/pages/authorised_values.js new file mode 100644 index 0000000000..34e9dfe03d --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/authorised_values.js @@ -0,0 +1,50 @@ +$(document).ready(function () { + $("#categoriest").kohaTable({ + order: [[0, "asc"]], + pagingType: "full", + }); + + if ($("#branches option:selected").length < 1) { + $("#branches option:first").attr("selected", "selected"); + } + + $(".delete").click(function () { + return confirm( + __("Are you sure you want to delete this authorized value?") + ); + }); + $("#category_search").change(function () { + $("#category").submit(); + }); + + $("#delete_category").on("submit", function () { + return confirm( + __( + "Are you sure you want to delete this authorized value category?" + ) + ); + }); + + if ($("#icons .tab-pane.active").length < 1) { + $("#icons a:first").tab("show"); + } + + $("#Aform").submit(function () { + if ($("#authorised_value").length) { + if (!$("#authorised_value").get(0).checkValidity()) { + alert(__("Authorised value should be numeric.")); + $("#authorised_value").focus(); + return false; + } + } + return true; + }); + + if ($("#library_limitation").length > 0) { + $("#library_limitation")[0].style.minWidth = "450px"; + $("#library_limitation").select2(); + } + $("#remoteimage").on("mousedown", function () { + document.getElementById("remote_image_check").checked = true; + }); +}); diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/itemtypes.js b/koha-tmpl/intranet-tmpl/prog/js/pages/itemtypes.js new file mode 100644 index 0000000000..65e05fcefa --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/itemtypes.js @@ -0,0 +1,32 @@ +$(document).ready(function () { + $("#table_item_type").kohaTable( + { + pagingType: "full", + }, + table_settings + ); + + $("#itemtypeentry").validate({ + rules: { + itemtype: { required: true }, + description: { required: true }, + rentalcharge: { number: true }, + rentalcharge_hourly: { number: true }, + defaultreplacecost: { number: true }, + }, + }); + $("#itemtype").on("blur", function () { + toUC(this); + }); + if ($("#icons .tab-pane.active").length < 1) { + $("#icons a:first").tab("show"); + } + + if ($("#library_limitation").length > 0) { + $("#library_limitation")[0].style.minWidth = "450px"; + $("#library_limitation").select2(); + } + $("#remoteimage").on("mousedown", function () { + document.getElementById("remote_image_check").checked = true; + }); +});