"Enhance error handling in ObjectsGlobal.vue with a new centralized handleError method; update OrderBookingsTable.vue to include department filter functionality and dynamic department loading for improved filtering options."
This commit is contained in:
@@ -274,11 +274,32 @@ export const ObjectsGlobal = {
|
||||
"PUT",
|
||||
{
|
||||
id: id,
|
||||
[column]: value
|
||||
}
|
||||
[column]: value,
|
||||
},
|
||||
(error) => {
|
||||
ObjectsGlobal.errorHandler.handleError(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
errorHandler: {
|
||||
/**
|
||||
* Handle an error
|
||||
* @param {object} error The error object
|
||||
*/
|
||||
handleError: (error) => {
|
||||
console.error(error);
|
||||
let message = ObjectsGlobal.language.unknown_error;
|
||||
if (error.response && error.response.data && error.response.data.data.message) {
|
||||
message = error.response.data.data.message;
|
||||
}
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: ObjectsGlobal.language.error,
|
||||
text: message,
|
||||
});
|
||||
}
|
||||
},
|
||||
add: {
|
||||
/**
|
||||
* Add an object
|
||||
|
||||
@@ -284,7 +284,7 @@ export const OrderBookings = {
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"pickup",
|
||||
pickup
|
||||
pickup === true || pickup === 1 || pickup === "1" || pickup === "true"
|
||||
)
|
||||
},
|
||||
items: async (id, items) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { SessionUser } from "@/components/session/token/SessionUser.vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { getDepartmentName } from "@/components/pagination/departmentTabs.vue";
|
||||
import { getDepartmentName, departments, getDepartments } from "@/components/pagination/departmentTabs.vue";
|
||||
import EditableTableColumn from "@/components/displays/buttons/EditableTableColumn.vue";
|
||||
import ActionSettingsWheelButton from "@/components/displays/buttons/ActionSettingsWheelButton.vue";
|
||||
import ActionSettingsWheelItemLabel from "@/components/displays/buttons/ActionSettingsWheelItemLabel.vue";
|
||||
@@ -33,8 +33,18 @@ const onOrderIdFilterChange = (event) => {
|
||||
setFilter('order_id', val);
|
||||
};
|
||||
|
||||
// Department filter
|
||||
const departmentFilter = ref('*');
|
||||
const onDepartmentFilterChange = (event) => {
|
||||
const val = event.target.value;
|
||||
departmentFilter.value = val;
|
||||
setFilter('department', val);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
setEndpoint("/order-bookings");
|
||||
// Load departments for filter options
|
||||
getDepartments().catch(() => {});
|
||||
});
|
||||
/**
|
||||
* This function will return a string that tells how long until the given time
|
||||
@@ -183,6 +193,19 @@ const onItemsClick = (event, booking) => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-narrow">
|
||||
<div class="field mb-0">
|
||||
<label class="label is-small">Afdeling</label>
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select :value="departmentFilter" @change="onDepartmentFilterChange">
|
||||
<option value="*">Alle</option>
|
||||
<option v-for="department in departments" :key="department.id" :value="department.id">{{ department.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user