Bugzilla – Attachment 167555 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 multi select
Bug-37050-Add-select2-to-SQL-reports-multi-select.patch (text/plain), 4.56 KB, created by
Brendan Lawlor
on 2024-06-06 20:07:29 UTC
(
hide
)
Description:
Bug 37050: Add select2 to SQL reports multi select
Filename:
MIME Type:
Creator:
Brendan Lawlor
Created:
2024-06-06 20:07:29 UTC
Size:
4.56 KB
patch
obsolete
>From f12db48a1bfd4a5c90672d00a29722972733a1c4 Mon Sep 17 00:00:00 2001 >From: Brendan Lawlor <blawlor@clamsnet.org> >Date: Thu, 6 Jun 2024 19:49:47 +0000 >Subject: [PATCH] Bug 37050: Add select2 to SQL reports multi select > >This patch adds select 2 to modifies multi-select parameter fields in SQL reports to use the select2 framework. If no selections are made for a multi select parameter all values will be used by default. > >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 >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. This allows the query to run when no selections are made instead of causing an error. It allows reports to be written where a multi select parameter is optional. >--- > .../modules/reports/guided_reports_start.tt | 25 ++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) > >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 50f7a65a4f..7378b2ef5e 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 >@@ -882,7 +882,6 @@ > <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label> > [% IF (sql_param.select_multiple) %] > <select name="[%- sql_param.input.name | html -%]" tabindex="1" id="[%- sql_param.input.id | html -%]" multiple> >- <option value="null" hidden></option> > [% ELSE %] > <select name="[%- sql_param.input.name | html -%]" tabindex="1" id="[%- sql_param.input.id | html -%]"> > [% END %] >@@ -1567,12 +1566,14 @@ > [% Asset.js( "lib/codemirror/highlight.js" ) | $raw %] > [% Asset.css("lib/codemirror/highlight.css") | $raw %] > [% Asset.js( "js/mana.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).prepend('<option hidden></option>'); > $(this).on('change', function() { > var $selected = $(this).val().join('\n'); > $(this).find('option:first').val($selected); >@@ -1581,8 +1582,16 @@ > > $('#report_param_form').on('submit', function(e) { > $('#report_param_form').find('select[multiple]').each( function (i) { >- var $selected = $('option:first', this).val(); >- $(this).val($selected); >+ if( $(this).find('option:selected').length ) { >+ var $selected = $('option:first', this).val(); >+ $(this).val($selected); >+ } >+ else { >+ let values = $.map( $(this).find('option'), function(o) { >+ return $(o).val(); >+ }).slice(1).join('\n'); >+ $(this).find('option:first').val(values).prop('selected', true); >+ } > }); > }); > } >@@ -2306,6 +2315,16 @@ > $("#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({ >+ closeOnSelect: false, >+ }); >+ }); >+ > }); > > $("#toggle_auto_links").on("click", function(e){ >-- >2.39.2
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