Line 0
Link Here
|
0 |
- |
1 |
function persistPatronSelections(form) { |
|
|
2 |
var selected_patrons; |
3 |
var persistence_checkbox = $("#maintain_selections_" + form)[0]; |
4 |
var persist = persistence_checkbox.checked |
5 |
if (form === 'patron-merge-form' && persist) { |
6 |
// We should only keep the id for the patron that is being kept in the merge |
7 |
var patron_id = $(".keeper")[0].value |
8 |
selected_patrons = [patron_id] |
9 |
} else { |
10 |
selected_patrons = persist ? JSON.parse(localStorage.getItem("patron_search_selections")) : []; |
11 |
} |
12 |
localStorage.setItem('patron_search_selections', JSON.stringify(selected_patrons)); |
13 |
} |
14 |
|
15 |
function showPatronSelections(number) { |
16 |
if (number === 0) { |
17 |
$("#table_search_selections").hide() |
18 |
} else { |
19 |
$("#table_search_selections").show().find("span").text(_("Patrons selected: " + number)); |
20 |
} |
21 |
} |
22 |
|
23 |
function prepSelections() { |
24 |
var selected_patrons = JSON.parse(localStorage.getItem("patron_search_selections")); |
25 |
if (selected_patrons && selected_patrons.length > 0) { |
26 |
showPatronSelections(selected_patrons.length); |
27 |
|
28 |
$('#merge-patrons').prop('disabled', true); |
29 |
$("input.selection").each(function () { |
30 |
var cardnumber = $(this).val(); |
31 |
if (selected_patrons.indexOf(cardnumber) >= 0) { |
32 |
$(this).prop("checked", true); |
33 |
} |
34 |
}); |
35 |
|
36 |
if (selected_patrons.length > 1) { |
37 |
$('#batch-mod-patrons, #merge-patrons, #patronlist-menu').removeClass("disabled").prop('disabled', false); |
38 |
} |
39 |
} else { |
40 |
showPatronSelections(0); |
41 |
$('#merge-patrons').prop('disabled', true); |
42 |
$("input.selection").each(function () { |
43 |
$(this).prop("checked", false); |
44 |
}); |
45 |
$('#batch-mod-patrons, #merge-patrons, #patronlist-menu').addClass("disabled").prop('disabled', true); |
46 |
} |
47 |
} |
48 |
|
49 |
$(document).ready(function () { |
50 |
var form_identifier = $("#form-identifier").data(); |
51 |
if(form_identifier && form_identifier.hasOwnProperty('identifier') && form_identifier.identifier) { |
52 |
var form_id = form_identifier.identifier; |
53 |
if (form_id !== 'new-patron-list_form') { |
54 |
$("#" + form_id).on("submit", function(e){ |
55 |
persistPatronSelections(form_id) |
56 |
}); |
57 |
} |
58 |
} |
59 |
}) |