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