From d44523470508ccc3037a0918bb19c34f295b9f1a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 3 Dec 2025 10:52:07 -0500 Subject: [PATCH] Bug 41360: Add toolbar of buttons for batch modifications to transport cost matrix We can add a toolbar of buttons to A) batch enable all cells B) batch populate empty cells with a value C) batch disable empty cells Test plan: 1) Apply this patch 2) Visit the TCM editor 3) Try out the 3 new buttons, verify they behave correctly --- .../en/modules/admin/transport-cost-matrix.tt | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt index 0b1c848393e..501765d65fe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt @@ -37,6 +37,27 @@ [% WRAPPER 'main-container.inc' aside='admin-menu' %]

Transport cost matrix

+
+ Enable all cells + Disable empty cells +
+ + +
+
+ [% IF ( WARNING_transport_cost_matrix_off ) %]
Because the "UseTransportCostMatrix" system preference is currently not enabled, the transport cost matrix is not being used.
Go to the @@ -113,11 +134,13 @@ } alert(_("Cost must be expressed as a decimal number >= 0")); } + function disable_transport_cost_chg(e) { var input_name = e.name; var cost_id = input_name.replace(/disable_/, ""); // Parse the code_id out of the input name disable_transport_cost(cost_id, e.checked); } + function disable_transport_cost(cost_id, disable) { if (disable) { $("#celldiv_" + cost_id) @@ -131,6 +154,7 @@ .removeClass("disabled-transfer"); } } + function enable_cost_input(cost_id) { var cell = $("#celldiv_" + cost_id); var cost = $(cell).text(); @@ -158,20 +182,53 @@ $(f).find("input:disabled").prop("disabled", false); return true; } + $(document).ready(function () { $(".enable_cost_input").on("click", function () { var cost_id = $(this).data("cost-id"); enable_cost_input(cost_id); }); + $("body").on("blur", ".cost_input", function () { check_transport_cost(this); }); + $("body").on("change", ".disable_transport_cost", function () { disable_transport_cost_chg(this); }); + $("#cost_matrix_form").on("submit", function () { return form_submit(this); }); + + $("#enable_all_cells").on("click", function () { + $(".enable_cost_input").each(function () { + $(this).trigger("click"); + }); + + $(".disable_transport_cost") + .filter(":checked") + .each(function () { + $(this).trigger("click"); + }); + }); + + $("#disable_all_empty_cells").on("click", function () { + $(".cost_input").each(function () { + if ($(this).val() == "") { + $(this).siblings(".disable_transport_cost").filter(":not(:checked)").trigger("click"); + } + }); + }); + + $(".populate_empty_cells").on("click", function () { + var value = $(this).data("value"); + $(".cost_input").each(function () { + if ($(this).val() == "") { + $(this).val(value); + } + }); + }); }); [% END %] -- 2.50.1 (Apple Git-155)