208 lines
5.4 KiB
Vue
208 lines
5.4 KiB
Vue
<template>
|
|
<v-expansion-panels class="calendar" variant="accordion" flat tile static v-model="openGroup">
|
|
<v-expansion-panel elevation="0" flat tile static>
|
|
<v-expansion-panel-title flat tile static class="py-0 px-3">
|
|
<div @click.stop="">
|
|
<span class="text-subtitle-2"> {{ title }} </span>
|
|
</div>
|
|
|
|
<v-btn
|
|
v-if="title === 'Мои календари'"
|
|
icon="mdi-plus"
|
|
class="simple-hover"
|
|
@click.stop="editCreatedCalendar()"
|
|
></v-btn>
|
|
</v-expansion-panel-title>
|
|
|
|
<v-expansion-panel-text flat tile static>
|
|
<template v-if="Object.keys(calendars).length > 0">
|
|
<v-list-item
|
|
v-for="(x, i) in calendars"
|
|
:key="x.id"
|
|
:value="x.cl_name"
|
|
@mouseenter="hover = i"
|
|
@mouseleave="hover = null"
|
|
:class="{ trasitlist: hover === i }"
|
|
class="pa-0 cursor-default"
|
|
>
|
|
<template v-slot:prepend>
|
|
<v-checkbox-btn
|
|
class="text-caption"
|
|
:class="`text-${x.cl_color}`"
|
|
:color="x.cl_color"
|
|
v-model="x.visible"
|
|
@update:modelValue="toggleVisiblityEvents(x)"
|
|
:model-value="x.visible"
|
|
></v-checkbox-btn>
|
|
</template>
|
|
<template v-slot:title>
|
|
<span class="text-body-2"> {{ x.cl_name }} </span>
|
|
</template>
|
|
|
|
<template v-slot:append>
|
|
<transition name="fade">
|
|
<v-btn
|
|
v-if="
|
|
x.author == user.is_idEmployee ||
|
|
x.participant.some(
|
|
(e) => e.editor === true && e.participant_calendar === user.is_idEmployee,
|
|
)
|
|
"
|
|
size="x-small"
|
|
icon="mdi-pen"
|
|
variant="text"
|
|
class="transitbtn"
|
|
@click.stop="editCreatedCalendar(x)"
|
|
></v-btn>
|
|
</transition>
|
|
</template>
|
|
</v-list-item>
|
|
</template>
|
|
<template v-else>
|
|
<div class="text-caption text-grey text-center pa-3">Календарей нет</div>
|
|
</template>
|
|
</v-expansion-panel-text>
|
|
</v-expansion-panel>
|
|
<v-dialog v-model="showDialog" min-width="636" max-width="800">
|
|
<calendar-create
|
|
@closeDialog="handleCloseDialog"
|
|
:calendar="calendar"
|
|
@getCalendar="$emit('getCalendar')"
|
|
/>
|
|
</v-dialog>
|
|
</v-expansion-panels>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, watch } from 'vue';
|
|
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
|
import { useAccountStore } from '@/store/AccountStore';
|
|
import { storeToRefs } from 'pinia';
|
|
import { useCalendarStore } from '@/store/calendarStore';
|
|
|
|
const props = defineProps({
|
|
calendars: Array,
|
|
title: String,
|
|
});
|
|
|
|
const emit = defineEmits(['getCalendar']);
|
|
|
|
const showDialog = ref(false);
|
|
const accountStore = useAccountStore();
|
|
const { user } = storeToRefs(accountStore);
|
|
const calendarStore = useCalendarStore();
|
|
|
|
const { hiddenCalendarIds, showCreateCalendarDialog, createCalendarInitial } =
|
|
storeToRefs(calendarStore);
|
|
|
|
const { toggleCalendarVisibility, resolveCreateCalendar } = calendarStore;
|
|
|
|
const calendar = ref(null);
|
|
const openGroup = ref([0]);
|
|
const hover = ref(0);
|
|
|
|
const editCreatedCalendar = (cal) => {
|
|
if (!cal) {
|
|
calendar.value = {
|
|
cl_name: '',
|
|
participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
|
|
cl_color: 'red',
|
|
cl_descr: '',
|
|
};
|
|
} else {
|
|
calendar.value = { ...cal };
|
|
}
|
|
showDialog.value = true;
|
|
};
|
|
|
|
const handleCloseDialog = () => {
|
|
const isValid = calendar.value?.cl_name?.length > 1;
|
|
if (showCreateCalendarDialog.value) {
|
|
resolveCreateCalendar(isValid ? JSON.parse(JSON.stringify(calendar.value)) : null);
|
|
}
|
|
|
|
showDialog.value = false;
|
|
};
|
|
|
|
const toggleVisiblityEvents = (cal) => {
|
|
toggleCalendarVisibility(cal.id);
|
|
};
|
|
|
|
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>
|
|
.simple-hover {
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
width: 22px !important;
|
|
height: 22px !important;
|
|
border-radius: 3px !important;
|
|
margin-left: 0.5rem;
|
|
background-color: #00897b !important;
|
|
color: white;
|
|
margin-bottom: 2px;
|
|
padding: 0;
|
|
}
|
|
|
|
.simple-hover:hover {
|
|
background-color: #004d40 !important;
|
|
transform: scale(1.1);
|
|
}
|
|
.fade-enter-active,
|
|
.fade-leave-active {
|
|
transition: opacity 0.1s;
|
|
}
|
|
.fade-enter,
|
|
.fade-leave-to {
|
|
transition: opacity 0.2s;
|
|
opacity: 0;
|
|
}
|
|
|
|
.calendar .v-expansion-panel-text__wrapper {
|
|
padding: 0 !important;
|
|
padding-right: 10px !important;
|
|
}
|
|
.trasitlist:hover .transitbtn {
|
|
animation-fill-mode: forwards;
|
|
/* transition: opacity 0.1s; */
|
|
animation-duration: 0.5s;
|
|
animation-name: filli;
|
|
}
|
|
|
|
@keyframes filli {
|
|
from {
|
|
margin-left: 100%;
|
|
opacity: 0;
|
|
}
|
|
|
|
to {
|
|
margin-left: 0%;
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
.transitbtn {
|
|
opacity: 0;
|
|
|
|
/* animation-direction: reverse; */
|
|
/* animation-duration: 0.1s;
|
|
animation-name: filli; */
|
|
}
|
|
</style>
|