Bug 39843: Use select2 for multiple selects on patron attributes and extend due dates pages

This patch adds Select2 functionality to the select[multiple] fields on
the patron attributes and batch extend due dates pages.

To test, apply the patch and go to Administration -> Patron attribute
types.

- Create or edit a patron attribute type.
- Test the "Library limitation" field: Selecting a single or multiple
  library and clearing selections.
- Save your changes and confirm that your selections were saved
  correctly.
- Perform the same test on Tools -> Batch extend due dates:
  - Test the patron categories, item types, and libraries fields.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Owen Leonard 2025-05-06 13:55:01 +00:00 committed by Katrin Fischer
parent 54abc78b72
commit 424b41b8d6
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 12 additions and 4 deletions

View File

@ -235,12 +235,12 @@
>
</li>
<li
><label for="branches">Library limitation: </label>
<select id="branches" name="branches" multiple size="10">
><label for="library_limitation">Library limitation: </label>
<select id="library_limitation" name="branches" multiple size="10">
<option value="">All libraries</option>
[% PROCESS options_for_libraries libraries => Branches.all( selected => attribute_type.library_limits ) %]
</select>
<div class="hint">Select "All libraries" if this attribute type should always be displayed. Otherwise select libraries you want to associate with this value. </div>
<div class="hint">Limits the use of this attribute to the selected libraries. </div>
</li>
<li>
<label for="category">Category: </label>
@ -406,6 +406,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'select2.inc' %]
<script>
$(document).ready(function () {
function toggle_search_default() {
@ -466,6 +467,9 @@
null
);
});
$("#library_limitation")[0].style.minWidth = "450px";
$("#library_limitation").select2();
});
</script>
[% END %]

View File

@ -87,7 +87,7 @@
<legend>Checkout criteria:</legend>
<ol>
<li>
<label for="categorycodes">Patrons' categories: </label>
<label for="categorycodes">Patrons categories: </label>
[% SET categories = Categories.all() %]
<select id="categorycodes" name="categorycodes" multiple="multiple">
[% FOREACH cat IN categories %]
@ -248,6 +248,7 @@
[% Asset.js("js/tools-menu.js") | $raw %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'select2.inc' %]
[% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
<script>
$(document).ready(function () {
@ -297,6 +298,9 @@
}
return true;
});
$("#extend_due_dates_form select[multiple]").css("minWidth", "450px");
$("#extend_due_dates_form select[multiple]").select2();
});
</script>
[% END %]