View | Details | Raw Unified | Return to bug 34479
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-patron-selections.inc (+6 lines)
Line 0 Link Here
1
2
<span>
3
    <input type="hidden" data-identifier="[% id | html %]" id="form-identifier"/>
4
    <input type="checkbox" id="maintain_selections_[% id | html %]" />
5
    <label for="maintain_selections_[% id | html %]">Keep patrons selected for a new operation</label>
6
</span>
(-)a/koha-tmpl/intranet-tmpl/prog/js/members-patron-selections.js (-1 / +61 lines)
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 keeper_checkboxes = $(".keeper")
8
        var patron_to_keep = keeper_checkboxes.filter(":checked")
9
        var patron_id = patron_to_keep[0].value
10
        selected_patrons = [ patron_id ]
11
    } else {
12
        selected_patrons = persist ? JSON.parse(localStorage.getItem("patron_search_selections")) : [];
13
    }
14
    localStorage.setItem('patron_search_selections', JSON.stringify(selected_patrons));
15
}
16
17
function showPatronSelections(number) {
18
    if (number === 0) {
19
        $("#table_search_selections").hide()
20
    } else {
21
        $("#table_search_selections").show().find("span").text(_("Patrons selected: " + number));
22
    }
23
}
24
25
function prepSelections() {
26
    var selected_patrons = JSON.parse(localStorage.getItem("patron_search_selections"));
27
    if (selected_patrons && selected_patrons.length > 0) {
28
        showPatronSelections(selected_patrons.length);
29
30
        $('#merge-patrons').prop('disabled', true);
31
        $("input.selection").each(function () {
32
            var cardnumber = $(this).val();
33
            if (selected_patrons.indexOf(cardnumber) >= 0) {
34
                $(this).prop("checked", true);
35
            }
36
        });
37
38
        if (selected_patrons.length > 1) {
39
            $('#batch-mod-patrons, #merge-patrons, #patronlist-menu').removeClass("disabled").prop('disabled', false);
40
        }
41
    } else {
42
        showPatronSelections(0);
43
        $('#merge-patrons').prop('disabled', true);
44
        $("input.selection").each(function () {
45
            $(this).prop("checked", false);
46
        });
47
        $('#batch-mod-patrons, #merge-patrons, #patronlist-menu').addClass("disabled").prop('disabled', true);
48
    }
49
}
50
51
$(document).ready(function () {
52
    var form_identifier = $("#form-identifier").data();
53
    if(form_identifier && form_identifier.hasOwnProperty('identifier') && form_identifier.identifier) {
54
        var form_id = form_identifier.identifier;
55
        if (form_id !== 'new-patron-list_form') {
56
            $("#" + form_id).on("submit", function(e){
57
                persistPatronSelections(form_id)
58
            });
59
        }
60
    }
61
})

Return to bug 34479