updated showing reservations in assetmanagement
This commit is contained in:
@@ -311,16 +311,20 @@ Vue.component('asset-borrow-return-widget', {
|
||||
},
|
||||
nextReservation() {
|
||||
if (!this.rowData.reservations || this.rowData.reservations.length === 0) return null;
|
||||
|
||||
const now = window.moment().unix();
|
||||
return this.rowData.reservations.reduce((closest, current) => {
|
||||
const closestDiff = Math.abs(closest.startDate - now);
|
||||
const currentDiff = Math.abs(current.startDate - now);
|
||||
|
||||
return currentDiff < closestDiff ? current : closest;
|
||||
// Filter for reservations starting in the future
|
||||
const upcomingReservations = this.rowData.reservations.filter(r => r.startDate > now);
|
||||
|
||||
if (upcomingReservations.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Of the upcoming reservations, find the one that starts soonest
|
||||
return upcomingReservations.reduce((earliest, current) => {
|
||||
return current.startDate < earliest.startDate ? current : earliest;
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
formatDate(timestamp, format) {
|
||||
@@ -755,4 +759,4 @@ Vue.component('asset-reservation-modal', {
|
||||
this.isPermanent = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user