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 |
- |
|
|