Lines 164-169
$(document).ready(function () {
Link Here
|
164 |
return ( |
164 |
return ( |
165 |
'<input type="checkbox" class="select_hold" data-id="' + |
165 |
'<input type="checkbox" class="select_hold" data-id="' + |
166 |
oObj.reserve_id + |
166 |
oObj.reserve_id + |
|
|
167 |
(oObj.hold_group_id |
168 |
? '" data-hold-group-id="' + |
169 |
oObj.hold_group_id + |
170 |
'"' |
171 |
: '"') + |
167 |
'" data-borrowernumber="' + |
172 |
'" data-borrowernumber="' + |
168 |
borrowernumber + |
173 |
borrowernumber + |
169 |
'" data-biblionumber="' + |
174 |
'" data-biblionumber="' + |
Lines 178-183
$(document).ready(function () {
Link Here
|
178 |
sort: "reservedate", |
183 |
sort: "reservedate", |
179 |
}, |
184 |
}, |
180 |
}, |
185 |
}, |
|
|
186 |
...(DisplayAddHoldGroups |
187 |
? [ |
188 |
{ |
189 |
data: function (oObj) { |
190 |
title = ""; |
191 |
if (oObj.visual_hold_group_id) { |
192 |
var link = |
193 |
'<a class="hold-group" href="/cgi-bin/koha/reserve/hold-group.pl?hold_group_id=' + |
194 |
oObj.hold_group_id + |
195 |
'">' + |
196 |
oObj.visual_hold_group_id + |
197 |
"</a>"; |
198 |
|
199 |
title = |
200 |
"<span>" + link + "</span>"; |
201 |
} |
202 |
|
203 |
return title; |
204 |
}, |
205 |
}, |
206 |
] |
207 |
: []), |
181 |
{ |
208 |
{ |
182 |
data: function (oObj) { |
209 |
data: function (oObj) { |
183 |
title = |
210 |
title = |
Lines 232-248
$(document).ready(function () {
Link Here
|
232 |
"</span>"; |
259 |
"</span>"; |
233 |
} |
260 |
} |
234 |
|
261 |
|
235 |
if (oObj.hold_group_id) { |
|
|
236 |
title += "<br>"; |
237 |
var link = |
238 |
'<a class="hold-group" href="/cgi-bin/koha/reserve/hold-group.pl?hold_group_id=' + |
239 |
oObj.hold_group_id + |
240 |
'">' + |
241 |
__("part of a hold group") + |
242 |
"</a>"; |
243 |
title += "<span>(" + link + ")</span>"; |
244 |
} |
245 |
|
246 |
return title; |
262 |
return title; |
247 |
}, |
263 |
}, |
248 |
}, |
264 |
}, |
Lines 603-621
$(document).ready(function () {
Link Here
|
603 |
e.preventDefault(); |
619 |
e.preventDefault(); |
604 |
let selected_holds; |
620 |
let selected_holds; |
605 |
if (!$(this).data("hold-id")) { |
621 |
if (!$(this).data("hold-id")) { |
606 |
selected_holds = |
622 |
selected_holds = get_selected_holds_data(); |
607 |
"[" + |
|
|
608 |
$(".holds_table .select_hold:checked") |
609 |
.toArray() |
610 |
.map(el => |
611 |
JSON.stringify({ |
612 |
hold: $(el).data("id"), |
613 |
borrowernumber: $(el).data("borrowernumber"), |
614 |
biblionumber: $(el).data("biblionumber"), |
615 |
}) |
616 |
) |
617 |
.join(",") + |
618 |
"]"; |
619 |
} else { |
623 |
} else { |
620 |
selected_holds = |
624 |
selected_holds = |
621 |
"[" + JSON.stringify({ hold: $(this).data("hold-id") }) + "]"; |
625 |
"[" + JSON.stringify({ hold: $(this).data("hold-id") }) + "]"; |
Lines 785-790
$(document).ready(function () {
Link Here
|
785 |
}); |
789 |
}); |
786 |
} |
790 |
} |
787 |
|
791 |
|
|
|
792 |
var MSG_GROUP_SELECTED = _("Group selected (%s)"); |
793 |
|
788 |
function updateSelectedHoldsButtonCounters() { |
794 |
function updateSelectedHoldsButtonCounters() { |
789 |
$(".cancel_selected_holds").html( |
795 |
$(".cancel_selected_holds").html( |
790 |
MSG_CANCEL_SELECTED.format( |
796 |
MSG_CANCEL_SELECTED.format( |
Lines 796-801
$(document).ready(function () {
Link Here
|
796 |
$(".holds_table .select_hold:checked").length |
802 |
$(".holds_table .select_hold:checked").length |
797 |
) |
803 |
) |
798 |
); |
804 |
); |
|
|
805 |
$(".group_selected_holds").html( |
806 |
MSG_GROUP_SELECTED.format( |
807 |
$(".holds_table .select_hold:checked").length |
808 |
) |
809 |
); |
799 |
} |
810 |
} |
800 |
|
811 |
|
801 |
updateSelectedHoldsButtonCounters(); |
812 |
updateSelectedHoldsButtonCounters(); |
Lines 926-929
$(document).ready(function () {
Link Here
|
926 |
'<input type="hidden" name="reserve_id" value="' + hold.hold + '">' |
937 |
'<input type="hidden" name="reserve_id" value="' + hold.hold + '">' |
927 |
); |
938 |
); |
928 |
} |
939 |
} |
|
|
940 |
|
941 |
$(".group_selected_holds").html( |
942 |
MSG_GROUP_SELECTED.format($(".holds_table .select_hold:checked").length) |
943 |
); |
944 |
|
945 |
$(".group_selected_holds").click(function (e) { |
946 |
if ($(".holds_table .select_hold:checked").length > 1) { |
947 |
let selected_holds = get_selected_holds_data(); |
948 |
const group_ids = JSON.parse(selected_holds) |
949 |
.filter(hold => hold.hold_group_id) |
950 |
.map(hold => hold.hold_group_id); |
951 |
|
952 |
if (group_ids.length > 0) { |
953 |
$("#group-modal .modal-body").prepend( |
954 |
'<div class="alert alert-warning">' + |
955 |
__( |
956 |
"Already grouped holds will be moved to the new group" |
957 |
) + |
958 |
"</div>" |
959 |
); |
960 |
} |
961 |
|
962 |
$("#group-modal").modal("show"); |
963 |
} |
964 |
return false; |
965 |
}); |
966 |
|
967 |
$("#group-modal-submit").click(function (e) { |
968 |
e.preventDefault(); |
969 |
let selected_holds = get_selected_holds_data(); |
970 |
|
971 |
const hold_ids = JSON.parse(selected_holds).map(hold => hold.hold); |
972 |
|
973 |
try { |
974 |
group_holds(hold_ids) |
975 |
.success(function () { |
976 |
holdsTable.api().ajax.reload(); |
977 |
}) |
978 |
.fail(function (jqXHR) { |
979 |
$("#group-modal .modal-body").prepend( |
980 |
'<div class="alert alert-danger">' + |
981 |
jqXHR.responseJSON.error + |
982 |
"</div>" |
983 |
); |
984 |
$("#group-modal-submit").prop("disabled", true); |
985 |
}) |
986 |
.done(function () { |
987 |
$("#group-modal").modal("hide"); |
988 |
$(".select_hold_all").click(); |
989 |
}); |
990 |
} catch (error) { |
991 |
if (error.status === 404) { |
992 |
alert(__("Unable to group, hold not found.")); |
993 |
} else { |
994 |
alert( |
995 |
__( |
996 |
"Your request could not be processed. Check the logs for details." |
997 |
) |
998 |
); |
999 |
} |
1000 |
} |
1001 |
return false; |
1002 |
}); |
1003 |
|
1004 |
function group_holds(hold_ids) { |
1005 |
return $.ajax({ |
1006 |
method: "POST", |
1007 |
url: "/api/v1/patrons/" + borrowernumber + "/hold_groups", |
1008 |
contentType: "application/json", |
1009 |
data: JSON.stringify({ hold_ids: hold_ids, force_grouped: true }), |
1010 |
}); |
1011 |
} |
1012 |
|
1013 |
$("#group-modal").on("hidden.bs.modal", function () { |
1014 |
$("#group-modal .modal-body .alert-warning").remove(); |
1015 |
$("#group-modal .modal-body .alert-danger").remove(); |
1016 |
$("#group-modal-submit").prop("disabled", false); |
1017 |
}); |
1018 |
|
1019 |
function get_selected_holds_data() { |
1020 |
return ( |
1021 |
"[" + |
1022 |
$(".holds_table .select_hold:checked") |
1023 |
.toArray() |
1024 |
.map(el => |
1025 |
JSON.stringify({ |
1026 |
hold: $(el).data("id"), |
1027 |
borrowernumber: $(el).data("borrowernumber"), |
1028 |
biblionumber: $(el).data("biblionumber"), |
1029 |
hold_group_id: $(el).data("hold-group-id"), |
1030 |
}) |
1031 |
) |
1032 |
.join(",") + |
1033 |
"]" |
1034 |
); |
1035 |
} |
929 |
}); |
1036 |
}); |
930 |
- |
|
|