Bugzilla – Attachment 179669 Details for
Bug 37050
Add select2 to SQL report multi select
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37050: Add select2 to SQL reports multiselect
Bug-37050-Add-select2-to-SQL-reports-multiselect.patch (text/plain), 6.11 KB, created by
Brendan Lawlor
on 2025-03-24 18:16:50 UTC
(
hide
)
Description:
Bug 37050: Add select2 to SQL reports multiselect
Filename:
MIME Type:
Creator:
Brendan Lawlor
Created:
2025-03-24 18:16:50 UTC
Size:
6.11 KB
patch
obsolete
>From eb959e00d4ec67494d98bd7b49883090b69cd068 Mon Sep 17 00:00:00 2001 >From: Brendan Lawlor <blawlor@clamsnet.org> >Date: Wed, 29 Jan 2025 20:27:27 +0000 >Subject: [PATCH] Bug 37050: Add select2 to SQL reports multiselect > >This patch adds select 2 to multi-select parameter fields in >SQL reports. If no selections are made for a multi-select >all authorised values will be used by default. This allows reports >to be written where a multi select parameter is optional. > >To test: >1. Apply patch >2. Go to Reports and create a report from SQL > select * > from items > where > homebranch in <<Libraries|branches:in>> > and > itype in <<Item type|itemtypes:in>> >3. Run the report making multiple selections for each parameter > and making single selections for each parameter >4. Run the report making multiple selections for one parameter and no > selections in another parameter >5. Check that the results are as you would expect >6. On the results page click 'Show SQL code' >7. Confirm that the codes are included according to your selections >8. Note that when no selections are made for a parameter all codes are > used by defaut > >Sponsored-by: CLAMS >--- > koha-tmpl/intranet-tmpl/prog/css/select2.css | 5 +++ > .../modules/reports/guided_reports_start.tt | 39 +++++++++++-------- > 2 files changed, 28 insertions(+), 16 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/css/select2.css b/koha-tmpl/intranet-tmpl/prog/css/select2.css >index 8046026ea5..6880eaa3c0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/select2.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/select2.css >@@ -44,3 +44,8 @@ > .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { > margin-right: 3px; > } >+ >+.select2-container--default .select2-selection--multiple .select2-selection__rendered li { >+ clear: none; >+ width: auto; >+} >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index 55afc39ff0..735e5e0af7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -907,10 +907,12 @@ > [% ELSE %] > <li> > <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label> >- <select name="[%- sql_param.input.name | html -%]" tabindex="1" id="[%- sql_param.input.id | html -%]" [% IF sql_param.select_multiple %]multiple[% END %]> >- [% IF (sql_param.select_multiple) %] >- <option value="%" hidden></option> >- [% END %] >+ [% IF (sql_param.select_multiple) %] >+ <select name="[%- sql_param.input.name | html -%]" tabindex="1" id="[%- sql_param.input.id | html -%]" multiple> >+ <option value="[% sql_param.input.values.join("\n") | html %]" disabled="disabled"></option> >+ [% ELSE %] >+ <select name="[%- sql_param.input.name | html -%]" tabindex="1" id="[%- sql_param.input.id | html -%]"> >+ [% END %] > [% IF (sql_param.include_all) %] > <option value="%">All</option> > [% END %] >@@ -1711,24 +1713,22 @@ > [% Asset.css("lib/codemirror/highlight.css") | $raw %] > [% Asset.js( "js/mana.js" ) | $raw %] > [% Asset.js("js/form-submit.js") | $raw %] >+ [% INCLUDE 'select2.inc' %] > <script> > // if the report param form has multiselects override default form submission > if( $('#report_param_form').find('select[multiple]').length ) { >- $('#report_param_form').find('select[multiple]').each( function (i) { >- $(this).on('change', function() { >- var $selected = $(this).val().join('\n'); >- $(this).find('option:first').val($selected); >- }); >- }); >- > $('#report_param_form').on('submit', function(e) { > $('#report_param_form').find('select[multiple]').each( function (i) { >+ $(this).find('option:first').prop('disabled', false); >+ var selection; > if( $(this).find('option:selected').length === 0 ) { >- $(this).val(['%']); >- } >- else if( $(this).find('option:selected').length > 1 ) { >- var $selected = $('option:first', this).val(); >- $(this).val($selected); >+ selection = $(this).find('option:first').val(); >+ $(this).val(selection); >+ } else if( $(this).find('option:selected').length > 1 ) { >+ selection = $(this).val().join('\n'); >+ $(this).find('option:selected').prop('selected', false); >+ $(this).find('option:first').val(selection); >+ $(this).find('option:first').prop('selected', 'selected'); > } > }); > }); >@@ -2445,6 +2445,13 @@ > $("#limit").val( limit ); > $("#limitselect").submit(); > }); >+ >+ // 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(); >+ }); > }); > > $("#toggle_auto_links").on("click", function(e){ >-- >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 37050
:
167555
|
167659
|
167838
|
167839
|
167840
|
167841
|
169750
|
169751
|
169818
|
169819
|
171340
|
171341
|
171342
|
171957
|
171958
|
171959
|
177320
|
179669
|
179728
|
180618
|
181099
|
181100