Bugzilla – Attachment 99160 Details for
Bug 18433
Allow to select results to export in item search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18433: Remember item search results selected rows in session storage
Bug-18433-Remember-item-search-results-selected-ro.patch (text/plain), 4.65 KB, created by
Jonathan Druart
on 2020-02-18 08:58:20 UTC
(
hide
)
Description:
Bug 18433: Remember item search results selected rows in session storage
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-02-18 08:58:20 UTC
Size:
4.65 KB
patch
obsolete
>From 195f1416d0096286490d673536a527d3f9b37edf Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 17 Jan 2020 10:17:42 +0100 >Subject: [PATCH] Bug 18433: Remember item search results selected rows in > session storage > >Session storage is not shared between browser tabs, and is cleared when >a tab is closed, so it seems like a good fit for storing selected rows > >Test plan: >1. Go to item search (intranet) and submit the form >2. Select some rows on the first page by clicking on checkboxes >3. Go to another page of results >4. Select more rows >5. Go back to the first page >6. Selected rows should still be checked >7. Play with sorting and filtering, and see that selected rows are > always checked >8. Export as CSV and as a barcodes file, verify that the export contains > all selected rows >9. Click on 'Clear selection', it should deselect all rows from all > pages >10. Select some rows again >11. Click on 'Edit search' and submit the same search >12. No row should be selected >13. Select some rows again >14. Refresh the page and submit again the same search >15. No row should be selected > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/en/modules/catalogue/itemsearch.tt | 44 ++++++++++++++++++---- > 1 file changed, 36 insertions(+), 8 deletions(-) > >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 a9ad87d0c5..578639af2e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >@@ -315,14 +315,22 @@ > $('#item-search-block').show(); > }); > >+ function getCheckedItemnumbers () { >+ var itemnumbers; >+ try { >+ itemnumbers = JSON.parse(sessionStorage.getItem('itemsearch_itemnumbers') || '[]'); >+ } catch (e) { >+ itemnumbers = []; >+ } >+ >+ return new Set(itemnumbers); >+ } >+ > function exportItems(format) { >- var itemnumbers = []; >- $('#results').find('input[name="itemnumber"]:checked').each(function() { >- itemnumbers.push($(this).val()); >- }); >- if (itemnumbers.length) { >+ var itemnumbers = getCheckedItemnumbers(); >+ if (itemnumbers.size > 0) { > var href = '/cgi-bin/koha/catalogue/item-export.pl?format=' + format; >- href += '&itemnumber=' + itemnumbers.join('&itemnumber='); >+ href += '&itemnumber=' + Array.from(itemnumbers).join('&itemnumber='); > location = href; > } else { > $('#format-' + format).prop('checked', true); >@@ -374,6 +382,7 @@ > .append(_("Clear selection")) > .on('click', function(e) { > e.preventDefault(); >+ sessionStorage.setItem('itemsearch_itemnumbers', '[]'); > $('#results input[type="checkbox"]').prop('checked', false).change(); > }); > var exportLinks = $('<p>') >@@ -491,11 +500,30 @@ > null > ] > }); >+ $('#results').on('draw.dt', function (e, settings) { >+ var itemnumbers = getCheckedItemnumbers(); >+ $(this).find('input[type="checkbox"][name="itemnumber"]').each(function () { >+ var itemnumber = this.value; >+ if (itemnumbers.has(itemnumber)) { >+ this.checked = true; >+ } >+ }); >+ }); >+ >+ sessionStorage.setItem('itemsearch_itemnumbers', '[]'); > > $('#results').on('change', 'input[type="checkbox"]', function() { >- var countSelected = $(this).parents('table').find('input:checked').length; >+ var itemnumber = this.value; >+ var itemnumbers = getCheckedItemnumbers(); >+ if (this.checked) { >+ itemnumbers.add(itemnumber); >+ } else { >+ itemnumbers.delete(itemnumber); >+ } >+ sessionStorage.setItem('itemsearch_itemnumbers', JSON.stringify(Array.from(itemnumbers))); >+ > var caret = ' <span class="caret">'; >- if (countSelected > 0) { >+ if (itemnumbers.size > 0) { > $('#export-button').html(_("Export selected results to") + caret); > } else { > $('#export-button').html(_("Export all results to") + caret); >-- >2.11.0
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 18433
:
62170
|
62181
|
62358
|
62388
|
62389
|
62390
|
62415
|
62416
|
62417
|
62449
|
62472
|
95380
|
97479
|
99123
|
99124
|
99159
| 99160 |
99161
|
99162