forked from verdnatura/salix-front
WIP
This commit is contained in:
parent
9b3135fd97
commit
68bb4251a4
|
@ -74,7 +74,7 @@ const closeForm = () => {
|
||||||
:disabled="isLoading"
|
:disabled="isLoading"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
/>
|
/>
|
||||||
<slot name="customButtons" />
|
<slot name="custom-buttons" />
|
||||||
</div>
|
</div>
|
||||||
</QCard>
|
</QCard>
|
||||||
</QForm>
|
</QForm>
|
||||||
|
|
|
@ -17,6 +17,7 @@ globals:
|
||||||
date: Date
|
date: Date
|
||||||
dataSaved: Data saved
|
dataSaved: Data saved
|
||||||
dataDeleted: Data deleted
|
dataDeleted: Data deleted
|
||||||
|
delete: Delete
|
||||||
search: Search
|
search: Search
|
||||||
changes: Changes
|
changes: Changes
|
||||||
dataCreated: Data created
|
dataCreated: Data created
|
||||||
|
|
|
@ -17,6 +17,7 @@ globals:
|
||||||
date: Fecha
|
date: Fecha
|
||||||
dataSaved: Datos guardados
|
dataSaved: Datos guardados
|
||||||
dataDeleted: Datos eliminados
|
dataDeleted: Datos eliminados
|
||||||
|
delete: Eliminar
|
||||||
search: Buscar
|
search: Buscar
|
||||||
changes: Cambios
|
changes: Cambios
|
||||||
dataCreated: Datos creados
|
dataCreated: Datos creados
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
@ -11,8 +11,8 @@ import VnWeekdayPicker from 'src/components/common/VnWeekdayPicker.vue';
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||||
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted } from 'vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
date: {
|
date: {
|
||||||
|
@ -30,11 +30,12 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['onSubmit']);
|
const emit = defineEmits(['onSubmit', 'closeForm']);
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const weekdayStore = useWeekdayStore();
|
const weekdayStore = useWeekdayStore();
|
||||||
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
|
|
||||||
const isNew = computed(() => props.isNewMode);
|
const isNew = computed(() => props.isNewMode);
|
||||||
const eventInclusionFormData = ref({});
|
const eventInclusionFormData = ref({});
|
||||||
|
@ -77,25 +78,35 @@ const createEvent = async () => {
|
||||||
|
|
||||||
await refetchEvents();
|
await refetchEvents();
|
||||||
emit('onSubmit');
|
emit('onSubmit');
|
||||||
|
|
||||||
// case 'delete':
|
|
||||||
// return this.onDelete(this.selected.id).then(
|
|
||||||
// (response) => response == 'accept'
|
|
||||||
// );
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error creating event', err);
|
console.error('Error creating event', err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deleteEvent = async () => {
|
||||||
|
try {
|
||||||
|
if (!props.event) return;
|
||||||
|
await axios.delete(`Zones/${route.params.id}/events/${props.event?.id}`);
|
||||||
|
await refetchEvents();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error deleting event: ', err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeForm = () => {
|
||||||
|
emit('closeForm');
|
||||||
|
};
|
||||||
|
|
||||||
const refetchEvents = async () => {
|
const refetchEvents = async () => {
|
||||||
await arrayData.refresh({ append: false });
|
await arrayData.refresh({ append: false });
|
||||||
|
closeForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log('props.event', props.event);
|
console.log('props.event', props.event);
|
||||||
if (props.event) {
|
if (props.event) {
|
||||||
eventInclusionFormData.value = { ...props.event };
|
eventInclusionFormData.value = { ...props.event };
|
||||||
eventType.value = props.event.type;
|
eventType.value = props.event?.type || 'day';
|
||||||
} else if (props.date) eventInclusionFormData.value.dated = props.date;
|
} else if (props.date) eventInclusionFormData.value.dated = props.date;
|
||||||
|
|
||||||
console.log('eventInclusionFormData', eventInclusionFormData.value);
|
console.log('eventInclusionFormData', eventInclusionFormData.value);
|
||||||
|
@ -107,8 +118,9 @@ onMounted(() => {
|
||||||
:title="
|
:title="
|
||||||
isNew ? t('eventsInclusionForm.addEvent') : t('eventsInclusionForm.editEvent')
|
isNew ? t('eventsInclusionForm.addEvent') : t('eventsInclusionForm.editEvent')
|
||||||
"
|
"
|
||||||
:custom-submit-button-label="isNew ? t('globals.save') : t('globals.add')"
|
|
||||||
@on-submit="createEvent()"
|
@on-submit="createEvent()"
|
||||||
|
:default-cancel-button="false"
|
||||||
|
:default-submit-button="false"
|
||||||
>
|
>
|
||||||
<template #form-inputs>
|
<template #form-inputs>
|
||||||
<div class="column q-gutter-y-sm q-mb-md">
|
<div class="column q-gutter-y-sm q-mb-md">
|
||||||
|
@ -193,6 +205,34 @@ onMounted(() => {
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
|
<template #custom-buttons>
|
||||||
|
<QBtn
|
||||||
|
:label="t('globals.cancel')"
|
||||||
|
color="primary"
|
||||||
|
flat
|
||||||
|
class="q-mr-sm"
|
||||||
|
v-close-popup
|
||||||
|
/>
|
||||||
|
<QBtn
|
||||||
|
v-if="!isNew"
|
||||||
|
:label="t('globals.delete')"
|
||||||
|
color="primary"
|
||||||
|
flat
|
||||||
|
class="q-mr-sm"
|
||||||
|
@click="
|
||||||
|
openConfirmationModal(
|
||||||
|
t('eventsPanel.deleteTitle'),
|
||||||
|
t('eventsPanel.deleteSubtitle'),
|
||||||
|
() => deleteEvent()
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<QBtn
|
||||||
|
:label="isNew ? t('globals.save') : t('globals.add')"
|
||||||
|
type="submit"
|
||||||
|
color="primary"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</FormPopup>
|
</FormPopup>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,7 @@ const openEventExcludeForm = ({ date, isNewMode }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onZoneEventFormClose = () => {
|
const onZoneEventFormClose = () => {
|
||||||
|
showZoneEventForm.value = false;
|
||||||
zoneEventsFormProps.date = null;
|
zoneEventsFormProps.date = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -283,8 +284,8 @@ onUnmounted(() => arrayData.destroy());
|
||||||
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
|
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
|
||||||
<ZoneEventInclusionForm
|
<ZoneEventInclusionForm
|
||||||
v-if="formModeName === 'include'"
|
v-if="formModeName === 'include'"
|
||||||
@on-data-saved="refetch()"
|
|
||||||
v-bind="zoneEventsFormProps"
|
v-bind="zoneEventsFormProps"
|
||||||
|
@close-form="onZoneEventFormClose()"
|
||||||
/>
|
/>
|
||||||
<ZoneEventExclusionForm v-else />
|
<ZoneEventExclusionForm v-else />
|
||||||
</QDialog>
|
</QDialog>
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
|
||||||
import { toDateFormat, toTimeFormat } from 'src/filters/date.js';
|
import { toDateFormat, toTimeFormat } from 'src/filters/date.js';
|
||||||
import { toCurrency } from 'filters/index';
|
import { toCurrency } from 'filters/index';
|
||||||
import { dashIfEmpty } from 'src/filters';
|
import { dashIfEmpty } from 'src/filters';
|
||||||
|
@ -38,7 +37,6 @@ const props = defineProps({
|
||||||
const emit = defineEmits(['openZoneForm', 'update:formModeName']);
|
const emit = defineEmits(['openZoneForm', 'update:formModeName']);
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const weekdayStore = useWeekdayStore();
|
const weekdayStore = useWeekdayStore();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
|
|
Loading…
Reference in New Issue