From 10e671c0ac5c5bf30c60c6b300b8b9ae2fd2feb7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 16 Jul 2024 07:11:46 +0100 Subject: [PATCH] Bug 19037: Move test tool to includes --- .../prog/en/includes/circ-rule-tool.inc | 144 ++++++++++ .../prog/en/modules/admin/smart-rules.tt | 250 +----------------- .../intranet-tmpl/prog/js/circ-rule-tool.js | 99 +++++++ 3 files changed, 245 insertions(+), 248 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/circ-rule-tool.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/js/circ-rule-tool.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-rule-tool.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-rule-tool.inc new file mode 100644 index 00000000000..e34d2352d4a --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-rule-tool.inc @@ -0,0 +1,144 @@ +
+

Circulation and fine rules test tool

+

This test tool lets you search a row of circulation and fine rules for a specific patron, item and library.

+

Dropdown value for Library is determined via system preference CircControl. If the preference is set to item's library, then system preference HomeOrHoldingBranch defines the branch to use. You can test with any library by selecting the last option Library.

+ + + + + + + + + + + + + + + + + +
PatronItemLibraryActions
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LibraryPatron categoryItem typeCurrent checkouts allowedCurrent on-site checkouts allowedLoan periodUnitHard due dateFine amountFine charging intervalWhen to chargeFine grace periodOverdue fines cap (amount)Cap fine at replacement priceSuspension in days (day)Max. suspension duration (day)Renewals allowed (count)Renewal periodNo renewal beforeAutomatic renewalNo automatic renewal afterNo automatic renewal after (hard limit)Holds allowed (count)Holds per record (count)On shelf holds allowedItem level holdsArticle requestsRental discount (%)
+
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index f8382873772..9243ca88f59 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -73,153 +73,7 @@

The circulation and fine rules are applied based on the CircControl system preference which is set to [% Koha.Preference('CircControl') | html %] and the HomeOrHoldingBranch system preference which is set to [% Koha.Preference('HomeOrHoldingBranch') | html %].

-
- Circulation and fine rules test tool -
-

Circulation and fine rules test tool

-

This test tool lets you search a row of circulation and fine rules for a specific patron, item and library.

-

Dropdown value for Library is determined via system preference CircControl. If the preference is set to item's library, then system preference HomeOrHoldingBranch defines the branch to use. You can test with any library by selecting the last option Library.

- - - - - - - - - - - - - - - - - -
PatronItemLibraryActions
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LibraryPatron categoryItem typeCurrent checkouts allowedCurrent on-site checkouts allowedLoan periodUnitHard due dateFine amountFine charging intervalWhen to chargeFine grace periodOverdue fines cap (amount)Cap fine at replacement priceSuspension in days (day)Max. suspension duration (day)Renewals allowed (count)Renewal periodNo renewal beforeAutomatic renewalNo automatic renewal afterNo automatic renewal after (hard limit)Holds allowed (count)Holds per record (count)On shelf holds allowedItem level holdsArticle requestsRental discount (%)
-
-
-
+ [% INCLUDE 'circ-rule-tool.inc' %]
[% UNLESS restricted_to_own_library %] @@ -1580,6 +1434,7 @@ [% MACRO jsinclude BLOCK %] [% Asset.js("js/admin-menu.js") | $raw %] + [% Asset.js("js/circ-rule-tool.js") | $raw %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -1617,88 +1472,6 @@ $(edit_row).find("td:last input[name='clear']").remove(); } - function change_tester_input(el) { - $(el).parent().find("span").css("display", "none"); - $(el).parent().find("span").eq($("option:selected", el).index()).css("display", "inline"); - } - - function reset_tester_results() { - $("td[id^='tester_res_']").each(function() { - $(this).html(""); - }); - } - - function tester_submit() { - var query_params = {}; - $.each($("input[name^=tester_input_], select[name^=tester_input_]"), function () { - if ($(this).parent().css("display") === "none") { - return true; - } - var param = $(this).attr("name").replace("tester_input_", ""); - if ($(this).val() || param === 'branchcode' && !$(this).val()) { - query_params[param] = $(this).val(); - } - }); - $.ajax({ - url: "/api/v1/circulation_rules?"+$.param(query_params), - method: "GET", - statusCode: { - 200: function(response) { - $("#tester_error").html("").css("display","none"); - $.each(response, function (key,val) { - if (key === "hardduedate") { - var compare; - switch (response.hardduedatecompare) { - case -1: - compare = _("Before"); - break; - case 0: - compare = _("Exactly on"); - break; - case 1: - compare = _("After"); - break; - default: - compare = _("Exactly on"); - break; - } - val = "("+compare+") " + response.hardduedate; - } - if (val === "*") { - val = _("All"); - } - $("#tester_res_"+key).html("" + val); - }); - }, - 400: function(xhr) { - $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); - reset_tester_results(); - }, - 404: function(xhr) { - $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); - reset_tester_results(); - }, - 401: function(xhr) { - $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); - reset_tester_results(); - }, - 403: function(xhr) { - $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); - reset_tester_results(); - }, - 500: function(xhr) { - $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); - reset_tester_results(); - }, - 503: function(xhr) { - $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); - reset_tester_results(); - } - }, - dataType: "json" - }); - } - var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone."); $(document).ready(function() { @@ -1908,25 +1681,6 @@ f.find("[name='branch']").val($(this).data('branch')); return f.submit(); }); - - $("#issuing-rules-tester-container").css("display", "none"); - $("#toggle-tester").click(function() { - $("#issuing-rules-tester-container").toggle(); - }); - $("#tester_patron").val("cardnumber"); - $("#tester_item").val("barcode"); - $("#tester_branch").val($("#tester_branch option:first").val()); - change_tester_input($("#tester_patron")); - change_tester_input($("#tester_item")); - change_tester_input($("#tester_branch")); - $("select[id^='tester_']").change(function(e) { - change_tester_input(this); - }); - - tester_submit(); - $("#tester_submit").click(function () { - tester_submit(); - }); }); [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/circ-rule-tool.js b/koha-tmpl/intranet-tmpl/prog/js/circ-rule-tool.js new file mode 100644 index 00000000000..59e291ccd12 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/circ-rule-tool.js @@ -0,0 +1,99 @@ +function change_tester_input(el) { + $(el).parent().find("span").css("display", "none"); + $(el).parent().find("span").eq($("option:selected", el).index()).css("display", "inline"); +} + +function reset_tester_results() { + $("td[id^='tester_res_']").each(function () { + $(this).html(""); + }); +} + +function tester_submit() { + var query_params = {}; + $.each($("input[name^=tester_input_], select[name^=tester_input_]"), function () { + if ($(this).parent().css("display") === "none") { + return true; + } + var param = $(this).attr("name").replace("tester_input_", ""); + if ($(this).val() || param === 'branchcode' && !$(this).val()) { + query_params[param] = $(this).val(); + } + }); + $.ajax({ + url: "/api/v1/circulation_rules?" + $.param(query_params), + method: "GET", + statusCode: { + 200: function (response) { + $("#tester_error").html("").css("display", "none"); + $.each(response, function (key, val) { + if (key === "hardduedate") { + var compare; + switch (response.hardduedatecompare) { + case -1: + compare = _("Before"); + break; + case 0: + compare = _("Exactly on"); + break; + case 1: + compare = _("After"); + break; + default: + compare = _("Exactly on"); + break; + } + val = "(" + compare + ") " + response.hardduedate; + } + if (val === "*") { + val = _("All"); + } + $("#tester_res_" + key).html("" + val); + }); + }, + 400: function (xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 404: function (xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 401: function (xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 403: function (xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 500: function (xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 503: function (xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + } + }, + dataType: "json" + }); +} + +$(document).ready(function () { + $("#tester_patron").val("cardnumber"); + $("#tester_item").val("barcode"); + $("#tester_branch").val($("#tester_branch option:first").val()); + change_tester_input($("#tester_patron")); + change_tester_input($("#tester_item")); + change_tester_input($("#tester_branch")); + $("select[id^='tester_']").change(function (e) { + change_tester_input(this); + }); + + tester_submit(); + $("#tester_submit").click(function () { + tester_submit(); + }); +}); + -- 2.45.2