Bugzilla – Attachment 171957 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), 3.86 KB, created by
Biblibre Sandboxes
on 2024-09-25 21:58:04 UTC
(
hide
)
Description:
Bug 37050: Add select2 to SQL reports multi select
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2024-09-25 21:58:04 UTC
Size:
3.86 KB
patch
obsolete
>From b3d4c11639585be2b4cf72744d891cf6a372b921 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 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 >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> >--- > .../modules/reports/guided_reports_start.tt | 23 +++++++++++++++++++ > 1 file changed, 23 insertions(+) > >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 ed1e0cf7de..6737b73121 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 >@@ -1575,11 +1575,14 @@ > [% 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).prepend('<option hidden></option>'); > $(this).on('change', function() { > var $selected = $(this).val().join('\n'); > $(this).find('option:first').val($selected); >@@ -1588,6 +1591,16 @@ > > $('#report_param_form').on('submit', function(e) { > $('#report_param_form').find('select[multiple]').each( function (i) { >+ 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); >+ } > if( $(this).find('option:selected').length === 0 ) { > $(this).val(['%']); > } >@@ -2309,6 +2322,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.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