forked from verdnatura/salix-front
fix events and descriptor menu
This commit is contained in:
parent
2189244730
commit
41afc52f65
|
@ -8,13 +8,6 @@ import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
zone: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { push, currentRoute } = useRouter();
|
const { push, currentRoute } = useRouter();
|
||||||
const zoneId = currentRoute.value.params.id;
|
const zoneId = currentRoute.value.params.id;
|
||||||
|
@ -22,20 +15,14 @@ const zoneId = currentRoute.value.params.id;
|
||||||
const actions = {
|
const actions = {
|
||||||
clone: async () => {
|
clone: async () => {
|
||||||
const opts = { message: t('Zone cloned'), type: 'positive' };
|
const opts = { message: t('Zone cloned'), type: 'positive' };
|
||||||
let clonedZoneId;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.post(`Zones/${zoneId}/clone`, {
|
const { data } = await axios.post(`Zones/${zoneId}/clone`, {});
|
||||||
shipped: $props.zone.value.shipped,
|
notify(opts);
|
||||||
});
|
push(`/zone/${data.id}/basic-data`);
|
||||||
clonedZoneId = data;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
opts.message = t('It was not able to clone the zone');
|
opts.message = t('It was not able to clone the zone');
|
||||||
opts.type = 'negative';
|
opts.type = 'negative';
|
||||||
} finally {
|
|
||||||
notify(opts);
|
|
||||||
|
|
||||||
if (clonedZoneId) push({ name: 'ZoneSummary', params: { id: clonedZoneId } });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove: async () => {
|
remove: async () => {
|
||||||
|
|
|
@ -58,20 +58,12 @@ const arrayData = useArrayData('ZoneEvents');
|
||||||
|
|
||||||
const exclusionGeoCreate = async () => {
|
const exclusionGeoCreate = async () => {
|
||||||
try {
|
try {
|
||||||
if (isNew.value) {
|
|
||||||
const params = {
|
const params = {
|
||||||
zoneFk: parseInt(route.params.id),
|
zoneFk: parseInt(route.params.id),
|
||||||
date: dated.value,
|
date: dated.value,
|
||||||
geoIds: tickedNodes.value,
|
geoIds: tickedNodes.value,
|
||||||
};
|
};
|
||||||
await axios.post('Zones/exclusionGeo', params);
|
await axios.post('Zones/exclusionGeo', params);
|
||||||
} else {
|
|
||||||
const params = {
|
|
||||||
zoneExclusionFk: props.event?.zoneExclusionFk,
|
|
||||||
geoIds: tickedNodes.value,
|
|
||||||
};
|
|
||||||
await axios.post('Zones/updateExclusionGeo', params);
|
|
||||||
}
|
|
||||||
await refetchEvents();
|
await refetchEvents();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error creating exclusion geo: ', err);
|
console.error('Error creating exclusion geo: ', err);
|
||||||
|
@ -85,7 +77,7 @@ const exclusionCreate = async () => {
|
||||||
{ dated: dated.value },
|
{ dated: dated.value },
|
||||||
]);
|
]);
|
||||||
else
|
else
|
||||||
await axios.put(`Zones/${route.params.id}/exclusions/${props.event?.id}`, {
|
await axios.post(`Zones/${route.params.id}/exclusions`, {
|
||||||
dated: dated.value,
|
dated: dated.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -103,8 +95,8 @@ const onSubmit = async () => {
|
||||||
const deleteEvent = async () => {
|
const deleteEvent = async () => {
|
||||||
try {
|
try {
|
||||||
if (!props.event) return;
|
if (!props.event) return;
|
||||||
const exclusionId = props.event?.zoneExclusionFk || props.event?.id;
|
console.log('props.event: ', props.event);
|
||||||
await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`);
|
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
||||||
await refetchEvents();
|
await refetchEvents();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error deleting event: ', err);
|
console.error('Error deleting event: ', err);
|
||||||
|
@ -141,7 +133,11 @@ onMounted(() => {
|
||||||
>
|
>
|
||||||
<template #form-inputs>
|
<template #form-inputs>
|
||||||
<VnRow class="row q-gutter-md q-mb-lg">
|
<VnRow class="row q-gutter-md q-mb-lg">
|
||||||
<VnInputDate :label="t('eventsInclusionForm.day')" v-model="dated" />
|
<VnInputDate
|
||||||
|
:label="t('eventsInclusionForm.day')"
|
||||||
|
v-model="dated"
|
||||||
|
:model-value="props.date"
|
||||||
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<div class="column q-gutter-y-sm q-mb-md">
|
<div class="column q-gutter-y-sm q-mb-md">
|
||||||
<QRadio
|
<QRadio
|
||||||
|
|
Loading…
Reference in New Issue