|
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 617-635
$(document).ready(function () {
Link Here
|
| 617 |
e.preventDefault(); |
633 |
e.preventDefault(); |
| 618 |
let selected_holds; |
634 |
let selected_holds; |
| 619 |
if (!$(this).data("hold-id")) { |
635 |
if (!$(this).data("hold-id")) { |
| 620 |
selected_holds = |
636 |
selected_holds = get_selected_holds_data(); |
| 621 |
"[" + |
|
|
| 622 |
$(".holds_table .select_hold:checked") |
| 623 |
.toArray() |
| 624 |
.map(el => |
| 625 |
JSON.stringify({ |
| 626 |
hold: $(el).data("id"), |
| 627 |
borrowernumber: $(el).data("borrowernumber"), |
| 628 |
biblionumber: $(el).data("biblionumber"), |
| 629 |
}) |
| 630 |
) |
| 631 |
.join(",") + |
| 632 |
"]"; |
| 633 |
} else { |
637 |
} else { |
| 634 |
selected_holds = |
638 |
selected_holds = |
| 635 |
"[" + JSON.stringify({ hold: $(this).data("hold-id") }) + "]"; |
639 |
"[" + JSON.stringify({ hold: $(this).data("hold-id") }) + "]"; |
|
Lines 800-805
$(document).ready(function () {
Link Here
|
| 800 |
}); |
804 |
}); |
| 801 |
} |
805 |
} |
| 802 |
|
806 |
|
|
|
807 |
var MSG_GROUP_SELECTED = _("Group selected (%s)"); |
| 808 |
|
| 803 |
function updateSelectedHoldsButtonCounters() { |
809 |
function updateSelectedHoldsButtonCounters() { |
| 804 |
$(".cancel_selected_holds").html( |
810 |
$(".cancel_selected_holds").html( |
| 805 |
MSG_CANCEL_SELECTED.format( |
811 |
MSG_CANCEL_SELECTED.format( |
|
Lines 816-821
$(document).ready(function () {
Link Here
|
| 816 |
$(".holds_table .select_hold:checked").length |
822 |
$(".holds_table .select_hold:checked").length |
| 817 |
) |
823 |
) |
| 818 |
); |
824 |
); |
|
|
825 |
$(".group_selected_holds").html( |
| 826 |
MSG_GROUP_SELECTED.format( |
| 827 |
$(".holds_table .select_hold:checked").length |
| 828 |
) |
| 829 |
); |
| 819 |
} |
830 |
} |
| 820 |
|
831 |
|
| 821 |
function updateMoveButtons(table) { |
832 |
function updateMoveButtons(table) { |
|
Lines 1148-1151
$(document).ready(function () {
Link Here
|
| 1148 |
'<input type="hidden" name="reserve_id" value="' + hold.hold + '">' |
1159 |
'<input type="hidden" name="reserve_id" value="' + hold.hold + '">' |
| 1149 |
); |
1160 |
); |
| 1150 |
} |
1161 |
} |
|
|
1162 |
|
| 1163 |
$(".group_selected_holds").html( |
| 1164 |
MSG_GROUP_SELECTED.format($(".holds_table .select_hold:checked").length) |
| 1165 |
); |
| 1166 |
|
| 1167 |
$(".group_selected_holds").click(function (e) { |
| 1168 |
if ($(".holds_table .select_hold:checked").length > 1) { |
| 1169 |
let selected_holds = get_selected_holds_data(); |
| 1170 |
const group_ids = JSON.parse(selected_holds) |
| 1171 |
.filter(hold => hold.hold_group_id) |
| 1172 |
.map(hold => hold.hold_group_id); |
| 1173 |
|
| 1174 |
if (group_ids.length > 0) { |
| 1175 |
$("#group-modal .modal-body").prepend( |
| 1176 |
'<div class="alert alert-warning">' + |
| 1177 |
__( |
| 1178 |
"Already grouped holds will be moved to the new group" |
| 1179 |
) + |
| 1180 |
"</div>" |
| 1181 |
); |
| 1182 |
} |
| 1183 |
|
| 1184 |
$("#group-modal").modal("show"); |
| 1185 |
} |
| 1186 |
return false; |
| 1187 |
}); |
| 1188 |
|
| 1189 |
$("#group-modal-submit").click(function (e) { |
| 1190 |
e.preventDefault(); |
| 1191 |
let selected_holds = get_selected_holds_data(); |
| 1192 |
|
| 1193 |
const hold_ids = JSON.parse(selected_holds).map(hold => hold.hold); |
| 1194 |
|
| 1195 |
try { |
| 1196 |
group_holds(hold_ids) |
| 1197 |
.success(function () { |
| 1198 |
holdsTable.api().ajax.reload(); |
| 1199 |
}) |
| 1200 |
.fail(function (jqXHR) { |
| 1201 |
$("#group-modal .modal-body").prepend( |
| 1202 |
'<div class="alert alert-danger">' + |
| 1203 |
jqXHR.responseJSON.error + |
| 1204 |
"</div>" |
| 1205 |
); |
| 1206 |
$("#group-modal-submit").prop("disabled", true); |
| 1207 |
}) |
| 1208 |
.done(function () { |
| 1209 |
$("#group-modal").modal("hide"); |
| 1210 |
$(".select_hold_all").click(); |
| 1211 |
}); |
| 1212 |
} catch (error) { |
| 1213 |
if (error.status === 404) { |
| 1214 |
alert(__("Unable to group, hold not found.")); |
| 1215 |
} else { |
| 1216 |
alert( |
| 1217 |
__( |
| 1218 |
"Your request could not be processed. Check the logs for details." |
| 1219 |
) |
| 1220 |
); |
| 1221 |
} |
| 1222 |
} |
| 1223 |
return false; |
| 1224 |
}); |
| 1225 |
|
| 1226 |
function group_holds(hold_ids) { |
| 1227 |
return $.ajax({ |
| 1228 |
method: "POST", |
| 1229 |
url: "/api/v1/patrons/" + borrowernumber + "/hold_groups", |
| 1230 |
contentType: "application/json", |
| 1231 |
data: JSON.stringify({ hold_ids: hold_ids, force_grouped: true }), |
| 1232 |
}); |
| 1233 |
} |
| 1234 |
|
| 1235 |
$("#group-modal").on("hidden.bs.modal", function () { |
| 1236 |
$("#group-modal .modal-body .alert-warning").remove(); |
| 1237 |
$("#group-modal .modal-body .alert-danger").remove(); |
| 1238 |
$("#group-modal-submit").prop("disabled", false); |
| 1239 |
}); |
| 1240 |
|
| 1241 |
function get_selected_holds_data() { |
| 1242 |
return ( |
| 1243 |
"[" + |
| 1244 |
$(".holds_table .select_hold:checked") |
| 1245 |
.toArray() |
| 1246 |
.map(el => |
| 1247 |
JSON.stringify({ |
| 1248 |
hold: $(el).data("id"), |
| 1249 |
borrowernumber: $(el).data("borrowernumber"), |
| 1250 |
biblionumber: $(el).data("biblionumber"), |
| 1251 |
hold_group_id: $(el).data("hold-group-id"), |
| 1252 |
}) |
| 1253 |
) |
| 1254 |
.join(",") + |
| 1255 |
"]" |
| 1256 |
); |
| 1257 |
} |
| 1151 |
}); |
1258 |
}); |
| 1152 |
- |
|
|