forked from verdnatura/salix-front
fix: fixed functionality like Salix
This commit is contained in:
parent
aaab41fe97
commit
61d0d71538
|
@ -67,7 +67,7 @@ const exclusionGeoCreate = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const exclusionCreate = async () => {
|
const exclusionCreate = async () => {
|
||||||
if (isNew.value)
|
if (isNew.value || props.event?.type)
|
||||||
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated }]);
|
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated }]);
|
||||||
else
|
else
|
||||||
await axios.put(`Zones/${route.params.id}/exclusions/${props.event?.id}`, {
|
await axios.put(`Zones/${route.params.id}/exclusions/${props.event?.id}`, {
|
||||||
|
@ -119,11 +119,7 @@ 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
|
<VnInputDate :label="t('eventsInclusionForm.day')" v-model="dated" />
|
||||||
:label="t('eventsInclusionForm.day')"
|
|
||||||
v-model="dated"
|
|
||||||
:required="true"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<div class="column q-gutter-y-sm q-mb-md">
|
<div class="column q-gutter-y-sm q-mb-md">
|
||||||
<QRadio
|
<QRadio
|
||||||
|
@ -173,8 +169,8 @@ onMounted(() => {
|
||||||
class="q-mr-sm"
|
class="q-mr-sm"
|
||||||
@click="
|
@click="
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('zone.deleteTitle'),
|
t('eventsPanel.deleteTitle'),
|
||||||
t('zone.deleteSubtitle'),
|
t('eventsPanel.deleteSubtitle'),
|
||||||
() => deleteEvent()
|
() => deleteEvent()
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
|
|
@ -24,13 +24,14 @@ const zoneEventsFormProps = reactive({
|
||||||
date: null,
|
date: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const openForm = (data) => {
|
const openForm = (data, isBtnAdd) => {
|
||||||
const { date = null, isNewMode, event, eventType, geoIds = [] } = data;
|
const { date = null, isNewMode, event, eventType, geoIds = [] } = data;
|
||||||
zoneEventsFormProps.date = date;
|
zoneEventsFormProps.date = date;
|
||||||
zoneEventsFormProps.isNewMode = isNewMode;
|
zoneEventsFormProps.isNewMode = isNewMode;
|
||||||
zoneEventsFormProps.event = event;
|
zoneEventsFormProps.event = event;
|
||||||
zoneEventsFormProps.eventType = eventType;
|
zoneEventsFormProps.eventType = eventType;
|
||||||
if (geoIds.length) zoneEventsFormProps.geoIds = geoIds;
|
if (geoIds.length) zoneEventsFormProps.geoIds = geoIds;
|
||||||
|
if (isBtnAdd) formModeName.value = 'include';
|
||||||
|
|
||||||
showZoneEventForm.value = true;
|
showZoneEventForm.value = true;
|
||||||
};
|
};
|
||||||
|
@ -51,7 +52,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
:last-day="lastDay"
|
:last-day="lastDay"
|
||||||
:events="events"
|
:events="events"
|
||||||
v-model:formModeName="formModeName"
|
v-model:formModeName="formModeName"
|
||||||
@open-zone-form="openForm"
|
|
||||||
/>
|
/>
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
|
@ -65,7 +65,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
/>
|
/>
|
||||||
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
|
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
|
||||||
<ZoneEventInclusionForm
|
<ZoneEventInclusionForm
|
||||||
v-if="formModeName === 'include'"
|
v-if="!formModeName || formModeName === 'include'"
|
||||||
v-bind="zoneEventsFormProps"
|
v-bind="zoneEventsFormProps"
|
||||||
@close-form="onZoneEventFormClose()"
|
@close-form="onZoneEventFormClose()"
|
||||||
/>
|
/>
|
||||||
|
@ -78,9 +78,12 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
<QPageSticky :offset="[20, 20]">
|
<QPageSticky :offset="[20, 20]">
|
||||||
<QBtn
|
<QBtn
|
||||||
@click="
|
@click="
|
||||||
openForm({
|
openForm(
|
||||||
isNewMode: true,
|
{
|
||||||
})
|
isNewMode: true,
|
||||||
|
},
|
||||||
|
true
|
||||||
|
)
|
||||||
"
|
"
|
||||||
color="primary"
|
color="primary"
|
||||||
fab
|
fab
|
||||||
|
|
|
@ -11,6 +11,10 @@ import { dashIfEmpty } from 'src/filters';
|
||||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
|
|
||||||
|
const formModeName = defineModel('formModeName', {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
firstDay: {
|
firstDay: {
|
||||||
type: Date,
|
type: Date,
|
||||||
|
@ -27,25 +31,13 @@ const props = defineProps({
|
||||||
required: true,
|
required: true,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
formModeName: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
default: 'include',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['openZoneForm', 'update:formModeName']);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const weekdayStore = useWeekdayStore();
|
const weekdayStore = useWeekdayStore();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
|
|
||||||
const formName = computed({
|
|
||||||
get: () => props.formModeName,
|
|
||||||
set: (value) => emit('update:formModeName', value),
|
|
||||||
});
|
|
||||||
|
|
||||||
const params = computed(() => ({
|
const params = computed(() => ({
|
||||||
zoneFk: route.params.id,
|
zoneFk: route.params.id,
|
||||||
started: props.firstDay,
|
started: props.firstDay,
|
||||||
|
@ -88,16 +80,6 @@ const deleteEvent = async (id) => {
|
||||||
await fetchData();
|
await fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openInclusionForm = (event) => {
|
|
||||||
formName.value = 'include';
|
|
||||||
emit('openZoneForm', {
|
|
||||||
date: event.dated,
|
|
||||||
event,
|
|
||||||
isNewMode: false,
|
|
||||||
eventType: 'event',
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
weekdayStore.initStore();
|
weekdayStore.initStore();
|
||||||
});
|
});
|
||||||
|
@ -110,13 +92,13 @@ onMounted(async () => {
|
||||||
t('eventsPanel.editMode')
|
t('eventsPanel.editMode')
|
||||||
}}</span>
|
}}</span>
|
||||||
<QRadio
|
<QRadio
|
||||||
v-model="formName"
|
v-model="formModeName"
|
||||||
dense
|
dense
|
||||||
val="include"
|
val="include"
|
||||||
:label="t('eventsPanel.include')"
|
:label="t('eventsPanel.include')"
|
||||||
/>
|
/>
|
||||||
<QRadio
|
<QRadio
|
||||||
v-model="formName"
|
v-model="formModeName"
|
||||||
dense
|
dense
|
||||||
val="exclude"
|
val="exclude"
|
||||||
:label="t('eventsPanel.exclude')"
|
:label="t('eventsPanel.exclude')"
|
||||||
|
|
Loading…
Reference in New Issue