Bugzilla – Attachment 158526 Details for
Bug 34671
Collapsing fields in patron form allows saving without mandatory fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34671: Ignore validation if patron attribute field is hidden
Bug-34671-Ignore-validation-if-patron-attribute-fi.patch (text/plain), 5.40 KB, created by
ByWater Sandboxes
on 2023-11-06 14:15:51 UTC
(
hide
)
Description:
Bug 34671: Ignore validation if patron attribute field is hidden
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2023-11-06 14:15:51 UTC
Size:
5.40 KB
patch
obsolete
>From f48e84afdf1e88401381a400e27ada3a50c9af94 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Wed, 1 Nov 2023 13:38:08 +0200 >Subject: [PATCH] Bug 34671: Ignore validation if patron attribute field is > hidden > >Patron attributes not used by patron category are still present in >form as hidden and marked as required if they are set as >mandatory. This prevents saving patron when validation is >required also for hidden fields. This patch adds and removes class "ignore_validation" for these fields based on their visibility. > >To test: >1. Add patron attribute for patron category A and set it as mandatory. >2. Add patron with category B and fill in required fields. >3. Attempt to save. >=> Error is displayed above "Additional attributes and identifiers" >field set. >4. Apply this patch. >5. Repeat steps 2 and 3. >=> Save successfully. >6. Add new patron with category B, but this time change patrons >category as A from patron form. >=> Confirm that madatory patron attribute is displayed correctly >and without it patron cannot be saved. > >Sponsored-by: Koha-Suomi Oy >Signed-off-by: Kelly <kelly@bywatersolutions.com> >--- > .../prog/en/modules/members/memberentrygen.tt | 8 ++++++-- > koha-tmpl/intranet-tmpl/prog/js/members.js | 9 +++++++++ > 2 files changed, 15 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 7837d99efe..b728142e08 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -1559,14 +1559,18 @@ legend:hover { > [% END %] > [% FOREACH patron_attribute IN pa_loo.items %] > <li data-category_code="[% patron_attribute.category_code | html %]" data-pa_code="[% patron_attribute.code | replace('[^a-zA-Z0-9_-]', '') %]"> >- [% IF patron_attribute.mandatory %] >+ [% IF patron_attribute.mandatory && patron_attribute.category_code == patron_category.categorycode%] > <label for="[% patron_attribute.form_id | html %]" class="required" required="required">[% patron_attribute.description | html %]: </label> >+ [% ELSIF patron_attribute.mandatory && patron_attribute.category_code != patron_category.categorycode %] >+ <label for="[% patron_attribute.form_id | html %]" class="required ignore_validation" required="required">[% patron_attribute.description | html %]: </label> > [% ELSE %] > <label for="[% patron_attribute.form_id | html %]">[% patron_attribute.description | html %]: </label> > [% END %] > [% IF ( patron_attribute.use_dropdown ) %] >- [% IF patron_attribute.mandatory %] >+ [% IF patron_attribute.mandatory && patron_attribute.category_code == patron_category.categorycode %] > <select id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" required="required"> >+ [% ELSIF patron_attribute.mandatory && patron_attribute.category_code != patron_category.categorycode %] >+ <select id="[% patron_attribute.form_id | html %]" class="ignore_validation" name="[% patron_attribute.form_id | html %]" required="required"> > [% ELSE %] > <select id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]"> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js >index f49f11243f..af0f7d4e2f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js >@@ -74,6 +74,15 @@ function update_category_code(category_code) { > var min_length = $('select'+category_selector+' option:selected').data('pwdLength'); > var hint_string = __("Minimum password length: %s").format(min_length); > hint.html(hint_string); >+ >+ // Remove class ignore_validation from attribute field so it's validated >+ if($(mytables).find("li").is(":visible")){ >+ $(mytables).find("li").children('[id*="patron_attr"]').removeClass("ignore_validation"); >+ } >+ // Add class ignore_validation from attribute field to ignore validation >+ if($(mytables).find("li").is(":hidden")){ >+ $(mytables).find("li").children('[id*="patron_attr"]').addClass("ignore_validation"); >+ } > } > > function select_user(borrowernumber, borrower, relationship) { >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34671
:
155643
|
156145
|
156263
|
156264
|
156453
|
156454
|
158168
|
158299
|
158524
|
158525
| 158526