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 1448-1455 Link Here
1448
            pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed")
1448
            pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed")
1449
        }
1449
        }
1450
1450
1451
        var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
1452
        var MSG_CANCEL_ALERT    = _("This action will cancel <span class='badge bg-danger'>%s</span> hold(s).");
1453
        $.fn.select2.defaults.set("width", "100%" );
1451
        $.fn.select2.defaults.set("width", "100%" );
1454
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1452
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1455
1453
Lines 1768-1788 Link Here
1768
                $("#" + fieldID).val("");
1766
                $("#" + fieldID).val("");
1769
            });
1767
            });
1770
1768
1771
            // Confirm cancellation of hold
1772
            let cancel_link;
1773
            $(".cancel-hold").on("click",function(e) {
1774
                e.preventDefault;
1775
                cancel_link = $(this);
1776
                $("#cancel_modal_form #inputs").empty();
1777
                    let reserve_id = cancel_link.data('id');
1778
                    let biblionumber = cancel_link.data('biblionumber');
1779
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="reserve_id" value="' + reserve_id + '">');
1780
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="biblionumber" value="' + biblionumber + '">');
1781
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="op" value="cud-cancel">');
1782
                $('#cancelModal').modal('show');
1783
                return false;
1784
            });
1785
1786
            [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %]
1769
            [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %]
1787
                [% IF ( PatronAutoComplete ) %]
1770
                [% IF ( PatronAutoComplete ) %]
1788
                    patron_autocomplete($(".search_patron_filter"), { 'link-to': 'reserve', 'url-params': '[% url_biblio_params | url %]' });
1771
                    patron_autocomplete($(".search_patron_filter"), { 'link-to': 'reserve', 'url-params': '[% url_biblio_params | url %]' });
Lines 1799-1860 Link Here
1799
                });
1782
                });
1800
            [% END %]
1783
            [% END %]
1801
1784
1802
            if(!localStorage.selectedHolds  || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
1803
                localStorage.selectedHolds = [];
1804
            }
1805
1806
            $('.holds_table .select_hold').each(function() {
1807
                if(localStorage.selectedHolds.includes($(this).data('id'))) {
1808
                    $(this).prop('checked', true);
1809
                }
1810
            });
1811
1812
            $('.holds_table .select_hold_all').each(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
            });
1817
1818
            $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1819
1820
            $('.holds_table .select_hold_all').click(function() {
1821
                var table = $(this).parents('.holds_table');
1822
                var count = $('.select_hold:checked', table).length;
1823
                $('.select_hold', table).prop('checked', !count);
1824
                $(this).prop('checked', !count);
1825
                $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1826
                $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length));
1827
                $('#cancel_hold_alert').show();
1828
                localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1829
            });
1830
1831
            $('.holds_table .select_hold').click(function() {
1832
                var table = $(this).parents('.holds_table');
1833
                var count = $('.select_hold:not(:checked)', table).length;
1834
                $('.select_hold_all', table).prop('checked', !count);
1835
                $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1836
                $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length));
1837
                $('#cancel_hold_alert').show();
1838
                localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1839
            });
1840
1841
            $('.cancel_selected_holds').click(function(e) {
1842
                e.preventDefault();
1843
                if($('.holds_table .select_hold:checked').length) {
1844
                    cancel_link = $(this);
1845
                    $("#cancel_modal_form #inputs").empty();
1846
                    biblionumbers.forEach( function(biblionumber){
1847
                        $("#cancel_modal_form #inputs").append('<input type="hidden" name="biblionumber" value="'+biblionumber+'">');
1848
                    });
1849
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="op" value="cud-cancel_bulk">');
1850
                    let hold_ids= $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')).join(',');
1851
                    $("#cancel_modal_form #inputs").append('<input type="hidden" name="ids" value="' + hold_ids + '">');
1852
                    delete localStorage.selectedHolds;
1853
                    $('#cancelModal').modal('show');
1854
                }
1855
                return false;
1856
            });
1857
1858
            $(".hold-arrow").click(function(e) {
1785
            $(".hold-arrow").click(function(e) {
1859
                e.preventDefault();
1786
                e.preventDefault();
1860
                let arrowForm = $("#hold-actions-form").attr({
1787
                let arrowForm = $("#hold-actions-form").attr({
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-1 / +221 lines)
Lines 697-702 $(document).ready(function () { Link Here
697
        ];
697
        ];
698
        return toggle_suspend(this, inputs);
698
        return toggle_suspend(this, inputs);
699
    });
699
    });
700
701
    var MSG_SUSPEND_SELECTED = _("Suspend selected (%s)");
702
    var MSG_SUSPEND_SELECTED_HOLDS = _("Suspend selected holds");
703
    $(".suspend_selected_holds").html(
704
        MSG_SUSPEND_SELECTED.format(
705
            $(".holds_table .select_hold:checked").length
706
        )
707
    );
708
709
    $(".suspend_selected_holds").click(function (e) {
710
        e.preventDefault();
711
        if (!$(".holds_table .select_hold:checked").length) {
712
            return false;
713
        }
714
        $(".modal-title").html(MSG_SUSPEND_SELECTED_HOLDS);
715
        $("#suspend-modal").modal("show");
716
        return false;
717
    });
718
700
    $(".unsuspend-hold").on("click", function (e) {
719
    $(".unsuspend-hold").on("click", function (e) {
701
        e.preventDefault();
720
        e.preventDefault();
702
        let inputs = [
721
        let inputs = [
Lines 708-711 $(document).ready(function () { Link Here
708
        ];
727
        ];
709
        return toggle_suspend(this, inputs);
728
        return toggle_suspend(this, inputs);
710
    });
729
    });
730
731
    var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
732
    var MSG_CANCEL_ALERT = _(
733
        "This action will cancel <span class='badge bg-danger'>%s</span> hold(s)."
734
    );
735
736
    // Confirm cancellation of hold
737
    let cancel_link;
738
    $(document).on("click", ".cancel-hold", function (e) {
739
        e.preventDefault;
740
        cancel_link = $(this);
741
        $("#cancel_modal_form #inputs").empty();
742
        let reserve_id = cancel_link.data("id");
743
        let biblionumber = cancel_link.data("biblionumber");
744
        if (!patron_page) {
745
            $("#cancel_modal_form #inputs").append(
746
                '<input type="hidden" name="reserve_id" value="' +
747
                    reserve_id +
748
                    '">'
749
            );
750
            $("#cancel_modal_form #inputs").append(
751
                '<input type="hidden" name="biblionumber" value="' +
752
                    biblionumber +
753
                    '">'
754
            );
755
            $("#cancel_modal_form #inputs").append(
756
                '<input type="hidden" name="op" value="cud-cancel">'
757
            );
758
        } else {
759
            _append_patron_page_cancel_hold_modal_data({
760
                hold: reserve_id,
761
                biblionumber: biblionumber,
762
                borrowernumber: cancel_link.data("borrowernumber"),
763
            });
764
        }
765
        $("#cancelModal").modal("show");
766
        return false;
767
    });
768
769
    if (
770
        !localStorage.selectedHolds ||
771
        document.referrer.replace(/\?.*/, "") !==
772
            document.location.origin + document.location.pathname
773
    ) {
774
        localStorage.selectedHolds = [];
775
    }
776
777
    $(".holds_table .select_hold").each(function () {
778
        if (localStorage.selectedHolds.includes($(this).data("id"))) {
779
            $(this).prop("checked", true);
780
        }
781
    });
782
783
    if (!patron_page) {
784
        $(".holds_table .select_hold_all").each(function () {
785
            var table = $(this).parents(".holds_table");
786
            var count = $(".select_hold:not(:checked)", table).length;
787
            $(".select_hold_all", table).prop("checked", !count);
788
        });
789
    }
790
791
    function updateSelectedHoldsButtonCounters() {
792
        $(".cancel_selected_holds").html(
793
            MSG_CANCEL_SELECTED.format(
794
                $(".holds_table .select_hold:checked").length
795
            )
796
        );
797
        $(".suspend_selected_holds").html(
798
            MSG_SUSPEND_SELECTED.format(
799
                $(".holds_table .select_hold:checked").length
800
            )
801
        );
802
    }
803
804
    updateSelectedHoldsButtonCounters();
805
806
    $(".holds_table .select_hold_all").click(function () {
807
        var table;
808
        if (!patron_page) {
809
            table = $(this).parents(".holds_table");
810
        } else {
811
            table = $(".holds_table:not(.fixedHeader-floating)");
812
        }
813
        var count = $(".select_hold:checked", table).length;
814
        $(".select_hold", table).prop("checked", !count);
815
        $(this).prop("checked", !count);
816
        updateSelectedHoldsButtonCounters();
817
        $("#cancel_hold_alert").html(
818
            MSG_CANCEL_ALERT.format(
819
                $(".holds_table .select_hold:checked").length
820
            )
821
        );
822
        $("#cancel_hold_alert").show();
823
        localStorage.selectedHolds =
824
            "[" +
825
            $(".holds_table .select_hold:checked")
826
                .toArray()
827
                .map(el =>
828
                    JSON.stringify({
829
                        hold: $(el).data("id"),
830
                        borrowernumber: $(el).data("borrowernumber"),
831
                        biblionumber: $(el).data("biblionumber"),
832
                    })
833
                )
834
                .join(",") +
835
            "]";
836
    });
837
838
    $(".holds_table").on("click", ".select_hold", function () {
839
        var table = $(this).parents(".holds_table");
840
        var count = $(".select_hold:not(:checked)", table).length;
841
        $(".select_hold_all", table).prop("checked", !count);
842
        updateSelectedHoldsButtonCounters();
843
        $("#cancel_hold_alert").html(
844
            MSG_CANCEL_ALERT.format(
845
                $(".holds_table .select_hold:checked").length
846
            )
847
        );
848
        $("#cancel_hold_alert").show();
849
        localStorage.selectedHolds =
850
            "[" +
851
            $(".holds_table .select_hold:checked")
852
                .toArray()
853
                .map(el =>
854
                    JSON.stringify({
855
                        hold: $(el).data("id"),
856
                        borrowernumber: $(el).data("borrowernumber"),
857
                        biblionumber: $(el).data("biblionumber"),
858
                    })
859
                )
860
                .join(",") +
861
            "]";
862
    });
863
864
    $(".cancel_selected_holds").click(function (e) {
865
        e.preventDefault();
866
        if ($(".holds_table .select_hold:checked").length) {
867
            $("#cancel_modal_form #inputs").empty();
868
            if (!patron_page) {
869
                biblionumbers.forEach(function (biblionumber) {
870
                    $("#cancel_modal_form #inputs").append(
871
                        '<input type="hidden" name="biblionumber" value="' +
872
                            biblionumber +
873
                            '">'
874
                    );
875
                });
876
                $("#cancel_modal_form #inputs").append(
877
                    '<input type="hidden" name="op" value="cud-cancel_bulk">'
878
                );
879
                let hold_ids = $(".holds_table .select_hold:checked")
880
                    .toArray()
881
                    .map(el => $(el).data("id"))
882
                    .join(",");
883
                $("#cancel_modal_form #inputs").append(
884
                    '<input type="hidden" name="ids" value="' + hold_ids + '">'
885
                );
886
            } else {
887
                $("#cancel_modal_form #inputs").append(
888
                    '<input type="hidden" name="op" value="cud-cancelall">'
889
                );
890
                let hold_data =
891
                    "[" +
892
                    $(".holds_table .select_hold:checked")
893
                        .toArray()
894
                        .map(el =>
895
                            JSON.stringify({
896
                                hold: $(el).data("id"),
897
                                borrowernumber: $(el).data("borrowernumber"),
898
                                biblionumber: $(el).data("biblionumber"),
899
                            })
900
                        )
901
                        .join(",") +
902
                    "]";
903
                JSON.parse(hold_data).forEach(function (hold) {
904
                    _append_patron_page_cancel_hold_modal_data(hold);
905
                });
906
            }
907
908
            delete localStorage.selectedHolds;
909
            $("#cancelModal").modal("show");
910
        }
911
        return false;
912
    });
913
914
    function _append_patron_page_cancel_hold_modal_data(hold) {
915
        $("#cancel_modal_form #inputs").append(
916
            '<input type="hidden" name="rank-request" value="del">'
917
        );
918
        $("#cancel_modal_form #inputs").append(
919
            '<input type="hidden" name="biblionumber" value="' +
920
                hold.biblionumber +
921
                '">'
922
        );
923
        $("#cancel_modal_form #inputs").append(
924
            '<input type="hidden" name="borrowernumber" value="' +
925
                hold.borrowernumber +
926
                '">'
927
        );
928
        $("#cancel_modal_form #inputs").append(
929
            '<input type="hidden" name="reserve_id" value="' + hold.hold + '">'
930
        );
931
    }
711
});
932
});
712
- 

Return to bug 40395