Bugzilla – Attachment 57764 Details for
Bug 14699
Intranet search history issues due to DataTables pagination
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14699: Fix intranet search history issues due to pagination
Bug-14699-Fix-intranet-search-history-issues-due-t.patch (text/plain), 5.09 KB, created by
Jonathan Druart
on 2016-11-25 08:25:24 UTC
(
hide
)
Description:
Bug 14699: Fix intranet search history issues due to pagination
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-11-25 08:25:24 UTC
Size:
5.09 KB
patch
obsolete
>From 8e7b02834fe5115d5bac96b7c654323786041ac3 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 20 Aug 2015 15:38:59 +0200 >Subject: [PATCH] Bug 14699: Fix intranet search history issues due to > pagination >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >DataTables removes hidden rows from the DOM. Because of that, "Select >all", "Clear all" and the form submission don't work correctly >(basically they act only on the currently displayed page). > >This patch fixes just that. > >Test plan: >1/ Go to your search history page >2/ Make you sure you have at least 21 entries in your search history. If >not, do some searches and come back here. >3/ Click "Select all" and change page. The checkboxes on the new page >should be checked. >4/ Check some checkboxes on this new page and click "Clear all". Go back >to the previous page, checkboxes shouldn't be checked. >5/ Check some checkboxes on at least 2 different pages and click >"Delete". All selected search history entries should be deleted. > >Followed test plan. Works as expected. >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > .../prog/en/modules/catalogue/search-history.tt | 56 ++++++++++++++++------ > 1 file changed, 42 insertions(+), 14 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt >index a31c4bc..240558a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt >@@ -23,33 +23,60 @@ $(document).ready(function() { > > $('#tabs').tabs(); > >+ // DataTables removes hidden rows from the DOM, so we can't expect a >+ // "regular" submit to work and we need to build another form containing >+ // all form elements, and then submit this form. >+ $('form').submit(function(e) { >+ e.preventDefault(); >+ >+ var form = $(this); >+ var table = form.find('table').dataTable(); >+ >+ var new_form = $('<form>') >+ .attr('action', form.attr('action')) >+ .attr('method', form.attr('method')); >+ form.find('input[type="hidden"]') >+ .add(table.$('input:checkbox:checked')) >+ .each(function() { >+ var input = $('<input type="hidden">') >+ .attr('name', $(this).attr('name')) >+ .attr('value', $(this).attr('value')); >+ new_form.append(input); >+ }); >+ $(document.body).append(new_form); >+ new_form.submit(); >+ }); >+ > $(".CheckNone").click(function(e){ > e.preventDefault(); >- var form = $(this).parents("form").get(0); >- $(form).unCheckCheckboxes(); >+ var form = $(this).parents("form").first(); >+ var table = form.find('table').dataTable(); >+ table.$('input[type="checkbox"]').attr('checked', false); > enableCheckboxActions(form); > }); > $(".CheckAll").click(function(e){ > e.preventDefault(); >- var form = $(this).parents("form").get(0); >- $(form).checkCheckboxes(); >+ var form = $(this).parents("form").first(); >+ var table = form.find('table').dataTable(); >+ table.$('input[type="checkbox"]').attr('checked', true); > enableCheckboxActions(form); > }); > > $("input:checkbox").click(function(){ >- var form = $(this).parents("form").get(0); >+ var form = $(this).parents("form").first(); > enableCheckboxActions(form); > }); > > $(".action_delete").click(function(e){ > e.preventDefault(); >- var form = $(this).parents("form").get(0); >- var ids = $(form).find("input:checkbox:checked"); >+ var form = $(this).parents("form").first(); >+ var table = form.find('table').dataTable(); >+ var ids = table.$("input:checkbox:checked"); > if ( $(ids).length < 1 ) { > return false; > } > if ( confirm(MSG_CONFIRM_DELETE_HISTORY) ) { >- $(form).submit(); >+ form.submit(); > } > return false; > }); >@@ -58,13 +85,14 @@ $(document).ready(function() { > > function enableCheckboxActions(form){ > // Enable/disable controls if checkboxes are checked >- var checkedBoxes = $(form).find("input:checkbox:checked"); >- if ($(checkedBoxes).size()) { >- $(form).find(".selections").html(_("With selected searches: ")); >- $(form).find(".selections-toolbar .links a").removeClass("disabled"); >+ var table = form.find('table').dataTable(); >+ var checkedBoxes = table.$("input:checkbox:checked"); >+ if (checkedBoxes.size()) { >+ form.find(".selections").html(_("With selected searches: ")); >+ form.find(".selections-toolbar .links a").removeClass("disabled"); > } else { >- $(form).find(".selections").html(_("Select searches to: ")); >- $(form).find(".selections-toolbar .links a").addClass("disabled"); >+ form.find(".selections").html(_("Select searches to: ")); >+ form.find(".selections-toolbar .links a").addClass("disabled"); > } > } > >-- >2.9.3
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 14699
:
41734
|
42330
|
42449
|
56313
|
57684
|
57685
| 57764 |
57765
|
57766