From 07cd4a8657826ec10a71484b89b50efc5c51fa3b Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Mon, 10 Jul 2023 13:46:48 +0000
Subject: [PATCH] Bug 31731: Offer user a dropdown of authorized values instead
of a text field in preferences
This patch updates the system preferences interface so that preferences
which ask for a single authorized value can offer a dropdown menu of
choices instead of a text field.
The patch also updates a few existing preferences to use the new
feature: BundleLostValue, BundleNotLoanValue, and
ClaimReturnedLostValue.
To test, apply the patch and restart services.
- Go to Administration -> System preferences and search for "authorized
value."
- The search results should include the entries for BundleLostValue,
BundleNotLoanValue, and ClaimReturnedLostValue.
- Confirm that the dropdowns show the correct authorized value category
(LOST or NOT_LOAN)
- Confirm that setting or unsetting each of the preferences works
correctly.
Signed-off-by: Sam Lau <samalau@gmail.com>
---
admin/preferences.pl | 5 +++++
.../prog/en/modules/admin/preferences.tt | 14 +++++++++++---
.../en/modules/admin/preferences/circulation.pref | 6 ++++++
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/admin/preferences.pl b/admin/preferences.pl
index 45a5891c62..e43491c1ea 100755
--- a/admin/preferences.pl
+++ b/admin/preferences.pl
@@ -102,6 +102,11 @@ sub _get_chunk {
} elsif ( $options{choices} eq 'patron-categories' ) {
$options{choices} = { map { $_->categorycode => $_->description } Koha::Patron::Categories->search->as_list };
$add_blank = 1;
+ } elsif ( $options{'choices'} eq 'authval' ){
+ if( $options{'source'} ){
+ $options{'choices'} = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search( { category => $options{'source'} } )->as_list };
+ $add_blank = 1;
+ }
} else {
die 'Unrecognized source of preference values: ' . $options{'choices'};
}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt
index 1bc1458141..aa93e7e622 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt
@@ -131,9 +131,17 @@
[% ELSIF ( CHUNK.type_modalselect ) %]
<input type="text" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="modalselect preference preference-[% CHUNK.type | html %]" data-source="[% CHUNK.source | html %]" data-required="[% CHUNK.required | html %]" data-exclusions="[% CHUNK.exclusions | html %]" readonly="readonly" value="[% CHUNK.value | html %]"/>
[% ELSIF ( CHUNK.type_multiple ) %]
- <select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "choice" | html %]" multiple="multiple">
- [% FOREACH CHOICE IN CHUNK.CHOICES %][% IF ( CHOICE.selected ) %]<option value="[% CHOICE.value | html %]" selected="selected">[% ELSE %]<option value="[% CHOICE.value | html %]">[% END %][% CHOICE.text | html %]</option>[% END %]
- </select>
+ <select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "choice" | html %]" multiple="multiple">
+ [% FOREACH CHOICE IN CHUNK.CHOICES %]
+ [% IF ( CHOICE.selected ) %]
+ <option value="[% CHOICE.value | html %]" selected="selected">
+ [% ELSE %]
+ <option value="[% CHOICE.value | html %]">
+ [% END %]
+ [% CHOICE.text | html %]
+ </option>
+ [% END %]
+ </select>
[% ELSIF ( CHUNK.type_textarea )%]
[% IF ( CHUNK.syntax == "text/html" && Koha.Preference('UseWYSIWYGinSystemPreferences') ) %]
<textarea name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "short" | html %] mce" rows="20" cols="60">[% CHUNK.value | html %]</textarea>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
index ffe8481869..4a2975f51b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -1285,10 +1285,14 @@ Circulation:
-
- Use the <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=LOST">LOST</a> authorized value
- pref: BundleLostValue
+ choices: authval
+ source: LOST
- to represent 'missing from bundle' at return.
-
- Use the <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=NOT_LOAN">NOT_LOAN</a> authorized value
- pref: BundleNotLoanValue
+ choices: authval
+ source: NOT_LOAN
- to represent 'added to bundle' when an item is attached to bundle.
Return claims:
@@ -1304,6 +1308,8 @@ Circulation:
-
- Use the <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=LOST">LOST</a> authorized value
- pref: ClaimReturnedLostValue
+ choices: authval
+ source: LOST
- to represent 'claims returned'.
-
- Warn librarians that a patron has excessive return claims if the patron has claimed the return of more than
--
2.30.2