Bug 36545: Use select2 in item search

This patch modifies the multi-select fields in the item search to use
the select2 framework.

To test:
1. Apply patch
2. Go to staff interface -> "Item search"
3. Check item search form and search for
      - Home library
      - Current library
      - Shelving location
      - Item type
      - Collection
      - Status
      - Lost
      - Withdrawn
      - Damaged
4. Search with multiple variations (nothing selected, only one value,
   multiple values, ...) If no value is selected this means that "All"
   values are searched
5. Check that the search is working well

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Michael Skarupianski 2024-04-09 14:00:15 +00:00 committed by Katrin Fischer
parent 822f19d6a4
commit b7fa695f68
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 17 additions and 9 deletions

View File

@ -185,28 +185,28 @@
</div>
</div>
<fieldset>
[% INCLUDE form_field_select name="homebranch" options = branches empty_option = "All libraries" %]
[% INCLUDE form_field_select name="holdingbranch" options = branches empty_option = "All libraries" %]
[% INCLUDE form_field_select name="homebranch" options = branches %]
[% INCLUDE form_field_select name="holdingbranch" options = branches %]
[% IF locations.size %]
[% INCLUDE form_field_select name="location" options = locations empty_option = "All locations" %]
[% INCLUDE form_field_select name="location" options = locations %]
[% END %]
</fieldset>
<fieldset>
[% INCLUDE form_field_select name="itype" options = itemtypes empty_option = "All item types" %]
[% INCLUDE form_field_select name="itype" options = itemtypes style="min-width:300px" %]
[% IF ccodes.size %]
[% INCLUDE form_field_select name="ccode" options = ccodes empty_option = "All collection codes" %]
[% INCLUDE form_field_select name="ccode" options = ccodes %]
[% END %]
[% IF notforloans.size %]
[% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %]
[% INCLUDE form_field_select name="notforloan" options = notforloans %]
[% END %]
[% IF itemlosts.size %]
[% INCLUDE form_field_select name="itemlost" options = itemlosts empty_option = "All statuses" %]
[% INCLUDE form_field_select name="itemlost" options = itemlosts %]
[% END %]
[% IF withdrawns.size %]
[% INCLUDE form_field_select name="withdrawn" options = withdrawns empty_option = "All statuses" %]
[% INCLUDE form_field_select name="withdrawn" options = withdrawns %]
[% END %]
[% IF damageds.size %]
[% INCLUDE form_field_select name="damaged" options = damageds empty_option = "All statuses" %]
[% INCLUDE form_field_select name="damaged" options = damageds %]
[% END %]
<div class="form-field">
<label class="form-field-label">Availability:</label>
@ -288,6 +288,7 @@
[% INCLUDE 'datatables.inc' %]
[% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
[% Asset.js("lib/hc-sticky/hc-sticky.js") | $raw %]
[% INCLUDE 'select2.inc' %]
<script>
var authorised_values = [% authorised_values_json | $raw %];
@ -722,6 +723,13 @@
checkbox.change();
}
});
// Apply select2 to all select fields having a "multiple" attribute
let selectFields = document.querySelectorAll('select[multiple]');
selectFields.forEach((selectField) => {
selectField.style.minWidth = '320px';
$(selectField).select2();
});
});
</script>
[% END %]