"Refactor ActionSettingsWheelButton.vue: simplify label logic using dynamic properties, add conditional display for admin actions, and enhance delete buttons with danger templates for improved clarity and safety."

This commit is contained in:
Jeppe Bundgaard
2025-11-11 08:10:32 +01:00
parent 61d500e7a1
commit 74be373e7c
@@ -201,15 +201,14 @@ const hasUser = () => {
</template>
<!-- If there's an order_id, show the order actions -->
<template v-if="props.order_id">
<!-- Label, only if the user is a superuser (Otherwise, the label is redundant) -->
<!-- Label -->
<action-settings-wheel-item-label
:label="SessionUser.functions.ucFirst(SessionUser.objects.orders.meta.labels.single)"
v-show="SessionUser.canAccessSuperUser()"
/>
<!-- Go to the order page, in a new tab -->
<action-settings-wheel-item
v-if="SessionUser.canAccessAdmin() || SessionUser.canAccessSuperUser()"
label="Se transaktion i ny fane"
:label="`Se ${SessionUser.objects.orders.meta.labels.single.toLowerCase()} i ny fane`"
icon="fas fa-external-link-alt"
:click-action="async () => redirectDepartmentOrderPage(props.order_id)"
:disabled="false"
@@ -217,7 +216,7 @@ const hasUser = () => {
<!-- Go to the user/order/:order_id page, in a new tab -->
<action-settings-wheel-item
v-if="!SessionUser.canAccessAdmin() && !SessionUser.canAccessSuperUser()"
label="Se transaktion i ny fane"
:label="`Se ${SessionUser.objects.orders.meta.labels.single.toLowerCase()} i ny fane`"
icon="fas fa-external-link-alt"
:click-action="() => SessionUser.functions.redirectTo.user('/orders/' + props.order_id, true)"
:disabled="false"
@@ -225,7 +224,8 @@ const hasUser = () => {
<!-- Delete the order -->
<action-settings-wheel-item
v-if="SessionUser.canAccessAdmin() || SessionUser.canAccessSuperUser()"
label="Slet transaktion"
:label="`Slet ${SessionUser.objects.orders.meta.labels.single.toLowerCase()}`"
template="danger"
icon="fas fa-trash-alt"
:click-action="() => SessionUser.objects.orders.functions.showDeleteConfirmationModal(props.order_id, () => {
emitDeleted();
@@ -283,6 +283,7 @@ const hasUser = () => {
<template v-if="props.order_booking_id">
<ActionSettingsWheelItemLabel :label="'Booking'"/>
<ActionSettingsWheelItem
v-if="SessionUser.canAccessAdmin() || SessionUser.canAccessSuperUser()"
:icon="'fas fa-check-circle'"
:label="'Marker som gennemført'"
:click-action="() => SessionUser.objects.order_bookings.functions.showCompleteConfirmationModal(props.order_booking_id, () => {
@@ -295,8 +296,9 @@ const hasUser = () => {
:click-action="() => SessionUser.functions.redirectTo.department(props.department_id, 'modules/bookings/order/' + props.order_booking_id, true)"
/>
<ActionSettingsWheelItem
v-if="SessionUser.canAccessAdmin() || SessionUser.canAccessSuperUser()"
:icon="'fas fa-edit'"
:label="'Tilknyt transaktion'"
:label="`Rediger tilknyttet ${SessionUser.objects.orders.meta.labels.single.toLowerCase()}`"
:click-action="() => SessionUser.objects.order_bookings.showEditObjectFieldForm(props.order_booking_id, 'order_id', props.order_id, () => {
props.refreshFunction();
}, {
@@ -313,6 +315,8 @@ const hasUser = () => {
<ActionSettingsWheelItem
:icon="'fas fa-trash-alt'"
:label="'Slet booking'"
template="danger"
v-show="!props.order_id"
:click-action="() => SessionUser.objects.order_bookings.functions.showDeleteConfirmationModal(props.order_booking_id, () => {
props.refreshFunction();
})"