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';
|
||||
|
||||
const $props = defineProps({
|
||||
zone: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const { push, currentRoute } = useRouter();
|
||||
const zoneId = currentRoute.value.params.id;
|
||||
|
@ -22,20 +15,14 @@ const zoneId = currentRoute.value.params.id;
|
|||
const actions = {
|
||||
clone: async () => {
|
||||
const opts = { message: t('Zone cloned'), type: 'positive' };
|
||||
let clonedZoneId;
|
||||
|
||||
try {
|
||||
const { data } = await axios.post(`Zones/${zoneId}/clone`, {
|
||||
shipped: $props.zone.value.shipped,
|
||||
});
|
||||
clonedZoneId = data;
|
||||
const { data } = await axios.post(`Zones/${zoneId}/clone`, {});
|
||||
notify(opts);
|
||||
push(`/zone/${data.id}/basic-data`);
|
||||
} catch (e) {
|
||||
opts.message = t('It was not able to clone the zone');
|
||||
opts.type = 'negative';
|
||||
} finally {
|
||||
notify(opts);
|
||||
|
||||
if (clonedZoneId) push({ name: 'ZoneSummary', params: { id: clonedZoneId } });
|
||||
}
|
||||
},
|
||||
remove: async () => {
|
||||
|
|
|
@ -58,20 +58,12 @@ const arrayData = useArrayData('ZoneEvents');
|
|||
|
||||
const exclusionGeoCreate = async () => {
|
||||
try {
|
||||
if (isNew.value) {
|
||||
const params = {
|
||||
zoneFk: parseInt(route.params.id),
|
||||
date: dated.value,
|
||||
geoIds: tickedNodes.value,
|
||||
};
|
||||
await axios.post('Zones/exclusionGeo', params);
|
||||
} else {
|
||||
const params = {
|
||||
zoneExclusionFk: props.event?.zoneExclusionFk,
|
||||
geoIds: tickedNodes.value,
|
||||
};
|
||||
await axios.post('Zones/updateExclusionGeo', params);
|
||||
}
|
||||
await refetchEvents();
|
||||
} catch (err) {
|
||||
console.error('Error creating exclusion geo: ', err);
|
||||
|
@ -85,7 +77,7 @@ const exclusionCreate = async () => {
|
|||
{ dated: dated.value },
|
||||
]);
|
||||
else
|
||||
await axios.put(`Zones/${route.params.id}/exclusions/${props.event?.id}`, {
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, {
|
||||
dated: dated.value,
|
||||
});
|
||||
|
||||
|
@ -103,8 +95,8 @@ const onSubmit = async () => {
|
|||
const deleteEvent = async () => {
|
||||
try {
|
||||
if (!props.event) return;
|
||||
const exclusionId = props.event?.zoneExclusionFk || props.event?.id;
|
||||
await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`);
|
||||
console.log('props.event: ', props.event);
|
||||
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
||||
await refetchEvents();
|
||||
} catch (err) {
|
||||
console.error('Error deleting event: ', err);
|
||||
|
@ -141,7 +133,11 @@ onMounted(() => {
|
|||
>
|
||||
<template #form-inputs>
|
||||
<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>
|
||||
<div class="column q-gutter-y-sm q-mb-md">
|
||||
<QRadio
|
||||
|
|
Loading…
Reference in New Issue