Bugzilla – Attachment 189065 Details for
Bug 41101
Allow extended patron attribute to be non-editable in the staff interface.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41101: Add ability to make patron extended attributes read-only in staff interface.
Bug-41101-Add-ability-to-make-patron-extended-attr.patch (text/plain), 13.60 KB, created by
CJ Lynce
on 2025-11-04 20:52:16 UTC
(
hide
)
Description:
Bug 41101: Add ability to make patron extended attributes read-only in staff interface.
Filename:
MIME Type:
Creator:
CJ Lynce
Created:
2025-11-04 20:52:16 UTC
Size:
13.60 KB
patch
obsolete
>From d12d3a72a30afb83049133d46198204cca4aa363 Mon Sep 17 00:00:00 2001 >From: CJ Lynce <cj.lynce@westlakelibrary.org> >Date: Sat, 25 Oct 2025 20:49:23 +0000 >Subject: [PATCH] Bug 41101: Add ability to make patron extended attributes > read-only in staff interface. > >This patch adds the ability for a Patron Extended Attrtibute to be marked as read-only > in the staff interface for all staff users, except 'superlibrarian's. > This allows patron attributes to be used by plugins or other features to track > statuses without allow staff users to change these attributes and cause > potential unintended issues, while still allowing the statuses to be visible to > staff. > >Testing PREP WORK >A. Create a new staff patron and assign the following permissions > i. Staff access, allows viewing of catalogue in staff interface (catalogue) > ii. Add, modify and view patron information (borrowers) >B. Create a couple of new 'Patron attribute types' under Administration > i. Vary the following settings > a. Staff interface mandatory > b. Authorized value category (include some with no authorized value) > c. Set some as data values. > >To Test >1. Apply patches, run updatedatabase, and restart_all services. >2. Login as 'koha' in the staff interface. >3. To go Administration -> Patron attribute types >4. For various attributes, do the following: > A. Check the "View-only in Staff interface:" > B. Verify 'OPAC mandatory' is unchecked and disabled when 'view-only' is checked. > C. Save these settings >5. Open a test patron and edit said patron. >6. Set values for various the extended patron attributes. Leave some blank to test as well. >7. Logout of the 'koha' user. >8. Login to the staff interface with the user you created in PREP WORK A., above. >9. Open the same patron, and edit the patron. >10. Verify the following things related to the extended attributes. > A. Attrtibutes marked as view-only cannot be changed. > B. Date attributes marked as view-only cannot be changed, and do not show a datepicker. > C. Attributes marked as view-only do not have a Clear, remove, or X button to clear. >11. Change some information on the patron and save the patron. >12. In the Patron details view, verify that your attributes are unchanged and still populated. > >Sponsored-by: Westlake Porter Public Library <https://westlakelibrary.org> >--- > admin/patron-attr-types.pl | 2 ++ > .../en/modules/admin/patron-attr-types.tt | 20 ++++++++++++ > .../prog/en/modules/members/memberentrygen.tt | 32 +++++++++++++++---- > members/memberentry.pl | 1 + > 4 files changed, 49 insertions(+), 6 deletions(-) > >diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl >index 47c16306a8..13a7bd8c74 100755 >--- a/admin/patron-attr-types.pl >+++ b/admin/patron-attr-types.pl >@@ -115,6 +115,7 @@ sub add_update_attribute_type { > my $staff_searchable = $input->param('staff_searchable') ? 1 : 0; > my $searched_by_default = $input->param('searched_by_default') ? 1 : 0; > my $keep_for_pseudonymization = $input->param('keep_for_pseudonymization') ? 1 : 0; >+ my $staff_viewonly = $input->param('staff_viewonly') ? 1 : 0; > my $mandatory = $input->param('mandatory') ? 1 : 0; > my $opac_mandatory = $input->param('opac_mandatory') ? 1 : 0; > my $authorised_value_category = $input->param('authorised_value_category'); >@@ -152,6 +153,7 @@ sub add_update_attribute_type { > staff_searchable => $staff_searchable, > searched_by_default => $searched_by_default, > keep_for_pseudonymization => $keep_for_pseudonymization, >+ staff_viewonly => $staff_viewonly, > mandatory => $mandatory, > opac_mandatory => $opac_mandatory, > authorised_value_category => $authorised_value_category, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >index 631a41867b..f6ff5049e3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >@@ -184,6 +184,15 @@ > [% END %] > <span class="hint"> If checked, this field will be included in 'Standard' patron searches. Requires field to be marked as searchable above </span> > </li> >+ <li >+ ><label for="staff_viewonly">View-only in Staff interface: </label> >+ [% IF attribute_type AND attribute_type.staff_viewonly %] >+ <input type="checkbox" id="staff_viewonly" name="staff_viewonly" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" id="staff_viewonly" name="staff_viewonly" /> >+ [% END %] >+ <span class="hint">Check to make this attribute view-only, non-editable by staff in the staff interface.</span> >+ </li> > <li > ><label for="mandatory">Staff interface mandatory: </label> > [% IF attribute_type AND attribute_type.mandatory %] >@@ -460,6 +469,17 @@ > $("#branches option:first").attr("selected", "selected"); > } > >+ $("#staff_viewonly") >+ .change(function () { >+ if (this.checked) { >+ $("#mandatory").prop("checked", false); >+ $("#mandatory").attr("disabled", true).parent().attr("aria-disabled", "true"); >+ } else { >+ $("#mandatory").removeAttr("disabled").parent().removeAttr("aria-disabled"); >+ } >+ }) >+ .change(); >+ > $("#is_date") > .change(function () { > if (this.checked) { >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 6a296dd8ff..29814c32a7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -1527,7 +1527,12 @@ > <label for="[% patron_attribute.form_id | html %]">[% patron_attribute.description | html %]: </label> > [% END %] > [% IF ( patron_attribute.use_dropdown ) %] >- <select id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" [% IF patron_attribute.mandatory %]required="required"[% END %]> >+ <select >+ id="[% patron_attribute.form_id | html %]" >+ name="[% patron_attribute.form_id | html %]" >+ [% IF patron_attribute.mandatory %]required="required"[% END %] >+ [% IF ( patron_attribute.viewonly AND !CAN_user_superlibrarian ) %]disabled[% END %] >+ > > <option value=""></option> > [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %] > [% IF auth_val_loo.authorised_value == patron_attribute.value %] >@@ -1552,7 +1557,7 @@ > /> > [% ELSE %] > <textarea rows="2" cols="30" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" required="required"> >-[% patron_attribute.value | html %]</textarea >+ [% patron_attribute.value | html %]</textarea > > > [% END %] > [% ELSE %] >@@ -1564,18 +1569,33 @@ > maxlength="10" > size="10" > value="[% patron_attribute.value | html %]" >- class="flatpickr" >+ [% IF ( patron_attribute.viewonly AND !CAN_user_superlibrarian ) -%] >+ disabled >+ [%- ELSE -%] >+ class="flatpickr" >+ [%- END %] > /> > [% ELSE %] >- <textarea rows="2" cols="30" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]">[% patron_attribute.value | html %]</textarea> >+ <textarea >+ rows="2" >+ cols="30" >+ id="[% patron_attribute.form_id | html %]" >+ name="[% patron_attribute.form_id | html %]" >+ [% IF ( patron_attribute.viewonly AND !CAN_user_superlibrarian ) %]disabled[% END %] >+ > >+ [%- patron_attribute.value | html %]</textarea >+ > > [% END %] > [% END %] > [% END # /IF ( patron_attribute.use_dropdown ) %] >+ [% IF ( patron_attribute.viewonly AND !CAN_user_superlibrarian ) %] >+ <input type="hidden" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" value="[% patron_attribute.value | html %]" /> >+ [% END %] > <input type="hidden" id="[% patron_attribute.form_id | html %]_code" name="[% patron_attribute.form_id | html %]_code" value="[% patron_attribute.code | html %]" /> >- [% IF ( !patron_attribute.is_date ) %] >+ [% IF ( !patron_attribute.is_date AND ( !patron_attribute.viewonly || CAN_user_superlibrarian ) ) %] > <a href="#" class="clear_attribute"><i class="fa fa-fw fa-trash-can"></i> Clear</a> > [% END %] >- [% IF ( patron_attribute.repeatable ) %] >+ [% IF ( patron_attribute.repeatable AND ( !patron_attribute.viewonly || CAN_user_superlibrarian ) ) %] > <a href="#" class="clone_attribute"><i class="fa fa-fw fa-plus"></i> New</a> > [% END %] > [% IF patron_attribute.mandatory %]<span class="required">Required</span>[% END %] >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 50343bcc04..e531d4984e 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -959,6 +959,7 @@ sub patron_attributes_form { > category => $attr_type->authorised_value_category(), > category_code => $attr_type->category_code(), > mandatory => $attr_type->mandatory(), >+ viewonly => $attr_type->staff_viewonly(), > is_date => $attr_type->is_date(), > }; > if ( exists $attr_hash{ $attr_type->code() } ) { >-- >2.39.5
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 41101
:
189064
| 189065