|
Lines 62-67
Link Here
|
| 62 |
<script> |
62 |
<script> |
| 63 |
dayjs.extend(window.dayjs_plugin_isSameOrBefore); |
63 |
dayjs.extend(window.dayjs_plugin_isSameOrBefore); |
| 64 |
</script> |
64 |
</script> |
|
|
65 |
[% Asset.js("js/additional-fields.js") | $raw %] |
| 65 |
[% Asset.js("js/modals/place_booking.js") | $raw %] |
66 |
[% Asset.js("js/modals/place_booking.js") | $raw %] |
| 66 |
[% Asset.js("js/cancel_booking_modal.js") | $raw %] |
67 |
[% Asset.js("js/cancel_booking_modal.js") | $raw %] |
| 67 |
[% Asset.js("js/combobox.js") | $raw %] |
68 |
[% Asset.js("js/combobox.js") | $raw %] |
|
Lines 84-95
Link Here
|
| 84 |
type: "GET", |
85 |
type: "GET", |
| 85 |
}); |
86 |
}); |
| 86 |
var bookings = $.ajax({ |
87 |
var bookings = $.ajax({ |
| 87 |
url: "/api/v1/biblios/%s/bookings?_per_page=-1".format(biblionumber), |
88 |
url: '/api/v1/biblios/%s/bookings?_per_page=-1'.format(biblionumber), |
| 88 |
headers: { "x-koha-embed": "patron" }, |
89 |
headers: { 'x-koha-embed': ['patron', 'extended_attributes'] }, |
| 89 |
dataType: "json", |
90 |
dataType: 'json', |
| 90 |
type: "GET", |
91 |
type: 'GET', |
| 91 |
}); |
92 |
}); |
| 92 |
|
93 |
var extended_attribute_types; |
|
|
94 |
var authorised_values; |
| 95 |
AdditionalFields.fetchAndProcessExtendedAttributes("booking") |
| 96 |
.then(types => { |
| 97 |
extended_attribute_types = types; |
| 98 |
const catArray = Object.values(types) |
| 99 |
.map(attr => attr.authorised_value_category_name) |
| 100 |
.filter(Boolean); |
| 101 |
return AdditionalFields.fetchAndProcessAuthorizedValues(catArray); |
| 102 |
}) |
| 103 |
.then(values => { |
| 104 |
authorised_values = values; |
| 105 |
}); |
| 93 |
$.when(items, bookings).then( |
106 |
$.when(items, bookings).then( |
| 94 |
function (items, bookings) { |
107 |
function (items, bookings) { |
| 95 |
var itemsSet = new vis.DataSet([ |
108 |
var itemsSet = new vis.DataSet([ |
|
Lines 122-127
Link Here
|
| 122 |
pickup_library: booking.pickup_library_id, |
135 |
pickup_library: booking.pickup_library_id, |
| 123 |
start: $toDisplayDate(startServerTz), |
136 |
start: $toDisplayDate(startServerTz), |
| 124 |
end: $toDisplayDate(endServerTz), |
137 |
end: $toDisplayDate(endServerTz), |
|
|
138 |
extended_attributes: booking.extended_attributes, |
| 125 |
content: !isActive ? `<s>${patronContent}</s>` : patronContent, |
139 |
content: !isActive ? `<s>${patronContent}</s>` : patronContent, |
| 126 |
className: booking.status === "cancelled" ? "cancelled" : "", |
140 |
className: booking.status === "cancelled" ? "cancelled" : "", |
| 127 |
...(permissions.CAN_user_circulate_manage_bookings ? { editable: !["cancelled", "completed"].includes(booking.status) ? { remove: true, updateTime: true } : false } : { editable: false }), |
141 |
...(permissions.CAN_user_circulate_manage_bookings ? { editable: !["cancelled", "completed"].includes(booking.status) ? { remove: true, updateTime: true } : false } : { editable: false }), |
|
Lines 175-200
Link Here
|
| 175 |
// set end datetime hours and minutes to the end of the day |
189 |
// set end datetime hours and minutes to the end of the day |
| 176 |
let endDate = dayjs(data.end).endOf("day"); |
190 |
let endDate = dayjs(data.end).endOf("day"); |
| 177 |
|
191 |
|
| 178 |
$("#placeBookingModal").modal( |
192 |
// Get the current booking to preserve extended attributes |
| 179 |
"show", |
193 |
let currentBooking = bookingsSet.get(data.id); |
| 180 |
$( |
194 |
let extendedAttributes = currentBooking.extended_attributes || []; |
| 181 |
'<button data-booking="' + |
195 |
|
| 182 |
data.id + |
196 |
$('#placeBookingModal').modal('show', $(`<button |
| 183 |
'" data-biblionumber="' + |
197 |
data-booking="${data.id}" |
| 184 |
biblionumber + |
198 |
data-biblionumber="[% biblionumber | uri %]" |
| 185 |
'" data-itemnumber="' + |
199 |
data-itemnumber="${data.group}" |
| 186 |
data.group + |
200 |
data-patron="${data.patron}" |
| 187 |
'" data-patron="' + |
201 |
data-pickup_library="${data.pickup_library}" |
| 188 |
data.patron + |
202 |
data-start_date="${startDate.toISOString()}" |
| 189 |
'" data-pickup_library="' + |
203 |
data-end_date="${endDate.toISOString()}" |
| 190 |
data.pickup_library + |
204 |
data-extended_attributes='${JSON.stringify(extendedAttributes.map(attribute => ({ |
| 191 |
'" data-start_date="' + |
205 |
field_id: attribute.field_id, |
| 192 |
startDate.toISOString() + |
206 |
value: attribute.value |
| 193 |
'" data-end_date="' + |
207 |
})))}' |
| 194 |
endDate.toISOString() + |
208 |
>`)); |
| 195 |
'">' |
|
|
| 196 |
) |
| 197 |
); |
| 198 |
$("#placeBookingModal").on("hide.bs.modal", function (e) { |
209 |
$("#placeBookingModal").on("hide.bs.modal", function (e) { |
| 199 |
if (update_success) { |
210 |
if (update_success) { |
| 200 |
update_success = 0; |
211 |
update_success = 0; |
|
Lines 255-261
Link Here
|
| 255 |
ajax: { |
266 |
ajax: { |
| 256 |
url: bookings_table_url, |
267 |
url: bookings_table_url, |
| 257 |
}, |
268 |
}, |
| 258 |
embed: ["item", "patron", "pickup_library"], |
269 |
embed: ["item", "patron", "pickup_library", "extended_attributes"], |
| 259 |
columns: [ |
270 |
columns: [ |
| 260 |
{ |
271 |
{ |
| 261 |
data: "booking_id", |
272 |
data: "booking_id", |
|
Lines 365-370
Link Here
|
| 365 |
return $date(row.end_date); |
376 |
return $date(row.end_date); |
| 366 |
}, |
377 |
}, |
| 367 |
}, |
378 |
}, |
|
|
379 |
{ |
| 380 |
data: "extended_attributes", |
| 381 |
title: _("Additional fields"), |
| 382 |
searchable: false, |
| 383 |
orderable: false, |
| 384 |
render: function (data, type, row, meta) { |
| 385 |
return AdditionalFields.renderExtendedAttributesValues( |
| 386 |
data, |
| 387 |
extended_attribute_types, |
| 388 |
authorised_values, |
| 389 |
row.booking_id |
| 390 |
).join("<br>"); |
| 391 |
}, |
| 392 |
}, |
| 368 |
{ |
393 |
{ |
| 369 |
data: "", |
394 |
data: "", |
| 370 |
title: _("Actions"), |
395 |
title: _("Actions"), |
|
Lines 387-392
Link Here
|
| 387 |
data-start_date="%s" |
412 |
data-start_date="%s" |
| 388 |
data-end_date="%s" |
413 |
data-end_date="%s" |
| 389 |
data-item_type_id="%s" |
414 |
data-item_type_id="%s" |
|
|
415 |
data-extended_attributes='%s' |
| 390 |
> |
416 |
> |
| 391 |
<i class="fa fa-pencil" aria-hidden="true"></i> %s |
417 |
<i class="fa fa-pencil" aria-hidden="true"></i> %s |
| 392 |
</button> |
418 |
</button> |
|
Lines 399-404
Link Here
|
| 399 |
escape_str(row.start_date), |
425 |
escape_str(row.start_date), |
| 400 |
escape_str(row.end_date), |
426 |
escape_str(row.end_date), |
| 401 |
escape_str(row.item.item_type_id), |
427 |
escape_str(row.item.item_type_id), |
|
|
428 |
escape_str(JSON.stringify(row.extended_attributes |
| 429 |
.filter(attribute => attribute.record_id == row.booking_id) |
| 430 |
.map(attribute => ({ |
| 431 |
field_id: attribute.field_id, |
| 432 |
value: attribute.value |
| 433 |
})) |
| 434 |
)), |
| 402 |
_("Edit") |
435 |
_("Edit") |
| 403 |
); |
436 |
); |
| 404 |
result += ` |
437 |
result += ` |