From c3364f655cc08410b2d59af45cb9ca37e22335b0 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Wed, 28 Oct 2020 02:44:28 +0000 Subject: [PATCH] Bug 26814: (SMART-RULES GUI) Disable hold rules when on-site option selected SMART-RULES GUI tag means that this patch will apply before Bug 15522. To test: 1. Apply patch 2. Go to Circulation and fine rules in staff client 3. Observe the main circulation rules matrix, observe the following columns: Holds allowed (total) Holds allowed (daily) Holds per record (count) On shelf holds allowed OPAC item level holds Article requests 4. Set "On-site checkout" to "No" or "On-site" 5. Observe the columns in step 3, they should now be disabled 6. Set "On-site checkout" to "All" 7. Observe the columns in step 3, they should now be enabled 8. Add a new rule: On-site checkout: "On-site" Current checkouts allowed: 1 and click Save. 9. Find the row you just added and press Edit. 10. Observe the columns in step 3, they should now be disabled 11. Press Edit for any other row where On-site checkout is "All" 12. Observe the columns in step 3, they should now be enabled Sponsored-by: The National Library of Finland --- .../prog/en/modules/admin/smart-rules.tt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) 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 a2287a9184..acc048c9c1 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 @@ -1012,6 +1012,36 @@ $(edit_row).find("td:last input[name='clear']").remove(); } + function disable_onsite_checkout_hold_rules() { + var onsite_checkout = $("#edit_row").find("select[name='onsite_checkout']"); + + var CANNOT_SET_HOLD_RULES_FOR_ONSITE_CHECKOUT = + _("Cannot set this rule when on-site checkout is defined"); + + var hold_related_rule_els = [ + $("input#reservesallowed"), + $("input#holds_per_record"), + $("input#holds_per_day"), + $("select#onshelfholds"), + $("select#opacitemholds"), + $("select#article_requests") + ]; + + // when onsite_checkout is selected (any other value than *), + // disable hold related input fields, because it makes no sense + // to set hold rules for a specific type of checkout + $.each(hold_related_rule_els, function (i, field) { + if (onsite_checkout.val() !== "*") { + $(field).attr("disabled", "disabled"); + $(field).val(""); + $(field).after('' + CANNOT_SET_HOLD_RULES_FOR_ONSITE_CHECKOUT + "") + } else { + $(field).removeAttr("disabled"); + $("span.hold_rule_disabled").remove(); + } + }); + } + var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone."); $(document).ready(function() { @@ -1112,8 +1142,16 @@ $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true); $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true); $("#default-circulation-rules tr:last td:eq(2) select").prop('disabled', true); + + disable_onsite_checkout_hold_rules(); + return false; }); + + $("select[id='matrixonsite_checkout']").change(function () { + disable_onsite_checkout_hold_rules(); + }); + $(".clear_edit").on("click",function(e){ e.preventDefault(); clear_edit(); -- 2.17.1