From 40a3815e85ea0a643e9f009e744c0c1aa6fdd989 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 12 Apr 2024 10:27:30 +0200 Subject: [PATCH] refs #6111 clean code fix changes --- src/i18n/en/index.js | 4 ++ src/pages/Route/RouteList.vue | 119 +++------------------------------- 2 files changed, 14 insertions(+), 109 deletions(-) diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 685591c2d..e9bfbe67a 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -91,6 +91,10 @@ export default { log: 'Logs', parkingList: 'Parkings list', }, + actions: 'Acciones', + started: 'Hora inicio', + finished: 'Hora fin', + volume: 'Volumen', }, errors: { statusUnauthorized: 'Access denied', diff --git a/src/pages/Route/RouteList.vue b/src/pages/Route/RouteList.vue index 6196ff398..b20c72807 100644 --- a/src/pages/Route/RouteList.vue +++ b/src/pages/Route/RouteList.vue @@ -2,7 +2,7 @@ import VnPaginate from 'components/ui/VnPaginate.vue'; import { useStateStore } from 'stores/useStateStore'; import { useI18n } from 'vue-i18n'; -import { computed, onMounted, reactive, onUnmounted, ref } from 'vue'; +import { computed, onMounted, onUnmounted, ref } from 'vue'; import { dashIfEmpty, toHour } from 'src/filters'; import VnSelectFilter from 'components/common/VnSelectFilter.vue'; import FetchData from 'components/FetchData.vue'; @@ -37,15 +37,6 @@ const columns = computed(() => [ field: (row) => row.id, sortable: true, align: 'center', - columnFilter: { - component: 'VnInput', - type: 'text', - filterValue: null, - event: getInputEvents, - attrs: { - dense: true, - }, - }, }, { name: 'worker', @@ -53,18 +44,6 @@ const columns = computed(() => [ field: (row) => row.workerUserName, sortable: true, align: 'left', - columnFilter: { - component: 'VnSelectFilter', - type: 'select', - filterValue: null, - event: getInputEvents, - attrs: { - options: workers, - 'option-value': 'id', - 'option-label': 'nickname', - dense: true, - }, - }, }, { name: 'agency', @@ -72,18 +51,6 @@ const columns = computed(() => [ field: (row) => row.agencyName, sortable: true, align: 'left', - columnFilter: { - component: 'VnSelectFilter', - type: 'select', - filterValue: null, - event: getInputEvents, - attrs: { - options: agencyList, - 'option-value': 'id', - 'option-label': 'name', - dense: true, - }, - }, }, { name: 'vehicle', @@ -91,18 +58,6 @@ const columns = computed(() => [ field: (row) => row.vehiclePlateNumber, sortable: true, align: 'left', - columnFilter: { - component: 'VnSelectFilter', - type: 'select', - filterValue: null, - event: getInputEvents, - attrs: { - options: vehicleList, - 'option-value': 'id', - 'option-label': 'numberPlate', - dense: true, - }, - }, }, { name: 'date', @@ -110,12 +65,6 @@ const columns = computed(() => [ field: (row) => row.created, sortable: true, align: 'left', - columnFilter: { - component: 'VnInputDate', - type: 'select', - filterValue: null, - event: getInputEvents, - }, }, { name: 'volume', @@ -130,38 +79,20 @@ const columns = computed(() => [ field: (row) => row.description, sortable: true, align: 'left', - columnFilter: { - component: 'VnInput', - type: 'select', - filterValue: null, - event: getInputEvents, - }, }, { - name: 'hourStarted', + name: 'started', label: t('hourStarted'), field: (row) => toHour(row.started), sortable: true, align: 'left', - columnFilter: { - component: 'VnInputTime', - type: 'select', - filterValue: null, - event: getInputEvents, - }, }, { - name: 'hourFinished', + name: 'finished', label: t('hourFinished'), field: (row) => toHour(row.finished), sortable: true, align: 'left', - columnFilter: { - component: 'VnInputDate', - type: 'select', - filterValue: null, - event: getInputEvents, - }, }, { name: 'actions', @@ -170,7 +101,6 @@ const columns = computed(() => [ align: 'right', }, ]); -const params = reactive({}); const arrayData = useArrayData('EntryLatestBuys', { url: 'Buys/latestBuysFilter', order: ['itemFk DESC'], @@ -190,23 +120,6 @@ const allColumnNames = ref([]); const confirmationDialog = ref(false); const startingDate = ref(null); -const getInputEvents = (col) => { - return col.columnFilter.type === 'select' - ? { 'update:modelValue': () => applyColumnFilter(col) } - : { - 'keyup.enter': () => applyColumnFilter(col), - }; -}; - -const applyColumnFilter = async (col) => { - try { - params[col.field] = col.columnFilter.filterValue; - await arrayData.addFilter({ params }); - } catch (err) { - console.error('Error applying column filter', err); - } -}; - const cloneRoutes = () => { axios.post('Routes/clone', { created: startingDate.value, @@ -260,7 +173,6 @@ const openTicketsDialog = (id) => { onMounted(async () => { stateStore.rightDrawer = true; allColumnNames.value = columns.value.map((col) => col.name); - console.log('les columnes', allColumnNames.value); await arrayData.fetch({ append: false }); }); onUnmounted(() => (stateStore.rightDrawer = false)); @@ -435,7 +347,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));