Bugzilla – Attachment 174258 Details for
Bug 38310
DataTables - Use Select2 for column filters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38310: WIP - Add Select2 to column filters
Bug-38310-WIP---Add-Select2-to-column-filters.patch (text/plain), 2.56 KB, created by
Jonathan Druart
on 2024-11-07 15:57:43 UTC
(
hide
)
Description:
Bug 38310: WIP - Add Select2 to column filters
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-11-07 15:57:43 UTC
Size:
2.56 KB
patch
obsolete
>From 93a116cb1f1040683cc7c45ebb427f6b65d8c657 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 7 Nov 2024 16:57:01 +0100 >Subject: [PATCH] Bug 38310: WIP - Add Select2 to column filters > >This is not working, the "clear" behaviour is not applied. >When 'x' is clicked the Select2 option list is supposed to hide. >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 2 ++ > koha-tmpl/intranet-tmpl/prog/js/select2.js | 15 +++++++++++---- > 2 files changed, 13 insertions(+), 4 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 83d1253c8a2..13b9911fc45 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -783,6 +783,7 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { > > if (!$(table_node).length) return; > >+ $(table_node).find('thead tr:eq(1) select').select2('destroy'); > $(table_node).find('thead tr:eq(1)').remove(); // Remove if one exists already > $(table_node).find('thead tr').clone().appendTo( $(table_node).find('thead') ); > >@@ -820,6 +821,7 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { > o.appendTo(select); > }); > $(th).html( select ); >+ apply_select2(select); > } else { > var title = $(th).text(); > if ( existing_search ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/select2.js b/koha-tmpl/intranet-tmpl/prog/js/select2.js >index bc11558e11f..946719ea8a9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/select2.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/select2.js >@@ -27,9 +27,10 @@ $.fn.select2.defaults.set("language", { > removeItem:function(){return __("Remove item"); } > }); > >-$(document).ready(function(){ >- $(".select2").select2(); >- $(".select2").on("select2:clear", function () { >+function apply_select2(node){ >+ $(node).select2(); >+ $(node).on("select2:clear", function () { >+ console.log("clear"); > $(this).on("select2:opening.cancelOpen", function (evt) { > evt.preventDefault(); > >@@ -37,8 +38,14 @@ $(document).ready(function(){ > }); > }); > >- $(document).on("select2:open", function () { >+ /*$(document).on("select2:open", function () { > document.querySelector(".select2-container--open .select2-search__field").focus(); >+ });*/ >+} >+ >+$(document).ready(function(){ >+ $(".select2").each(function(){ >+ apply_select2(this); > }); > }); > >-- >2.34.1
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 38310
: 174258