diff --git a/src/views/dashboards/departmentDashboard/modules/order-bookings/DepartmentDashboardOrderBooking.vue b/src/views/dashboards/departmentDashboard/modules/order-bookings/DepartmentDashboardOrderBooking.vue index 919fa407..d43aa59c 100644 --- a/src/views/dashboards/departmentDashboard/modules/order-bookings/DepartmentDashboardOrderBooking.vue +++ b/src/views/dashboards/departmentDashboard/modules/order-bookings/DepartmentDashboardOrderBooking.vue @@ -126,6 +126,13 @@ const total = computed(() => { return (items.value || []).reduce((sum, it: any) => sum + (parseFloat(it.price || 0) * (parseInt(it.quantity || 1))), 0); }); +const canEditBooking = () => { + // Admins can always edit + if (SessionUser.canAccessAdmin() && SessionUser.hasPermission('edit_bookings')) return true; + if (!!booking.value.order_id) return false; // Linked to order, restrict edits for users + if (SessionUser.hasPermission('edit_own_bookings')) return true; +} + watch(() => router.currentRoute.value.params.bookingId, (val) => { bookingId.value = val as any; getBooking(); @@ -167,6 +174,7 @@ onMounted(async () => { column="department" :parse-function="(value) => value ? `${getDepartmentName(value) || value}` : 'Ingen afdeling valgt'" :edit-function="SessionUser.objects.order_bookings.showEditObjectFieldForm" + :permission-check-function="() => canEditBooking()" />