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