diff --git a/src/pages/Zone/Card/ZoneSummary.vue b/src/pages/Zone/Card/ZoneSummary.vue index 00df03cb0..90241c9a3 100644 --- a/src/pages/Zone/Card/ZoneSummary.vue +++ b/src/pages/Zone/Card/ZoneSummary.vue @@ -28,19 +28,25 @@ onMounted(async () => { }); const filter = computed(() => { - return { where: { id: entityId.value } }; + const params = { + filter: { + include: { + relation: 'agencyMode', + fields: ['name'], + }, + where: { + id: entityId.value, + }, + }, + }; + return params; }); </script> <template> - <CardSummary - data-key="zoneData" - ref="summary" - :url="`Zones/summary`" - :filter="filter" - > + <CardSummary data-key="zoneData" ref="summary" url="Zones/findOne" :filter="filter"> <template #header="{ entity }"> - <div>{{ entity.id }} - {{ entity.firstName }} {{ entity.lastName }}</div> + <div>#{{ entity.id }} - {{ entity.name }}</div> </template> <template #body="{ entity: zone }"> <QCard class="vn-one"> diff --git a/src/pages/Zone/ZoneList.vue b/src/pages/Zone/ZoneList.vue index f260eb134..2b18df033 100644 --- a/src/pages/Zone/ZoneList.vue +++ b/src/pages/Zone/ZoneList.vue @@ -1,63 +1,61 @@ <script setup> import axios from 'axios'; -import { useQuasar } from 'quasar'; import VnPaginate from 'src/components/ui/VnPaginate.vue'; -import { useArrayData } from 'src/composables/useArrayData'; import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; import CardList from 'components/ui/CardList.vue'; import VnLv from 'components/ui/VnLv.vue'; -import FetchData from 'src/components/FetchData.vue'; +import ZoneSummary from 'src/pages/Zone/Card/ZoneSummary.vue'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { toTimeFormat } from 'src/filters/date'; +import { toCurrency } from 'filters/index'; +import { useVnConfirm } from 'composables/useVnConfirm'; +import useNotify from 'src/composables/useNotify.js'; -const quasar = useQuasar(); -const arrayData = useArrayData('ZoneList'); -const store = arrayData.store; -const router = useRouter(); const { t } = useI18n(); +const router = useRouter(); +const { notify } = useNotify(); const { viewSummary } = useSummaryDialog(); +const { openConfirmationModal } = useVnConfirm(); -function navigate(id) { - router.push({ path: `/zone/${id}/edit` }); -} +const redirectToZoneSummary = (id) => { + router.push({ name: 'ZoneSummary', params: { id } }); +}; -function create() { +function redirectToCreateView() { router.push({ path: `/zone/create` }); } -async function remove(row) { +async function clone(id) { try { - await axios.delete(`Zones/${row.id}`).then(async () => { - quasar.notify({ - message: t('zone.list.removeItem'), - type: 'positive', - }); - store.data.splice(store.data.indexOf(row), 1); - }); + await axios.post(`Zones/${id}/clone`); + notify(t('globals.dataSaved'), 'positive'); + //TODO: Redireccionar Zone Basic data cuando exista + // router.push({ name: 'ZoneBasicData', params: { id: row.id } }); } catch (error) { - // + console.error('Error cloning zone: ', error); } } </script> <template> - <FetchData - url="/Agencies" - @on-fetch="(data) => (agencyOptions = data)" - :filter="{ fields: ['id', 'name'] }" - auto-load - /> <QPage class="column items-center q-pa-md"> <div class="vn-card-list"> - <VnPaginate data-key="ZoneList" url="/Zones" order="id DESC" auto-load> + <VnPaginate + data-key="ZoneList" + url="Zones" + :filter="{ + include: { relation: 'agencyMode', scope: { fields: ['name'] } }, + }" + auto-load + > <template #body="{ rows }"> <CardList v-for="row of rows" :key="row.id" - :title="(row.label || '').toString()" + :title="row.name" :id="row.id" - @click="navigate(row.id)" + @click="redirectToZoneSummary(row.id)" > <template #list-items> <VnLv @@ -68,22 +66,29 @@ async function remove(row) { <VnLv :label="t('zone.list.name')" :value="row?.name" /> <VnLv :label="t('zone.list.agency')" - :options="agencyOptions" - option-value="id" - option-label="name" - :value="row?.agencyFk" + :value="row.agencyMode?.name" /> <VnLv :label="t('zone.list.close')" :value="toTimeFormat(row?.hour)" /> - <VnLv :label="t('zone.list.price')" :value="row?.price" /> + <VnLv + :label="t('zone.list.price')" + :value="toCurrency(row?.price)" + /> </template> <template #actions> <QBtn - :label="t('components.smartCard.openCard')" - @click.stop="navigate(row.id)" + :label="t('zone.list.clone')" + @click.stop=" + openConfirmationModal( + t('zone.list.confirmCloneTitle'), + t('zone.list.confirmCloneSubtitle'), + () => clone(row.id) + ) + " outline + style="margin-top: 15px" /> <QBtn :label="t('zone.list.openSummary')" @@ -91,20 +96,13 @@ async function remove(row) { color="primary" style="margin-top: 15px" /> - <!--AQUI PONER BOTÓN CLONAR--> - <QBtn - :label="t('zone.list.clone')" - @click.stop="remove(row)" - color="primary" - style="margin-top: 15px" - /> </template> </CardList> </template> </VnPaginate> </div> <QPageSticky position="bottom-right" :offset="[18, 18]"> - <QBtn @click="create" fab icon="add" color="primary"> + <QBtn @click="redirectToCreateView()" fab icon="add" color="primary"> <QTooltip>{{ t('zone.list.create') }}</QTooltip> </QBtn> </QPageSticky> diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml index e62111d57..273092f88 100644 --- a/src/pages/Zone/locale/en.yml +++ b/src/pages/Zone/locale/en.yml @@ -9,6 +9,8 @@ zone: price: Price create: Create zone openSummary: Details + confirmCloneTitle: All it's properties will be copied + confirmCloneSubtitle: Do you want to clone this zone? create: name: Name agency: Agency diff --git a/src/pages/Zone/locale/es.yml b/src/pages/Zone/locale/es.yml index 5d7a265bf..e1f928621 100644 --- a/src/pages/Zone/locale/es.yml +++ b/src/pages/Zone/locale/es.yml @@ -9,6 +9,8 @@ zone: price: Precio create: Crear zona openSummary: Detalles + confirmCloneTitle: Todas sus propiedades serán copiadas + confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona? create: name: Nombre agency: Agencia diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js index 079dfaa84..e01099ff3 100644 --- a/src/router/modules/zone.js +++ b/src/router/modules/zone.js @@ -11,58 +11,54 @@ export default { component: RouterView, redirect: { name: 'ZoneMain' }, menus: { - main: [ - /*'ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'*/ - ], - card: [ - // - ], + main: ['ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'], + card: [], }, children: [ - // { - // path: '/zone', - // name: 'ZoneMain', - // component: () => import('src/pages/Zone/ZoneMain.vue'), - // redirect: { name: 'ZoneList' }, - // children: [ - // { - // path: 'list', - // name: 'ZoneList', - // meta: { - // title: 'zonesList', - // icon: 'vn:zone', - // }, - // component: () => import('src/pages/Zone/ZoneList.vue'), - // }, - // { - // path: 'create', - // name: 'ZoneCreate', - // meta: { - // title: 'zoneCreate', - // icon: 'create', - // }, - // component: () => import('src/pages/Zone/ZoneCreate.vue'), - // }, - // { - // path: ':id/edit', - // name: 'ZoneEdit', - // meta: { - // title: 'zoneEdit', - // icon: 'edit', - // }, - // component: () => import('src/pages/Zone/ZoneCreate.vue'), - // }, - // { - // path: 'counter', - // name: 'ZoneCounter', - // meta: { - // title: 'zoneCounter', - // icon: 'add_circle', - // }, - // component: () => import('src/pages/Zone/ZoneCounter.vue'), - // }, - // ], - // }, + { + path: '/zone', + name: 'ZoneMain', + component: () => import('src/pages/Zone/ZoneMain.vue'), + redirect: { name: 'ZoneList' }, + children: [ + { + path: 'list', + name: 'ZoneList', + meta: { + title: 'zonesList', + icon: 'vn:zone', + }, + component: () => import('src/pages/Zone/ZoneList.vue'), + }, + { + path: 'create', + name: 'ZoneCreate', + meta: { + title: 'zoneCreate', + icon: 'create', + }, + component: () => import('src/pages/Zone/ZoneCreate.vue'), + }, + { + path: ':id/edit', + name: 'ZoneEdit', + meta: { + title: 'zoneEdit', + icon: 'edit', + }, + component: () => import('src/pages/Zone/ZoneCreate.vue'), + }, + { + path: 'counter', + name: 'ZoneCounter', + meta: { + title: 'zoneCounter', + icon: 'add_circle', + }, + component: () => import('src/pages/Zone/ZoneCounter.vue'), + }, + ], + }, { name: 'ZoneCard', path: ':id',