0
0
Fork 0

fix: fixed functionality like Salix

This commit is contained in:
Jon Elias 2024-11-28 12:26:33 +01:00
parent aaab41fe97
commit 61d0d71538
3 changed files with 19 additions and 38 deletions

View File

@ -67,7 +67,7 @@ const exclusionGeoCreate = async () => {
};
const exclusionCreate = async () => {
if (isNew.value)
if (isNew.value || props.event?.type)
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated }]);
else
await axios.put(`Zones/${route.params.id}/exclusions/${props.event?.id}`, {
@ -119,11 +119,7 @@ onMounted(() => {
>
<template #form-inputs>
<VnRow class="row q-gutter-md q-mb-lg">
<VnInputDate
:label="t('eventsInclusionForm.day')"
v-model="dated"
:required="true"
/>
<VnInputDate :label="t('eventsInclusionForm.day')" v-model="dated" />
</VnRow>
<div class="column q-gutter-y-sm q-mb-md">
<QRadio
@ -173,8 +169,8 @@ onMounted(() => {
class="q-mr-sm"
@click="
openConfirmationModal(
t('zone.deleteTitle'),
t('zone.deleteSubtitle'),
t('eventsPanel.deleteTitle'),
t('eventsPanel.deleteSubtitle'),
() => deleteEvent()
)
"

View File

@ -24,13 +24,14 @@ const zoneEventsFormProps = reactive({
date: null,
});
const openForm = (data) => {
const openForm = (data, isBtnAdd) => {
const { date = null, isNewMode, event, eventType, geoIds = [] } = data;
zoneEventsFormProps.date = date;
zoneEventsFormProps.isNewMode = isNewMode;
zoneEventsFormProps.event = event;
zoneEventsFormProps.eventType = eventType;
if (geoIds.length) zoneEventsFormProps.geoIds = geoIds;
if (isBtnAdd) formModeName.value = 'include';
showZoneEventForm.value = true;
};
@ -51,7 +52,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
:last-day="lastDay"
:events="events"
v-model:formModeName="formModeName"
@open-zone-form="openForm"
/>
</QScrollArea>
</QDrawer>
@ -65,7 +65,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
/>
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
<ZoneEventInclusionForm
v-if="formModeName === 'include'"
v-if="!formModeName || formModeName === 'include'"
v-bind="zoneEventsFormProps"
@close-form="onZoneEventFormClose()"
/>
@ -78,9 +78,12 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<QPageSticky :offset="[20, 20]">
<QBtn
@click="
openForm({
isNewMode: true,
})
openForm(
{
isNewMode: true,
},
true
)
"
color="primary"
fab

View File

@ -11,6 +11,10 @@ import { dashIfEmpty } from 'src/filters';
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
import { useVnConfirm } from 'composables/useVnConfirm';
const formModeName = defineModel('formModeName', {
type: String,
required: true,
});
const props = defineProps({
firstDay: {
type: Date,
@ -27,25 +31,13 @@ const props = defineProps({
required: true,
default: () => [],
},
formModeName: {
type: String,
required: true,
default: 'include',
},
});
const emit = defineEmits(['openZoneForm', 'update:formModeName']);
const { t } = useI18n();
const route = useRoute();
const weekdayStore = useWeekdayStore();
const { openConfirmationModal } = useVnConfirm();
const formName = computed({
get: () => props.formModeName,
set: (value) => emit('update:formModeName', value),
});
const params = computed(() => ({
zoneFk: route.params.id,
started: props.firstDay,
@ -88,16 +80,6 @@ const deleteEvent = async (id) => {
await fetchData();
};
const openInclusionForm = (event) => {
formName.value = 'include';
emit('openZoneForm', {
date: event.dated,
event,
isNewMode: false,
eventType: 'event',
});
};
onMounted(async () => {
weekdayStore.initStore();
});
@ -110,13 +92,13 @@ onMounted(async () => {
t('eventsPanel.editMode')
}}</span>
<QRadio
v-model="formName"
v-model="formModeName"
dense
val="include"
:label="t('eventsPanel.include')"
/>
<QRadio
v-model="formName"
v-model="formModeName"
dense
val="exclude"
:label="t('eventsPanel.exclude')"