From 90e9097931f9ec7cc8ab34d9a2036ad364c7e6b6 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Fri, 17 Mar 2023 09:55:39 +0200 Subject: [PATCH] Bug 16223: Require fee limit only if "Lift after payment" is set as "Yes" Fee limit should only be required if restriction is meant to be lifted after payment. This patch makes "Fee limit" input field required based on value of "Lift after payment" select field. To test: 1. Create a new restriction. 2. "Lift after payment" should be set as "No". 3. Change value as "Yes". => "Fee limit" should now have "Required" text after input field. 4. Try to save restriction. => Text "This field is required" should be displayed after "Fee limit". 5. Change "Lift after payment" back to "No". => Both texts should now be lifted. Also test with existing restriction and make sure restrictions are still saved without problems. Sponsored-by: Koha-Suomi Oy Signed-off-by: Martin Renvoize --- .../prog/en/modules/admin/restrictions.tt | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/restrictions.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/restrictions.tt index 168c8482cc..8dcb994c4e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/restrictions.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/restrictions.tt @@ -119,16 +119,19 @@
  • - + [% IF restriction.lift_after_payment %] + + [% ELSE %] + + + [% END %] - Required
  • - - - Required + +
  • [% ELSE %]
  • @@ -142,17 +145,15 @@ Required
  • - - + + - Required
  • - - - Required + +
  • [% END %] @@ -264,6 +265,15 @@ [% ex.code | $raw %]: '[% ex.display_text | $raw %]', [% END %] }; + + //Require fee limit if "Lift after payment" is set true + $("#lift_after_payment").on("change", function(){ + if($(this).val() == 1){ + $("#fee_limit").prop("required",true).after('Required'); + } else { + $("#fee_limit").prop("required",false).nextAll().remove(); + } + }); [% Asset.js("js/restrictiontypes.js") | $raw %] [% END %] -- 2.40.0