From a68f53d9f7f867e50dee5b946d3d9370f9e4ace7 Mon Sep 17 00:00:00 2001 From: Kevin Martinez Date: Wed, 17 Jan 2024 09:04:10 -0400 Subject: [PATCH] Add route form --- src/components/FormModel.vue | 7 +- src/i18n/en/index.js | 4 +- src/i18n/es/index.js | 4 +- src/pages/Route/Card/RouteCard.vue | 21 +++ src/pages/Route/Card/RouteForm.vue | 215 +++++++++++++++++++++++++++++ src/pages/Route/RouteList.vue | 19 +-- src/router/modules/route.js | 26 ++++ 7 files changed, 283 insertions(+), 13 deletions(-) create mode 100644 src/pages/Route/Card/RouteCard.vue create mode 100644 src/pages/Route/Card/RouteForm.vue diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index a5560dfc0..4ad566bf8 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -128,13 +128,14 @@ async function save() { try { const body = $props.mapper ? $props.mapper(formData.value) : formData.value; + let response if ($props.urlCreate) { - await axios.post($props.urlCreate, body); + response = await axios.post($props.urlCreate, body); notify('globals.dataCreated', 'positive'); } else { - await axios.patch($props.urlUpdate || $props.url, body); + response = await axios.patch($props.urlUpdate || $props.url, body); } - emit('onDataSaved', formData.value); + emit('onDataSaved', formData.value, response); originalData.value = JSON.parse(JSON.stringify(formData.value)); hasChanges.value = false; } catch (err) { diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 72ed1cba8..2056f1907 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -807,7 +807,9 @@ export default { pageTitles: { routes: 'Routes', cmrsList: 'External CMRs list', - RouteList: 'List' + RouteList: 'List', + create: 'Create', + basicData: 'Basic Data' }, cmr: { list: { diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index f5a7483f4..970f23231 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -806,7 +806,9 @@ export default { pageTitles: { routes: 'Rutas', cmrsList: 'Listado de CMRs externos', - RouteList: 'Listado' + RouteList: 'Listado', + create: 'Crear', + basicData: 'Datos básicos', }, cmr: { list: { diff --git a/src/pages/Route/Card/RouteCard.vue b/src/pages/Route/Card/RouteCard.vue new file mode 100644 index 000000000..2082b67df --- /dev/null +++ b/src/pages/Route/Card/RouteCard.vue @@ -0,0 +1,21 @@ + + diff --git a/src/pages/Route/Card/RouteForm.vue b/src/pages/Route/Card/RouteForm.vue new file mode 100644 index 000000000..00ea18f4f --- /dev/null +++ b/src/pages/Route/Card/RouteForm.vue @@ -0,0 +1,215 @@ + + diff --git a/src/pages/Route/RouteList.vue b/src/pages/Route/RouteList.vue index ddf3e1a12..3dcc0af37 100644 --- a/src/pages/Route/RouteList.vue +++ b/src/pages/Route/RouteList.vue @@ -371,14 +371,14 @@ const updateWorker = (row, worker) => { - - - - - - - - + + + + + {{ t('newRoute') }} + + + @@ -389,6 +389,8 @@ const updateWorker = (row, worker) => { } +en: + newRoute: New Route es: ID: ID Worker: Trabajador @@ -398,4 +400,5 @@ es: Description: Descripción Hour started: Hora inicio Hour finished: Hora fin + newRoute: Nueva Ruta diff --git a/src/router/modules/route.js b/src/router/modules/route.js index 70c92f84b..f6553a4f1 100644 --- a/src/router/modules/route.js +++ b/src/router/modules/route.js @@ -38,6 +38,32 @@ export default { }, component: () => import('src/pages/Route/RouteList.vue'), }, + { + path: 'create', + name: 'RouteCreate', + meta: { + title: 'create', + }, + component: () => import('src/pages/Route/Card/RouteForm.vue'), + }, + ], + }, + { + name: 'RouteCard', + path: ':id', + component: () => import('src/pages/Route/Card/RouteCard.vue'), + // TODO: Add summary + redirect: { name: 'RouteBasicData' }, + children: [ + { + name: 'RouteBasicData', + path: 'basic-data', + meta: { + title: 'basicData', + icon: 'vn:settings', + }, + component: () => import('pages/Route/Card/RouteForm.vue'), + }, ], }, ],