From dc9ad357e11da7ce1011e6163ca02437332b76bd 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 Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- .../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 0acd70ca688..93cf49f5e44 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/restrictions.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/restrictions.tt @@ -115,16 +115,19 @@
  • - + [% IF restriction.lift_after_payment %] + + [% ELSE %] + + + [% END %] - Required
  • - - - Required + +
  • [% ELSE %]
  • @@ -138,17 +141,15 @@ Required
  • - - + + - Required
  • - - - Required + +
  • [% END %] @@ -257,6 +258,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.42.0