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> Signed-off-by: Michael Adamyk <madamyk@ckls.org> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> (cherry picked from commit21e2ee11fb
) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit8ea3e73edc
) Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
d28e035f4d
commit
b507f94108
2 changed files with 67 additions and 0 deletions
|
@ -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>
|
61
koha-tmpl/intranet-tmpl/prog/js/members-patron-selections.js
Normal file
61
koha-tmpl/intranet-tmpl/prog/js/members-patron-selections.js
Normal file
|
@ -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)
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
Loading…
Reference in a new issue