fix [P-304]: переделка компонентов от мутаций стора, переход на Pinia для диалогов

This commit is contained in:
Inna committed 2026-05-29 11:55:09 +03:00
1 parent 1f7dc86728
commit 27a2e3680b
12 files changed
+1060 -1222

No files matched your search

@@ -74,7 +74,7 @@
</template>
<script setup>
import { onMounted, ref, watch } from 'vue';
import { ref, watch } from 'vue';
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
import { useAccountStore } from '@/store/AccountStore';
import { storeToRefs } from 'pinia';
@@ -91,15 +91,18 @@ const showDialog = ref(false);
const accountStore = useAccountStore();
const { user } = storeToRefs(accountStore);
const calendarStore = useCalendarStore();
const { toggleCalendarVisibility, hiddenCalendarIds } = calendarStore;
const { hiddenCalendarIds, showCreateCalendarDialog, createCalendarInitial } =
storeToRefs(calendarStore);
const { toggleCalendarVisibility, resolveCreateCalendar } = calendarStore;
const calendar = ref(null);
const openGroup = ref([0]);
// const trans = ref(false);
const hover = ref(0);
const editCreatedCalendar = (cal) => {
if (cal === undefined) {
if (!cal) {
calendar.value = {
cl_name: '',
participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
@@ -112,39 +115,36 @@ const editCreatedCalendar = (cal) => {
showDialog.value = true;
};
onMounted(() => {
window.$createCalendar = () => {
editCreatedCalendar();
};
});
const handleCloseDialog = () => {
if (calendar.value.cl_name.length > 1) {
const calendarData = JSON.parse(JSON.stringify(calendar.value));
window.dispatchEvent(
new CustomEvent('calendarCreated', {
detail: calendarData,
}),
);
const isValid = calendar.value?.cl_name?.length > 1;
if (showCreateCalendarDialog.value) {
resolveCreateCalendar(isValid ? JSON.parse(JSON.stringify(calendar.value)) : null);
}
showDialog.value = false;
};
const resetCalendar = () => {
calendar.value = {};
showDialog.value = false;
};
const toggleVisiblityEvents = (cal) => {
toggleCalendarVisibility(cal.id);
};
watch(hiddenCalendarIds, (newHiddenIds) => {}, { deep: true });
watch(
() => props.calendars,
(newCalendars) => {},
{ deep: true },
);
watch(showDialog, (open) => {
if (!open && showCreateCalendarDialog.value) {
resolveCreateCalendar(null);
}
});
watch(showCreateCalendarDialog, (open) => {
if (open && props.title === 'Мои календари') {
editCreatedCalendar(createCalendarInitial.value);
}
});
</script>
<style>