Merge pull request 'Hotfix[ZoneEvents]: Fixed zone exclusion dated and fixed exclusion and inclusion when there was already an event' (!1708) from Hotfix-ZoneExclusionDatedValue into master
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
Reviewed-on: #1708 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
b524a6d8eb
|
@ -68,7 +68,7 @@ const arrayData = useArrayData('ZoneEvents');
|
|||
const exclusionGeoCreate = async () => {
|
||||
const params = {
|
||||
zoneFk: parseInt(route.params.id),
|
||||
date: dated,
|
||||
date: dated.value,
|
||||
geoIds: tickedNodes.value,
|
||||
};
|
||||
await axios.post('Zones/exclusionGeo', params);
|
||||
|
@ -101,9 +101,17 @@ const exclusionCreate = async () => {
|
|||
const existsEvent = data.events.find(
|
||||
(event) => toDateFormat(event.dated) === toDateFormat(dated.value),
|
||||
);
|
||||
const existsGeoEvent = data.geoExclusions.find(
|
||||
(event) => toDateFormat(event.dated) === toDateFormat(dated.value),
|
||||
);
|
||||
if (existsEvent) {
|
||||
await axios.delete(`Zones/${existsEvent?.zoneFk}/events/${existsEvent?.id}`);
|
||||
}
|
||||
if (existsGeoEvent) {
|
||||
await axios.delete(
|
||||
`Zones/${existsGeoEvent?.zoneFk}/exclusions/${existsGeoEvent?.zoneExclusionFk}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (isNew.value || props.event?.type) await axios.post(`${url}`, [body]);
|
||||
else await axios.put(`${url}/${props.event?.id}`, body);
|
||||
|
|
|
@ -107,14 +107,27 @@ const createEvent = async () => {
|
|||
`Zones/${existsExclusion?.zoneFk}/exclusions/${existsExclusion?.id}`,
|
||||
);
|
||||
}
|
||||
const {
|
||||
dated: formDated,
|
||||
started,
|
||||
ended,
|
||||
type,
|
||||
weekDays,
|
||||
wdays,
|
||||
} = eventInclusionFormData.value;
|
||||
|
||||
if (isNew.value)
|
||||
await axios.post(`Zones/${id}/events`, eventInclusionFormData.value);
|
||||
else
|
||||
await axios.put(
|
||||
`Zones/${id}/events/${props.event?.id}`,
|
||||
eventInclusionFormData.value,
|
||||
);
|
||||
const payload = {
|
||||
dated: formDated,
|
||||
started,
|
||||
ended,
|
||||
type,
|
||||
weekDays,
|
||||
wdays,
|
||||
};
|
||||
|
||||
if (isNew.value || props.eventType === 'exclusion')
|
||||
await axios.post(`Zones/${id}/events`, payload);
|
||||
else await axios.put(`Zones/${id}/events/${props.event?.id}`, payload);
|
||||
}
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
|
|
Loading…
Reference in New Issue