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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-73 lines)
Lines 1429-1436 Link Here
1429
            pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed")
1429
            pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed")
1430
        }
1430
        }
1431
1431
1432
        var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
1433
        var MSG_CANCEL_ALERT    = _("This action will cancel <span class='badge bg-danger'>%s</span> hold(s).");
1434
        $.fn.select2.defaults.set("width", "100%" );
1432
        $.fn.select2.defaults.set("width", "100%" );
1435
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1433
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1436
1434
Lines 1749-1769 Link Here
1749
                $("#" + fieldID).val("");
1747
                $("#" + fieldID).val("");
1750
            });
1748
            });
1751
1749
1752
            // Confirm cancellation of hold
1753
            let cancel_link;
1754
            $(".cancel-hold").on("click",function(e) {
1755
                e.preventDefault;
1756
                cancel_link = $(this);
1757
                $("#cancel_modal_form #inputs").empty();
1758
                    let reserve_id = cancel_link.data('id');
1759
                    let biblionumber = cancel_link.data('biblionumber');
1760
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="reserve_id" value="' + reserve_id + '">');
1761
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="biblionumber" value="' + biblionumber + '">');
1762
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="op" value="cud-cancel">');
1763
                $('#cancelModal').modal('show');
1764
                return false;
1765
            });
1766
1767
            [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %]
1750
            [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %]
1768
                [% IF ( PatronAutoComplete ) %]
1751
                [% IF ( PatronAutoComplete ) %]
1769
                    patron_autocomplete($(".search_patron_filter"), { 'link-to': 'reserve', 'url-params': '[% url_biblio_params | url %]' });
1752
                    patron_autocomplete($(".search_patron_filter"), { 'link-to': 'reserve', 'url-params': '[% url_biblio_params | url %]' });
Lines 1780-1841 Link Here
1780
                });
1763
                });
1781
            [% END %]
1764
            [% END %]
1782
1765
1783
            if(!localStorage.selectedHolds  || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
1784
                localStorage.selectedHolds = [];
1785
            }
1786
1787
            $('.holds_table .select_hold').each(function() {
1788
                if(localStorage.selectedHolds.includes($(this).data('id'))) {
1789
                    $(this).prop('checked', true);
1790
                }
1791
            });
1792
1793
            $('.holds_table .select_hold_all').each(function() {
1794
                var table = $(this).parents('.holds_table');
1795
                var count = $('.select_hold:not(:checked)', table).length;
1796
                $('.select_hold_all', table).prop('checked', !count);
1797
            });
1798
1799
            $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1800
1801
            $('.holds_table .select_hold_all').click(function() {
1802
                var table = $(this).parents('.holds_table');
1803
                var count = $('.select_hold:checked', table).length;
1804
                $('.select_hold', table).prop('checked', !count);
1805
                $(this).prop('checked', !count);
1806
                $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1807
                $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length));
1808
                $('#cancel_hold_alert').show();
1809
                localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1810
            });
1811
1812
            $('.holds_table .select_hold').click(function() {
1813
                var table = $(this).parents('.holds_table');
1814
                var count = $('.select_hold:not(:checked)', table).length;
1815
                $('.select_hold_all', table).prop('checked', !count);
1816
                $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1817
                $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length));
1818
                $('#cancel_hold_alert').show();
1819
                localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1820
            });
1821
1822
            $('.cancel_selected_holds').click(function(e) {
1823
                e.preventDefault();
1824
                if($('.holds_table .select_hold:checked').length) {
1825
                    cancel_link = $(this);
1826
                    $("#cancel_modal_form #inputs").empty();
1827
                    biblionumbers.forEach( function(biblionumber){
1828
                        $("#cancel_modal_form #inputs").append('<input type="hidden" name="biblionumber" value="'+biblionumber+'">');
1829
                    });
1830
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="op" value="cud-cancel_bulk">');
1831
                    let hold_ids= $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')).join(',');
1832
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="ids" value="' + hold_ids + '">');
1833
                    delete localStorage.selectedHolds;
1834
                    $('#cancelModal').modal('show');
1835
                }
1836
                return false;
1837
            });
1838
1839
            $(".hold-arrow").click(function(e) {
1766
            $(".hold-arrow").click(function(e) {
1840
                e.preventDefault();
1767
                e.preventDefault();
1841
                let arrowForm = $("#hold-actions-form").attr({
1768
                let arrowForm = $("#hold-actions-form").attr({
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-1 / +221 lines)
Lines 686-691 $(document).ready(function () { Link Here
686
        ];
686
        ];
687
        return toggle_suspend(this, inputs);
687
        return toggle_suspend(this, inputs);
688
    });
688
    });
689
690
    var MSG_SUSPEND_SELECTED = _("Suspend selected (%s)");
691
    var MSG_SUSPEND_SELECTED_HOLDS = _("Suspend selected holds");
692
    $(".suspend_selected_holds").html(
693
        MSG_SUSPEND_SELECTED.format(
694
            $(".holds_table .select_hold:checked").length
695
        )
696
    );
697
698
    $(".suspend_selected_holds").click(function (e) {
699
        e.preventDefault();
700
        if (!$(".holds_table .select_hold:checked").length) {
701
            return false;
702
        }
703
        $(".modal-title").html(MSG_SUSPEND_SELECTED_HOLDS);
704
        $("#suspend-modal").modal("show");
705
        return false;
706
    });
707
689
    $(".unsuspend-hold").on("click", function (e) {
708
    $(".unsuspend-hold").on("click", function (e) {
690
        e.preventDefault();
709
        e.preventDefault();
691
        let inputs = [
710
        let inputs = [
Lines 697-700 $(document).ready(function () { Link Here
697
        ];
716
        ];
698
        return toggle_suspend(this, inputs);
717
        return toggle_suspend(this, inputs);
699
    });
718
    });
719
720
    var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
721
    var MSG_CANCEL_ALERT = _(
722
        "This action will cancel <span class='badge bg-danger'>%s</span> hold(s)."
723
    );
724
725
    // Confirm cancellation of hold
726
    let cancel_link;
727
    $(document).on("click", ".cancel-hold", function (e) {
728
        e.preventDefault;
729
        cancel_link = $(this);
730
        $("#cancel_modal_form #inputs").empty();
731
        let reserve_id = cancel_link.data("id");
732
        let biblionumber = cancel_link.data("biblionumber");
733
        if (!patron_page) {
734
            $("#cancel_modal_form #inputs").append(
735
                '<input type="hidden" name="reserve_id" value="' +
736
                    reserve_id +
737
                    '">'
738
            );
739
            $("#cancel_modal_form #inputs").append(
740
                '<input type="hidden" name="biblionumber" value="' +
741
                    biblionumber +
742
                    '">'
743
            );
744
            $("#cancel_modal_form #inputs").append(
745
                '<input type="hidden" name="op" value="cud-cancel">'
746
            );
747
        } else {
748
            _append_patron_page_cancel_hold_modal_data({
749
                hold: reserve_id,
750
                biblionumber: biblionumber,
751
                borrowernumber: cancel_link.data("borrowernumber"),
752
            });
753
        }
754
        $("#cancelModal").modal("show");
755
        return false;
756
    });
757
758
    if (
759
        !localStorage.selectedHolds ||
760
        document.referrer.replace(/\?.*/, "") !==
761
            document.location.origin + document.location.pathname
762
    ) {
763
        localStorage.selectedHolds = [];
764
    }
765
766
    $(".holds_table .select_hold").each(function () {
767
        if (localStorage.selectedHolds.includes($(this).data("id"))) {
768
            $(this).prop("checked", true);
769
        }
770
    });
771
772
    if (!patron_page) {
773
        $(".holds_table .select_hold_all").each(function () {
774
            var table = $(this).parents(".holds_table");
775
            var count = $(".select_hold:not(:checked)", table).length;
776
            $(".select_hold_all", table).prop("checked", !count);
777
        });
778
    }
779
780
    function updateSelectedHoldsButtonCounters() {
781
        $(".cancel_selected_holds").html(
782
            MSG_CANCEL_SELECTED.format(
783
                $(".holds_table .select_hold:checked").length
784
            )
785
        );
786
        $(".suspend_selected_holds").html(
787
            MSG_SUSPEND_SELECTED.format(
788
                $(".holds_table .select_hold:checked").length
789
            )
790
        );
791
    }
792
793
    updateSelectedHoldsButtonCounters();
794
795
    $(".holds_table .select_hold_all").click(function () {
796
        var table;
797
        if (!patron_page) {
798
            table = $(this).parents(".holds_table");
799
        } else {
800
            table = $(".holds_table:not(.fixedHeader-floating)");
801
        }
802
        var count = $(".select_hold:checked", table).length;
803
        $(".select_hold", table).prop("checked", !count);
804
        $(this).prop("checked", !count);
805
        updateSelectedHoldsButtonCounters();
806
        $("#cancel_hold_alert").html(
807
            MSG_CANCEL_ALERT.format(
808
                $(".holds_table .select_hold:checked").length
809
            )
810
        );
811
        $("#cancel_hold_alert").show();
812
        localStorage.selectedHolds =
813
            "[" +
814
            $(".holds_table .select_hold:checked")
815
                .toArray()
816
                .map(el =>
817
                    JSON.stringify({
818
                        hold: $(el).data("id"),
819
                        borrowernumber: $(el).data("borrowernumber"),
820
                        biblionumber: $(el).data("biblionumber"),
821
                    })
822
                )
823
                .join(",") +
824
            "]";
825
    });
826
827
    $(".holds_table").on("click", ".select_hold", function () {
828
        var table = $(this).parents(".holds_table");
829
        var count = $(".select_hold:not(:checked)", table).length;
830
        $(".select_hold_all", table).prop("checked", !count);
831
        updateSelectedHoldsButtonCounters();
832
        $("#cancel_hold_alert").html(
833
            MSG_CANCEL_ALERT.format(
834
                $(".holds_table .select_hold:checked").length
835
            )
836
        );
837
        $("#cancel_hold_alert").show();
838
        localStorage.selectedHolds =
839
            "[" +
840
            $(".holds_table .select_hold:checked")
841
                .toArray()
842
                .map(el =>
843
                    JSON.stringify({
844
                        hold: $(el).data("id"),
845
                        borrowernumber: $(el).data("borrowernumber"),
846
                        biblionumber: $(el).data("biblionumber"),
847
                    })
848
                )
849
                .join(",") +
850
            "]";
851
    });
852
853
    $(".cancel_selected_holds").click(function (e) {
854
        e.preventDefault();
855
        if ($(".holds_table .select_hold:checked").length) {
856
            $("#cancel_modal_form #inputs").empty();
857
            if (!patron_page) {
858
                biblionumbers.forEach(function (biblionumber) {
859
                    $("#cancel_modal_form #inputs").append(
860
                        '<input type="hidden" name="biblionumber" value="' +
861
                            biblionumber +
862
                            '">'
863
                    );
864
                });
865
                $("#cancel_modal_form #inputs").append(
866
                    '<input type="hidden" name="op" value="cud-cancel_bulk">'
867
                );
868
                let hold_ids = $(".holds_table .select_hold:checked")
869
                    .toArray()
870
                    .map(el => $(el).data("id"))
871
                    .join(",");
872
                $("#cancel_modal_form #inputs").append(
873
                    '<input type="hidden" name="ids" value="' + hold_ids + '">'
874
                );
875
            } else {
876
                $("#cancel_modal_form #inputs").append(
877
                    '<input type="hidden" name="op" value="cud-cancelall">'
878
                );
879
                let hold_data =
880
                    "[" +
881
                    $(".holds_table .select_hold:checked")
882
                        .toArray()
883
                        .map(el =>
884
                            JSON.stringify({
885
                                hold: $(el).data("id"),
886
                                borrowernumber: $(el).data("borrowernumber"),
887
                                biblionumber: $(el).data("biblionumber"),
888
                            })
889
                        )
890
                        .join(",") +
891
                    "]";
892
                JSON.parse(hold_data).forEach(function (hold) {
893
                    _append_patron_page_cancel_hold_modal_data(hold);
894
                });
895
            }
896
897
            delete localStorage.selectedHolds;
898
            $("#cancelModal").modal("show");
899
        }
900
        return false;
901
    });
902
903
    function _append_patron_page_cancel_hold_modal_data(hold) {
904
        $("#cancel_modal_form #inputs").append(
905
            '<input type="hidden" name="rank-request" value="del">'
906
        );
907
        $("#cancel_modal_form #inputs").append(
908
            '<input type="hidden" name="biblionumber" value="' +
909
                hold.biblionumber +
910
                '">'
911
        );
912
        $("#cancel_modal_form #inputs").append(
913
            '<input type="hidden" name="borrowernumber" value="' +
914
                hold.borrowernumber +
915
                '">'
916
        );
917
        $("#cancel_modal_form #inputs").append(
918
            '<input type="hidden" name="reserve_id" value="' + hold.hold + '">'
919
        );
920
    }
700
});
921
});
701
- 

Return to bug 40395