diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index add2a29e9..1f0c58416 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -389,7 +389,9 @@ export default { wagon: { pageTitles: { wagons: 'Wagons', - list: 'List' + types: 'Types', + typeCreate: 'Create type', + typeEdit: 'Edit type' }, type: { name: 'Name', diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 91e69b13b..d9ac390a4 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -389,7 +389,9 @@ export default { wagon: { pageTitles: { wagons: 'Vagones', - list: 'Listado' + types: 'Tipos', + typeCreate: 'Crear tipo', + typeEdit: 'Editar tipo' }, type: { name: 'Nombre', diff --git a/src/pages/Wagon/WagonTray.vue b/src/pages/Wagon/Type/WagonTray.vue similarity index 100% rename from src/pages/Wagon/WagonTray.vue rename to src/pages/Wagon/Type/WagonTray.vue diff --git a/src/pages/Wagon/WagonTypeCreate.vue b/src/pages/Wagon/Type/WagonTypeCreate.vue similarity index 88% rename from src/pages/Wagon/WagonTypeCreate.vue rename to src/pages/Wagon/Type/WagonTypeCreate.vue index c431b808e..3657e31b8 100644 --- a/src/pages/Wagon/WagonTypeCreate.vue +++ b/src/pages/Wagon/Type/WagonTypeCreate.vue @@ -32,10 +32,12 @@ import FetchData from 'components/FetchData.vue'; import { useQuasar } from 'quasar'; import { ref } from 'vue'; import { useI18n } from 'vue-i18n'; -import WagonTray from './WagonTray.vue'; +import { useRouter } from 'vue-router'; +import WagonTray from '../Type/WagonTray.vue'; const { t } = useI18n(); const quasar = useQuasar(); +const router = useRouter(); const wagonConfig = ref([]); const wagonTypeColors = ref([]); const wagon = ref([]); @@ -45,7 +47,7 @@ let currentPosition = 0; function addTray() { if (wagon.value.length < wagonConfig.value.maxTrays - 1) { - currentPosition += wagonConfig.value.trayStep; + currentPosition += wagonConfig.value.minTrayHeight; wagon.value.unshift({ position: currentPosition, color: { @@ -65,7 +67,7 @@ function deleteTray(position) { currentPosition = 0; wagon.value = wagon.value.filter((tray) => tray.position !== position); for (let i = wagon.value.length - 1; i >= 0; i--) { - currentPosition += wagonConfig.value.trayStep; + currentPosition += wagonConfig.value.minTrayHeight; wagon.value[i].position = currentPosition; } } @@ -76,20 +78,23 @@ async function onSubmit() { .post('WagonTypes', { name: name.value, }) - .then((res) => { - wagon.value.forEach(async (tray) => { - await axios.post('WagonTypeTrays', { + .then(async (res) => { + const trays = []; + wagon.value.forEach((tray) => { + trays.push({ typeFk: res.data.id, height: tray.position, colorFk: tray.color.id, }); }); + await axios.post('WagonTypeTrays', trays).then(() => { + router.push({ path: `/wagon/type/list` }); + quasar.notify({ + message: t('wagon.type.saveMessage'), + type: 'positive', + }); + }); }); - - quasar.notify({ - message: t('wagon.type.saveMessage'), - type: 'positive', - }); } catch (error) { // } diff --git a/src/pages/Wagon/Type/WagonTypeEdit.vue b/src/pages/Wagon/Type/WagonTypeEdit.vue new file mode 100644 index 000000000..0d466f129 --- /dev/null +++ b/src/pages/Wagon/Type/WagonTypeEdit.vue @@ -0,0 +1,223 @@ + + + + + (wagonConfig = data[0])" + auto-load + /> + (wagonTypeColors = data)" + auto-load + /> + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/pages/Wagon/Type/WagonTypeList.vue b/src/pages/Wagon/Type/WagonTypeList.vue new file mode 100644 index 000000000..a4e00e19d --- /dev/null +++ b/src/pages/Wagon/Type/WagonTypeList.vue @@ -0,0 +1,100 @@ + + + + + + + + + + + + {{ t('globals.collapseMenu') }} + + + + + + + + + + + + + {{ row.name }} + #{{ row.id }} + + + + + + {{ t('components.smartCard.openCard') }} + + + + + + + + + + + + + + + + + +es: + Search wagon type: Buscar tipo de vagón + You can search by wagon type id or name: Puedes buscar por id o nombre del tipo de vagón + diff --git a/src/router/modules/wagon.js b/src/router/modules/wagon.js index 7059b3143..56d8cd548 100644 --- a/src/router/modules/wagon.js +++ b/src/router/modules/wagon.js @@ -15,19 +15,37 @@ export default { }, children: [ { - path: '', + path: '/wagon/type', name: 'WagonMain', component: () => import('src/pages/Wagon/WagonMain.vue'), redirect: { name: 'WagonTypeList' }, children: [ { path: 'list', - name: 'WagonTypeCreate', + name: 'WagonTypeList', meta: { - title: 'list', + title: 'types', icon: 'view_list', }, - component: () => import('src/pages/Wagon/WagonTypeCreate.vue'), + component: () => import('src/pages/Wagon/Type/WagonTypeList.vue') + }, + { + path: 'create', + name: 'WagonTypeCreate', + meta: { + title: 'typeCreate', + icon: 'create', + }, + component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue') + }, + { + path: ':id/edit', + name: 'WagonTypeEdit', + meta: { + title: 'typeEdit', + icon: 'edit', + }, + component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue') }, ], }