From 590e764cc267916c9a82f18f16232d8711da15e7 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 7 Mar 2025 07:09:07 +0100 Subject: [PATCH 01/10] feat: refs #7869 added include and exclude event from list --- .../Zone/Card/ZoneEventExclusionForm.vue | 59 ++++++++++++++---- .../Zone/Card/ZoneEventInclusionForm.vue | 40 ++++++++---- src/pages/Zone/ZoneCalendarGrid.vue | 4 +- src/pages/Zone/ZoneList.vue | 61 ++++++++++++++++++- src/pages/Zone/locale/en.yml | 2 + src/pages/Zone/locale/es.yml | 2 + src/stores/useWeekdayStore.js | 4 +- 7 files changed, 144 insertions(+), 28 deletions(-) diff --git a/src/pages/Zone/Card/ZoneEventExclusionForm.vue b/src/pages/Zone/Card/ZoneEventExclusionForm.vue index 4b6aa52bd..8c630cb18 100644 --- a/src/pages/Zone/Card/ZoneEventExclusionForm.vue +++ b/src/pages/Zone/Card/ZoneEventExclusionForm.vue @@ -1,16 +1,18 @@ + + + + + + + diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml index e53e7b560..c11e4cbad 100644 --- a/src/pages/Zone/locale/en.yml +++ b/src/pages/Zone/locale/en.yml @@ -33,6 +33,8 @@ list: createZone: Create zone zoneSummary: Summary addressFk: Address + includeEvent: Include event + excludeEvent: Exclude event create: name: Name closingHour: Closing hour diff --git a/src/pages/Zone/locale/es.yml b/src/pages/Zone/locale/es.yml index bc31e74a9..5fcb85b8a 100644 --- a/src/pages/Zone/locale/es.yml +++ b/src/pages/Zone/locale/es.yml @@ -35,6 +35,8 @@ list: createZone: Crear zona zoneSummary: Resumen addressFk: Consignatario + includeEvent: Incluir evento + excludeEvent: Excluir evento create: closingHour: Hora de cierre itemMaxSize: Medida máxima diff --git a/src/stores/useWeekdayStore.js b/src/stores/useWeekdayStore.js index 57a302dc1..bf6b2704d 100644 --- a/src/stores/useWeekdayStore.js +++ b/src/stores/useWeekdayStore.js @@ -77,14 +77,14 @@ export const useWeekdayStore = defineStore('weekdayStore', () => { const locales = {}; for (let code of localeOrder.es) { const weekDay = weekdaysMap[code]; - const locale = t(`weekdays.${weekdaysMap[code].code}`); + const locale = t(`weekdays.${weekDay?.code}`); const obj = { ...weekDay, locale, localeChar: locale.substr(0, 1), localeAbr: locale.substr(0, 3), }; - locales[weekDay.code] = obj; + locales[weekDay?.code] = obj; } return locales; }); From 268d723eb11182241aac08269761d10573346e4c Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 7 Mar 2025 12:29:03 +0100 Subject: [PATCH 02/10] refactor: refs #7869 merged changes with #8606 --- .../Zone/Card/ZoneEventExclusionForm.vue | 3 +- .../Zone/Card/ZoneEventInclusionForm.vue | 32 ++++++++++++-- src/pages/Zone/ZoneList.vue | 44 +++++++++---------- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/src/pages/Zone/Card/ZoneEventExclusionForm.vue b/src/pages/Zone/Card/ZoneEventExclusionForm.vue index 8822b9657..3b33d5036 100644 --- a/src/pages/Zone/Card/ZoneEventExclusionForm.vue +++ b/src/pages/Zone/Card/ZoneEventExclusionForm.vue @@ -83,7 +83,8 @@ const exclusionCreate = async () => { const body = { dated: dated.value, }; - for (const id of props.zoneIds) { + const zoneIds = props.zoneIds?.length ? props.zoneIds : [route.params.id]; + for (const id of zoneIds) { const url = `Zones/${id}/exclusions`; let today = moment(dated.value); let lastDay = today.clone().add(4, 'months').endOf('month'); diff --git a/src/pages/Zone/Card/ZoneEventInclusionForm.vue b/src/pages/Zone/Card/ZoneEventInclusionForm.vue index dac71f513..bb329b0a3 100644 --- a/src/pages/Zone/Card/ZoneEventInclusionForm.vue +++ b/src/pages/Zone/Card/ZoneEventInclusionForm.vue @@ -3,6 +3,12 @@ import { ref, computed, onMounted } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; import { useQuasar } from 'quasar'; +import axios from 'axios'; +import moment from 'moment'; + +import { useArrayData } from 'src/composables/useArrayData'; +import { useWeekdayStore } from 'src/stores/useWeekdayStore'; +import { useVnConfirm } from 'composables/useVnConfirm'; import VnRow from 'components/ui/VnRow.vue'; import FormPopup from 'components/FormPopup.vue'; @@ -10,10 +16,7 @@ import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnWeekdayPicker from 'src/components/common/VnWeekdayPicker.vue'; import VnInputTime from 'components/common/VnInputTime.vue'; import VnInput from 'src/components/common/VnInput.vue'; -import { useArrayData } from 'src/composables/useArrayData'; -import { useWeekdayStore } from 'src/stores/useWeekdayStore'; -import { useVnConfirm } from 'composables/useVnConfirm'; -import axios from 'axios'; +import { toDateFormat } from 'src/filters/date'; const props = defineProps({ date: { @@ -79,6 +82,27 @@ const createEvent = async () => { const zoneIds = props.zoneIds?.length ? props.zoneIds : [route.params.id]; for (const id of zoneIds) { + let today = moment(eventInclusionFormData.value.dated); + let lastDay = today.clone().add(4, 'months').endOf('month'); + + const { data } = await axios.get(`Zones/getEventsFiltered`, { + params: { + zoneFk: id, + started: today, + ended: lastDay, + }, + }); + const existsExclusion = data.exclusions.find( + (exclusion) => + toDateFormat(exclusion.dated) === + toDateFormat(eventInclusionFormData.value.dated), + ); + if (existsExclusion) { + await axios.delete( + `Zones/${existsExclusion?.zoneFk}/exclusions/${existsExclusion?.id}`, + ); + } + if (isNew.value) await axios.post(`Zones/${id}/events`, eventInclusionFormData.value); else diff --git a/src/pages/Zone/ZoneList.vue b/src/pages/Zone/ZoneList.vue index 9eac801c0..8d7c4a165 100644 --- a/src/pages/Zone/ZoneList.vue +++ b/src/pages/Zone/ZoneList.vue @@ -213,28 +213,6 @@ const closeEventForm = () => {