Zone list

This commit is contained in:
William Buezas 2024-05-08 15:23:52 -03:00
parent c18d035be5
commit a3ce81d66d
5 changed files with 106 additions and 102 deletions

View File

@ -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">

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -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',