P-42 Рабочая версия редактирования календаря

This commit is contained in:
iriska-gri committed 2024-06-25 13:33:23 +03:00
1 parent b982e01c16
commit d4ebc14212
5 files changed
+131 -136

No files matched your search

+1
View File
@@ -39,6 +39,7 @@ class MyCalendars(APIView):
'''
print(request.data, '---------------')
try:
ob=MyCalendarPostParameters(data=request.data)
@@ -44,35 +44,31 @@
</v-date-picker>
</v-locale-provider>
</v-col>
<v-col class="flex-column d-flex">
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
<v-col>
<calendar-my
:calendars="
calendarForMy.filter(
(e) => e.author == accountStore.user.is_idEmployee
)
"
title="Мои календари"
/>
<calendar-my
:calendars="
calendarForMy.filter(
(e) => e.author != accountStore.user.is_idEmployee
)
"
title="Подписки"
/>
<calendar-my
:calendars="
calendarForMy.filter(
(e) => e.author == accountStore.user.is_idEmployee
)
"
title="Мои календари"
@getCalendar="getCalendar"
/>
<calendar-my
:calendars="
calendarForMy.filter(
(e) => e.author != accountStore.user.is_idEmployee
)
"
title="Подписки"
/>
</v-col>
</v-row>
</v-col>
</v-row>
</v-card>
</v-col>
@@ -128,17 +124,19 @@ export default {
MyYear.value = year;
};
axiosApiInstance
.get("api/calendar_of_events/my_calendars/")
.then((res) => {
res.data.forEach(
(e) =>
(e.visible = accountStore.calendar.includes(e.id) ? false : true
)
);
calendarForMy.value = res.data;
console.log(calendarForMy.value, 'calendarForMy.valuecalendarForMy.valuecalendarForMy.value');
});
const getCalendar = () => {
axiosApiInstance
.get("api/calendar_of_events/my_calendars/")
.then((res) => {
res.data.forEach(
(e) =>
(e.visible = accountStore.calendar.includes(e.id) ? false : true)
);
calendarForMy.value = res.data;
});
};
getCalendar();
const weekendsData = () => {
cal.value.$el
@@ -198,6 +196,7 @@ export default {
showDialog,
calendarForMy,
accountStore,
getCalendar,
};
},
};
@@ -106,16 +106,16 @@ export default {
const filtered = ref("");
const staff = ref([]);
const calendarParticipant = computed({
get: () => props.participant,
set: (value) => emit("update:participant", value),
});
// const calendarParticipant = computed({
// get: () => props.participant,
// set: (value) => emit("update:participant", value),
// });
axiosApiInstance
.get("api/calendar_of_events/get_employees/")
.then((res) => {
staff.value = res.data.filter((e) => e.employees.length > 0);
staff.value.forEach((e) => {
if (props.participant.length > 0) {
e.employees.forEach((empl) => {
@@ -131,38 +131,26 @@ export default {
});
});
const selectedStaff = computed(() => {
let selected = [];
// let idEmployees = props.participant
let idEmployees = [];
staff.value.forEach((e) => {
e.employees
.filter((n) => n.selected == true)
.map((res) => {
calendarParticipant.value.push({ participant_calendar: res.id });
idEmployees.push({ participant_calendar: res.id });
});
if (e.employees.every((n) => n.selected == true)) {
e.selected = true;
selected.push(e);
}
else {
} else {
e.selected = false;
selected.push(...e.employees.filter((n) => n.selected == true));
}
});
emit("returnIdParticant", idEmployees);
// calendarParticipant.value = idEmployees
return selected;
});
@@ -3,8 +3,11 @@
<v-card min-height="436" class="pa-3">
{{ calendar }}
<v-card-title class="pr-0 pl-2 d-flex justify-space-between">
Новый календарь
{{
calendar.hasOwnProperty("id")
? "Редактирование календаря"
: "Новый календарь"
}}
<v-icon
icon="mdi-close cursor-pointer"
size="small"
@@ -55,10 +58,8 @@
<v-col>
<calendar-create-select
:participant="calendar.participant"
@update:participant="props.calendar.participant = $event"
/>
<!-- upParticant-->
</v-col
@returnIdParticant="returnIdParticant"
/> </v-col
></v-row>
</v-col>
<v-col class="d-flex flex-grow-0">
@@ -81,10 +82,10 @@
class="text-subtitle-1"
elevation="0"
width="150"
@click="dialog_create_calendar = false"
>Отменить</v-btn
>
<!-- @click="dialog_create_calendar = false" -->
<v-btn
class="text-subtitle-1 font-weight-regular"
color="btn_text"
@@ -92,8 +93,9 @@
elevation="0"
width="150"
@click="postCalendar"
>Создать</v-btn
>
{{ calendar.hasOwnProperty("id") ? "Редактировать" : "Создать" }}
</v-btn>
</v-card-actions>
<!-- <v-row no-gutters class="gap flex-column">
v-col*
@@ -138,34 +140,42 @@ export default {
calendar: {
type: Object,
default: { cl_name: "", participant: [] },
default: {
cl_name: "",
participant: [{ editor: true, participant_calendar: 0 }],
cl_color: "red",
cl_descr: "",
},
},
},
setup(props, { emit }) {
console.log('-1111111111111')
const postParticant = {};
// Возможно можно сделать запись короче
const returnIdParticant = (idPart) => {
console.log(props.calendar, "props.calendar");
postParticant.value = { ...props.calendar, participant: idPart };
};
const dialog_create_calendar = computed({
get: () => props.opendialog,
set: (value) => emit("update:opendialog", value),
});
const feedalert = useAlertStore().alert;
const postCalendar = () => {
axiosApiInstance
.post(`api/calendar_of_events/my_calendars/`, props.calendar)
.post(`api/calendar_of_events/my_calendars/`, postParticant.value)
.then((result) => {
feedalert.alert = true;
feedalert.text = result.data.mess;
feedalert.ico = "mdi-check";
feedalert.color = "green-darken-4";
emit("getCalendar");
});
dialog_create_calendar.value = false;
};
const color = [
@@ -194,18 +204,13 @@ export default {
}
};
const upParticant = () => {
console.log('hi')
props.calendar.participant = $event
}
return {
dialog_create_calendar,
postCalendar,
color,
colorPik,
upParticant
returnIdParticant,
};
},
};
@@ -1,6 +1,12 @@
<template>
<v-expansion-panels class="calendar" variant="accordion" flat tile static v-model="openGroup">
<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="">
@@ -18,54 +24,53 @@
</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="i"
: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}`"
v-model="x.visible"
:color="x.cl_color"
@update:modelValue="chekUpdate(x)"
></v-checkbox-btn>
</template>
<template v-slot:title>
<span class="text-body-2"> {{ x.cl_name }} </span>
</template>
<v-list-item
v-for="(x, i) in calendars"
:key="i"
: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}`"
v-model="x.visible"
:color="x.cl_color"
@update:modelValue="chekUpdate(x)"
></v-checkbox-btn>
</template>
<template v-slot:title>
<span class="text-body-2"> {{ x.cl_name }} </span>
</template>
<template v-slot:append>
<!-- <my-helper :pretext = x /> -->
<transition name="fade">
<v-btn
v-if="
(x.author == accountStore.user.is_idEmployee) ||
(x.participant.some(
(e) =>
e.editor == true &&
e.participant_calendar == accountStore.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 v-slot:append>
<!-- <my-helper :pretext = x /> -->
<transition name="fade">
<v-btn
v-if="
x.author == accountStore.user.is_idEmployee ||
x.participant.some(
(e) =>
e.editor == true &&
e.participant_calendar ==
accountStore.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">Календарей нет</div>
<div class="text-caption text-grey text-center">Календарей нет</div>
</template>
</v-expansion-panel-text>
</v-expansion-panel>
@@ -73,7 +78,7 @@
@update:opendialog="showDialog = $event"
:opendialog="showDialog"
:calendar="calendar"
@getCalendar="$emit('getCalendar')"
/>
</v-expansion-panels>
</template>
@@ -103,7 +108,7 @@ export default {
const calendar = ref({});
const openGroup = ref([0]);
const trans = ref(false);
const hover = ref(0)
const hover = ref(0);
@@ -130,7 +135,8 @@ export default {
accountStore,
openGroup,
trans,
hover
hover,
};
},
};
@@ -148,11 +154,10 @@ export default {
}
.calendar .v-expansion-panel-text__wrapper {
padding: 0!important;
padding-right: 10px!important;
padding: 0 !important;
padding-right: 10px !important;
}
.trasitlist:hover .transitbtn {
animation-fill-mode: forwards;
/* transition: opacity 0.1s; */
animation-duration: 0.5s;
@@ -173,12 +178,9 @@ export default {
.transitbtn {
opacity: 0;
/* animation-direction: reverse; */
/* animation-duration: 0.1s;
animation-name: filli; */
}
</style>