forked from verdnatura/salix-front
Merge pull request 'Hotfix: delete event and dated value when excluding a day' (!1010) from Hotfix-ZoneEventsExclusion into master
Reviewed-on: verdnatura/salix-front#1010 Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
commit
ddfcc0aff5
|
@ -124,8 +124,7 @@ const columns = computed(() => [
|
|||
</template>
|
||||
|
||||
<i18n>
|
||||
en:
|
||||
Search suppliers: Search suppliers
|
||||
es:
|
||||
es:
|
||||
Search suppliers: Buscar proveedores
|
||||
Create Supplier: Crear proveedor
|
||||
</i18n>
|
||||
|
|
|
@ -257,7 +257,7 @@ function toTicketUrl(section) {
|
|||
<QCard class="vn-one" v-if="entity.notes.length">
|
||||
<VnTitle
|
||||
:url="toTicketUrl('observation')"
|
||||
:text="t('ticket.pageTitles.notes')"
|
||||
:text="t('globals.pageTitles.notes')"
|
||||
/>
|
||||
<QVirtualScroll
|
||||
:items="entity.notes"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ref, computed, onMounted, reactive } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
|
@ -43,7 +43,7 @@ const { t } = useI18n();
|
|||
const { openConfirmationModal } = useVnConfirm();
|
||||
|
||||
const isNew = computed(() => props.isNewMode);
|
||||
const dated = ref(props.date);
|
||||
const dated = reactive(props.date);
|
||||
const tickedNodes = ref();
|
||||
|
||||
const _excludeType = ref('all');
|
||||
|
@ -67,12 +67,12 @@ const exclusionGeoCreate = async () => {
|
|||
};
|
||||
|
||||
const exclusionCreate = async () => {
|
||||
if (isNew.value)
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, [{ dated: dated.value }]);
|
||||
else
|
||||
await axios.post(`Zones/${route.params.id}/exclusions`, {
|
||||
dated: dated.value,
|
||||
});
|
||||
const url = `Zones/${route.params.id}/exclusions`;
|
||||
const body = {
|
||||
dated,
|
||||
};
|
||||
if (isNew.value || props.event?.type) await axios.post(`${url}`, [body]);
|
||||
else await axios.put(`${url}/${props.event?.id}`, body);
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
|
@ -83,7 +83,8 @@ const onSubmit = async () => {
|
|||
|
||||
const deleteEvent = async () => {
|
||||
if (!props.event) return;
|
||||
await axios.delete(`Zones/${route.params.id}/exclusions`);
|
||||
const exclusionId = props.event?.zoneExclusionFk || props.event?.id;
|
||||
await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`);
|
||||
await refetchEvents();
|
||||
};
|
||||
|
||||
|
@ -118,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
|
||||
|
@ -172,8 +169,8 @@ onMounted(() => {
|
|||
class="q-mr-sm"
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('zone.deleteTitle'),
|
||||
t('zone.deleteSubtitle'),
|
||||
t('eventsPanel.deleteTitle'),
|
||||
t('eventsPanel.deleteSubtitle'),
|
||||
() => deleteEvent()
|
||||
)
|
||||
"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')"
|
||||
|
|
|
@ -61,6 +61,8 @@ eventsPanel:
|
|||
events: Events
|
||||
everyday: Everyday
|
||||
delete: Delete
|
||||
deleteTitle: This item will be deleted
|
||||
deleteSubtitle: Are you sure you want to continue?
|
||||
eventsExclusionForm:
|
||||
addExclusion: Add exclusion
|
||||
editExclusion: Edit exclusion
|
||||
|
@ -76,6 +78,7 @@ eventsInclusionForm:
|
|||
rangeOfDates: Range of dates
|
||||
from: From
|
||||
to: To
|
||||
day: Day
|
||||
upcomingDeliveries:
|
||||
province: Province
|
||||
closing: Closing
|
||||
|
|
|
@ -61,6 +61,8 @@ eventsPanel:
|
|||
events: Eventos
|
||||
everyday: Todos los días
|
||||
delete: Eliminar
|
||||
deleteTitle: Eliminar evento
|
||||
deleteSubtitle: ¿Seguro que quieres eliminar este evento?
|
||||
eventsExclusionForm:
|
||||
addExclusion: Añadir exclusión
|
||||
editExclusion: Editar exclusión
|
||||
|
@ -76,5 +78,6 @@ eventsInclusionForm:
|
|||
rangeOfDates: Rango de fechas
|
||||
from: Desde
|
||||
to: Hasta
|
||||
day: Día
|
||||
upcomingDeliveries:
|
||||
province: Provincia
|
||||
|
|
Loading…
Reference in New Issue