Bugzilla – Attachment 185625 Details for
Bug 40683
Use DataTables Select plugin for handling selections across multiple pages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40683: WIP
Bug-40683-WIP.patch (text/plain), 8.76 KB, created by
Nick Clemens (kidclamp)
on 2025-08-21 12:35:01 UTC
(
hide
)
Description:
Bug 40683: WIP
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-08-21 12:35:01 UTC
Size:
8.76 KB
patch
obsolete
>From 99f56bac30adec17b246e7dda0da382260385a46 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 21 Aug 2025 12:32:39 +0000 >Subject: [PATCH] Bug 40683: WIP > >This patch adds a row id which allows the slection to work across pages > >I played with making the Rigth side export buttons use selected rows - they all work on visible rows at this time > >We need to fully implement "Select none" to clear across pages > >Right now the row selection doesn't always match the checkboxes > >Basically, this needs a lot of work :-) >--- > .../catalogue/itemsearch_item.json.inc | 2 +- > .../prog/en/modules/catalogue/itemsearch.tt | 55 ++----------------- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 17 +++++- > 3 files changed, 23 insertions(+), 51 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc >index 2367c59f1b2..d2e9652c1dc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc >@@ -8,7 +8,7 @@ > [%- biblioitem = item.biblioitem -%] > [ > "[% FILTER escape_quotes = replace('"', '\"') ~%] >- <input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" /> >+ <input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" data-itemnumber="[% item.itemnumber | html %]" id="[% item.itemnumber | html %]" /> > [%~ END %]", > "[% FILTER escape_quotes ~%] > <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]" title="Go to record detail page">[% INCLUDE 'biblio-title.inc' | trim | collapse %]</a >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >index a050fdf52e7..f78d3579f66 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >@@ -430,7 +430,8 @@ > } > > function exportItems(format) { >- let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || []; >+ var the_table = $("#results").DataTable(); >+ var item_search_selections = the_table.select.cumulative().rows; > if (item_search_selections.length > 0) { > var href = '/cgi-bin/koha/catalogue/item-export.pl?format=' + format; > href += '&itemnumber=' + Array.from( item_search_selections ).join('&itemnumber='); >@@ -442,19 +443,6 @@ > } > } > >- function prepSelections(){ >- let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || []; >- if( item_search_selections.length > 0 ){ >- showItemSelections( item_search_selections.length ); >- $("#results input[type='checkbox']").each(function(){ >- var itemnumber = $(this).val(); >- if( item_search_selections.indexOf( itemnumber ) >= 0 ){ >- $(this).prop("checked", true ); >- } >- }); >- } >- } >- > function getParams($form) { > var params = []; > $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() { >@@ -649,6 +637,7 @@ > "destroy": true, > "serverSide": true, > "processing": true, >+ "select": { "style": "multi", "selector": "td:first-child" }, > "ajax": { > url: '/cgi-bin/koha/catalogue/itemsearch.pl', > data: function ( d ) { >@@ -692,15 +681,12 @@ > { 'name': 'date_due' }, > { 'name': 'actions', 'orderable': false, searchable: false, } > ], >+ "rowId": [6], > "pagingType": "full_numbers", >- "drawCallback": function( settings ) { >- prepSelections(); >- }, > fixedHeader: false // There is a bug on this view > }, table_settings, true, null, filters_options ); > > $('#results').on('draw.dt', function (e, settings) { >- prepSelections(); > $('[data-bs-toggle="tooltip"]').tooltip(); > }); > } >@@ -763,36 +749,6 @@ > }); > }); > >- $("body").on("click", "#clear-row-selection", function(e){ >- e.preventDefault(); >- $("#results input[type='checkbox']").prop("checked" ,false ).change(); >- localStorage.removeItem("item_search_selections"); >- showItemSelections( 0 ); >- }); >- >- $("body").on('change', '#results input[type="checkbox"]', function() { >- let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || []; >- var itemnumber = $(this).val(); >- if( $(this).prop("checked") ){ >- item_search_selections.push( $(this).val() ); >- localStorage.setItem('item_search_selections', JSON.stringify( item_search_selections )); >- showItemSelections( item_search_selections.length ); >- } else { >- var filtered = item_search_selections.filter(function( value ){ >- return value !== itemnumber; >- }); >- if( filtered.length > 0 ){ >- localStorage.setItem('item_search_selections', JSON.stringify( filtered )); >- item_search_selections = filtered; >- showItemSelections( filtered.length ); >- } else { >- item_search_selections = []; >- localStorage.removeItem('item_search_selections'); >- showItemSelections( 0 ); >- } >- } >- }); >- > $("body").on("click", "#csvExportLink", function(e){ > e.preventDefault(); > exportItems('csv'); >@@ -822,7 +778,8 @@ > .attr("name", "del") > .attr("id", "batch_mod_del") > ); >- let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || []; >+ var the_table = $("#results").DataTable(); >+ var item_search_selections = the_table.select.cumulative().rows; > // Populate batch forms with itemnumbers in local storage > for (let item of item_search_selections){ > var field = $("<input>").attr("type","hidden") >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 28d1cf5eee8..6ecc3c5d961 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -38,6 +38,7 @@ var dataTablesDefaults = { > }, > dom: '<"dt-info"i><"top pager"<"table_entries"lp><"table_controls"fB>>tr<"bottom pager"ip>', > buttons: [ >+ "selectNone", > { > fade: 100, > className: "dt_button_clear_filter", >@@ -75,7 +76,7 @@ var dataTablesDefaults = { > }, > }; > DataTable.defaults.column.orderSequence = ["asc", "desc"]; >- >+//select: { style: 'multi',selector: 'td:first-child' }, > function toggledClearFilter(searchText, tableId) { > let clear_filter_button = $("#" + tableId + "_wrapper").find( > ".dt_button_clear_filter" >@@ -837,6 +838,19 @@ function _dt_buttons(params) { > format: export_format_spreadsheet, > }, > }, >+ { >+ extend: "excelHtml5", >+ text: _("Export selected to excel"), >+ exportOptions: { >+ columns: exportColumns, >+ format: export_format_spreadsheet, >+ // rows: function(idx, data, node) { >+ // console.log( idx, $(node).find('td:first-child input[type="checkbox"]').is(':checked') ); >+ // return $(node).find('td:first-child input[type="checkbox"]').is(':checked'); >+ // }, >+ modifier: { selected: true }, >+ }, >+ }, > { > extend: "csvHtml5", > exportOptions: { >@@ -875,6 +889,7 @@ function _dt_buttons(params) { > node.addClass("disabled"); > }, > }); >+ buttons.push("selectNone"); > > // Retrieving bKohaColumnsUseNames from the options passed to the constructor, not DT's settings > // But ideally should be retrieved using table.data() >-- >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 40683
:
185624
| 185625