diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index bfaa76588..aef24715a 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -69,6 +69,10 @@ const props = defineProps({ type: Boolean, default: true, }, + moduleName: { + type: String, + default: '', + }, }); const searchText = ref(); diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index c13c4f9a6..1868f804a 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -243,6 +243,9 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { function updateStateParams(data) { if (!route?.path) return; + const usesModuleName = userOptions.moduleName + ? `/${data[0].id}` + userOptions.moduleName + : `/${data[0].id}`; const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; if (store?.searchUrl) newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter); @@ -259,12 +262,12 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { const to = data?.length === 1 - ? path.replace(/\/(list|:id)|-list/, `/${data[0].id}`) + ? path.replace(/\/(list|:id)|-list/, usesModuleName) : path.replace(/:id.*/, ''); if (route.path != to) { const pushUrl = { path: to }; - if (to.endsWith('/list') || to.endsWith('/')) + if (to.endsWith('/list') || to.endsWith('/') || to.endsWith('/edit')) pushUrl.query = newUrl.query; return router.push(pushUrl) && { redirect: true }; } diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index bf001c9ba..cbcdce555 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -692,37 +692,6 @@ worker: sizeLimit: Size limit isOnReservationMode: Reservation mode machine: Machine -wagon: - type: - submit: Submit - reset: Reset - trayColor: Tray color - removeItem: Wagon type removed successfully - list: - plate: Plate - volume: Volume - remove: Remove - removeItem: Wagon removed successfully - create: - plate: Plate - label: Label - warnings: - noData: No data available - nameNotEmpty: Name can not be empty - labelNotEmpty: Label can not be empty - plateNotEmpty: Plate can not be empty - volumeNotEmpty: Volume can not be empty - typeNotEmpty: Type can not be empty - maxTrays: You have reached the max number of trays - minHeightBetweenTrays: 'The minimum height between trays is ' - maxWagonHeight: 'The maximum height of the wagon is ' - uncompleteTrays: There are incomplete trays - params: - label: Label - plate: Plate - volume: Volume - name: Name - supplier: list: payMethod: Pay method diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 2c95f936c..a3e98c34c 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -693,36 +693,6 @@ worker: sizeLimit: Tamaño límite isOnReservationMode: Modo de reserva machine: Máquina - -wagon: - type: - submit: Guardar - reset: Deshacer cambios - trayColor: Color de la bandeja - removeItem: Tipo de vagón borrado correctamente - list: - plate: Matrícula - volume: Volumen - remove: Borrar - removeItem: Vagón borrado correctamente - create: - label: Etiqueta - warnings: - noData: Sin datos disponibles - nameNotEmpty: El nombre no puede estar vacío - labelNotEmpty: La etiqueta no puede estar vacía - plateNotEmpty: La matrícula no puede estar vacía - volumeNotEmpty: El volumen no puede estar vacío - typeNotEmpty: El tipo no puede estar vacío - maxTrays: Has alcanzado el número máximo de bandejas - minHeightBetweenTrays: 'La distancia mínima entre bandejas es ' - maxWagonHeight: 'La altura máxima del vagón es ' - uncompleteTrays: Hay bandejas sin completar - params: - label: Etiqueta - plate: Matrícula - volume: Volumen - name: Nombre supplier: list: payMethod: Método de pago diff --git a/src/pages/Wagon/Type/WagonTypeEdit.vue b/src/pages/Wagon/Type/WagonTypeEdit.vue index 49492b1b9..8a5160f23 100644 --- a/src/pages/Wagon/Type/WagonTypeEdit.vue +++ b/src/pages/Wagon/Type/WagonTypeEdit.vue @@ -9,6 +9,7 @@ import { useI18n } from 'vue-i18n'; import axios from 'axios'; import VnPaginate from 'components/ui/VnPaginate.vue'; import WagonCreateTray from './WagonCreateTray.vue'; +import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; const { t } = useI18n(); const { notify } = useQuasar(); @@ -29,7 +30,7 @@ async function addTray(newTray) { const res = await axios.post(`WagonTypeTrays`, newTray); wagonTrays.value.push(res.data); notify({ - message: t(`Tray added successfully`), + message: t(`wagon.trayAdded`), type: 'positive', }); } @@ -41,7 +42,7 @@ async function deleteTray(trayToDelete) { wagonTrays.value.splice(index, 1); } notify({ - message: t('Tray deleted successfully'), + message: t('wagon.trayDeleted'), type: 'positive', }); } @@ -72,14 +73,29 @@ watch( }, { deep: true } ); + +const exprBuilder = (param, value) => { + switch (param) { + case 'search': + return /^\d+$/.test(value) ? { id: value } : { name: { like: `%${value}%` } }; + } +}; - - -en: - nameNotEmpty: The name cannot be empty -es: - Create new Wagon type: Crear nuevo tipo de vagón - Name: Nombre - nameNotEmpty: El nombre no puede estar vacío - diff --git a/src/pages/Wagon/WagonCreate.vue b/src/pages/Wagon/WagonCreate.vue index ac2aab6ce..356b613a8 100644 --- a/src/pages/Wagon/WagonCreate.vue +++ b/src/pages/Wagon/WagonCreate.vue @@ -7,6 +7,7 @@ import VnInput from 'src/components/common/VnInput.vue'; import { useRoute, useRouter } from 'vue-router'; import axios from 'axios'; +import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; onMounted(() => fetch()); onUpdated(() => fetch()); @@ -85,9 +86,25 @@ function filterType(val, update) { ); }); } + +const exprBuilder = (param, value) => { + switch (param) { + case 'search': + return /^\d+$/.test(value) + ? { label: value } + : { plate: { like: `%${value}%` } }; + } +};