Bugzilla – Attachment 160907 Details for
Bug 34479
Clear saved patron search selections after certain actions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34479: Move patron selection history to a re-useable file
Bug-34479-Move-patron-selection-history-to-a-re-us.patch (text/plain), 5.14 KB, created by
Jonathan Druart
on 2024-01-12 09:54:39 UTC
(
hide
)
Description:
Bug 34479: Move patron selection history to a re-useable file
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-01-12 09:54:39 UTC
Size:
5.14 KB
patch
obsolete
>From f69af0966afd3a1cc2928f7c7f2991ba83c41317 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Mon, 27 Nov 2023 10:35:15 +0000 >Subject: [PATCH] Bug 34479: Move patron selection history to a re-useable file > >This patch takes some of the functionality for maintaining patron selections and moves it to a new file that can be used in other template files. It also introduces a new method for determining whether to delete the history after an operation is complete, along with an .inc file containing the checkbox that manages this > >Test plan: >1) Navigate to Patrons and run a search >2) Use the checkboxes to select some patrons and run the three different options in the menu bar: Add to patron list, Merge selected patrons, Batch patron modification. >3) For each operation, you should see a checkbox asking if you want to "Keep patrons selected for anew operation". N.B. For adding patrons to a list, you will only see this when selecting to add them to a new list >4) When you run the operations, if you select the checkbox to keep the patrons then when you return tho the patron search, those patrons should all be still selected. >5) If you don't check the box, when you return to the search, your patron selection history should be empty and no patrons should be selected >N.B. If you have run a merge operation and elected to keep the patron history, you will only keep the patron who was kept > >Signed-off-by: Sharon Dugdale <sharon.dugdale@cumberland.gov.uk> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../en/includes/members-patron-selections.inc | 6 ++ > .../prog/js/members-patron-selections.js | 61 +++++++++++++++++++ > 2 files changed, 67 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/members-patron-selections.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/members-patron-selections.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-patron-selections.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-patron-selections.inc >new file mode 100644 >index 00000000000..dfa54fab5f5 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-patron-selections.inc >@@ -0,0 +1,6 @@ >+ >+<span> >+ <input type="hidden" data-identifier="[% id | html %]" id="form-identifier"/> >+ <input type="checkbox" id="maintain_selections_[% id | html %]" /> >+ <label for="maintain_selections_[% id | html %]">Keep patrons selected for a new operation</label> >+</span> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members-patron-selections.js b/koha-tmpl/intranet-tmpl/prog/js/members-patron-selections.js >new file mode 100644 >index 00000000000..228cad32935 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/members-patron-selections.js >@@ -0,0 +1,61 @@ >+function persistPatronSelections(form) { >+ var selected_patrons; >+ var persistence_checkbox = $("#maintain_selections_" + form)[0]; >+ var persist = persistence_checkbox.checked >+ if (form === 'patron-merge-form' && persist) { >+ // We should only keep the id for the patron that is being kept in the merge >+ var keeper_checkboxes = $(".keeper") >+ var patron_to_keep = keeper_checkboxes.filter(":checked") >+ var patron_id = patron_to_keep[0].value >+ selected_patrons = [ patron_id ] >+ } else { >+ selected_patrons = persist ? JSON.parse(localStorage.getItem("patron_search_selections")) : []; >+ } >+ localStorage.setItem('patron_search_selections', JSON.stringify(selected_patrons)); >+} >+ >+function showPatronSelections(number) { >+ if (number === 0) { >+ $("#table_search_selections").hide() >+ } else { >+ $("#table_search_selections").show().find("span").text(_("Patrons selected: " + number)); >+ } >+} >+ >+function prepSelections() { >+ var selected_patrons = JSON.parse(localStorage.getItem("patron_search_selections")); >+ if (selected_patrons && selected_patrons.length > 0) { >+ showPatronSelections(selected_patrons.length); >+ >+ $('#merge-patrons').prop('disabled', true); >+ $("input.selection").each(function () { >+ var cardnumber = $(this).val(); >+ if (selected_patrons.indexOf(cardnumber) >= 0) { >+ $(this).prop("checked", true); >+ } >+ }); >+ >+ if (selected_patrons.length > 1) { >+ $('#batch-mod-patrons, #merge-patrons, #patronlist-menu').removeClass("disabled").prop('disabled', false); >+ } >+ } else { >+ showPatronSelections(0); >+ $('#merge-patrons').prop('disabled', true); >+ $("input.selection").each(function () { >+ $(this).prop("checked", false); >+ }); >+ $('#batch-mod-patrons, #merge-patrons, #patronlist-menu').addClass("disabled").prop('disabled', true); >+ } >+} >+ >+$(document).ready(function () { >+ var form_identifier = $("#form-identifier").data(); >+ if(form_identifier && form_identifier.hasOwnProperty('identifier') && form_identifier.identifier) { >+ var form_id = form_identifier.identifier; >+ if (form_id !== 'new-patron-list_form') { >+ $("#" + form_id).on("submit", function(e){ >+ persistPatronSelections(form_id) >+ }); >+ } >+ } >+}) >-- >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 34479
:
159261
|
159262
|
159275
|
159276
|
159295
|
159451
|
160906
|
160907
|
160982
|
161798