Merge pull request #51 from dderbentsov/UC-20

Распределила из events владельцев событий
This commit is contained in:
Daria Golova
2022-10-21 17:29:48 +03:00
committed by GitHub
5 changed files with 210 additions and 24 deletions

141
server.js
View File

@@ -132,7 +132,7 @@ export function clientsServer() {
dataClients, dataClients,
})); }));
this.get("/registry/event/", () => ({ this.get("/registry/event/", () => ({
count: 1, count: 4,
next: null, next: null,
previous: null, previous: null,
results: [ results: [
@@ -157,6 +157,16 @@ export function clientsServer() {
}, },
], ],
employees: [ employees: [
{
id: "f941a0c6-c750-4f79-92c0-d7a19354e422",
employee: {
id: "db541a67-e836-481f-a653-6325de7c567e",
last_name: "Захарова",
first_name: "Ольга",
patronymic: "Александровна",
},
role: null,
},
{ {
id: "f941a0c6-c750-4f79-92c0-d7a19354e422", id: "f941a0c6-c750-4f79-92c0-d7a19354e422",
employee: { employee: {
@@ -169,6 +179,135 @@ export function clientsServer() {
}, },
], ],
}, },
{
id: "7faa7bb7-2de6-422c-a401-1b35cd455303",
start: "2022-10-20T10:00:00Z",
end: "2022-10-20T11:10:00Z",
kind: "call",
subkind: null,
description: "",
location: null,
members: [
{
id: "b0509f9a-e824-4bb3-a260-2b32dae9bc81",
person: {
id: "14ff401c-2b7b-4d9a-9159-720c74d8b23c",
last_name: "Гагарин",
first_name: "Юрий",
patronymic: "Алексеевич",
},
role: null,
},
],
employees: [
{
id: "f941a0c6-c734-4f79-92c2-d7a5674459e422",
employee: {
id: "db831a15-e876-481f-a658-6325de7c311e",
last_name: "Константинопольская",
first_name: "Юлия",
patronymic: "Викторовна",
},
role: null,
},
{
id: "f941a0c6-c750-4f79-92c0-d7a19354e422",
employee: {
id: "db541a67-e836-481f-a653-6325de7c567e",
last_name: "Захарова",
first_name: "Ольга",
patronymic: "Александровна",
},
role: "owner",
},
],
},
{
id: "2faa7bb2-2de6-422c-a401-1b35cd455223",
start: "2022-10-20T10:00:00Z",
end: "2022-10-20T11:10:00Z",
kind: "call",
subkind: null,
description: "",
location: null,
members: [
{
id: "b0509f9a-e824-4bb3-a260-2b32dae9bc81",
person: {
id: "14ff401c-2b7b-4d9a-9159-720c74d8b23c",
last_name: "Гагарин",
first_name: "Юрий",
patronymic: "Алексеевич",
},
role: null,
},
],
employees: [
{
id: "f941a0c6-c734-4f79-92c2-d7a5674459e422",
employee: {
id: "db831a15-e876-481f-a658-6325de7c311e",
last_name: "Константинопольская",
first_name: "Юлия",
patronymic: "Викторовна",
},
role: "owner",
},
{
id: "f941a0c6-c750-4f79-92c0-d7a19354e422",
employee: {
id: "db541a67-e836-481f-a653-6325de7c567e",
last_name: "Захарова",
first_name: "Ольга",
patronymic: "Александровна",
},
role: null,
},
],
},
{
id: "6faa6bb2-1de4-425c-a401-1b35cd455303",
start: "2022-10-20T20:23:49Z",
end: "2022-10-20T21:23:53Z",
kind: "call",
subkind: null,
description: "",
location: null,
members: [
{
id: "b0509f9a-e824-4bb3-a260-2b32dae9bc81",
person: {
id: "14ff401c-2b7b-4d9a-9159-720c74d8b23c",
last_name: "Гагарин",
first_name: "Юрий",
patronymic: "Алексеевич",
},
role: null,
},
],
employees: [
{
id: "f941a0c6-c750-4f79-92c0-d7a19354e422",
employee: {
id: "db541a67-e836-481f-a653-6325de7c567e",
last_name: "Захарова",
first_name: "Ольга",
patronymic: "Александровна",
},
role: null,
},
{
id: "f941a0c6-c750-4f79-92c0-d7a19354e422",
employee: {
id: "db831a14-e836-481f-a653-6325de7c311e",
last_name: "Жмыхов",
first_name: "Егор",
patronymic: "Сергеевич",
},
role: null,
},
],
},
], ],
})); }));
this.passthrough("http://45.84.227.122:8080/**"); this.passthrough("http://45.84.227.122:8080/**");

View File

@@ -4,7 +4,7 @@
calendar-schedule( calendar-schedule(
:current-date="currentDate" :current-date="currentDate"
:time-information="timeInformation" :time-information="timeInformation"
:column-information="columnInformation" :events-data="eventsData"
@previous-date="switchPreviousDate" @previous-date="switchPreviousDate"
@next-date="switchNextDate" @next-date="switchNextDate"
@selected-layout="changeCalendarLayout" @selected-layout="changeCalendarLayout"
@@ -27,14 +27,6 @@ export default {
dayEndTime: "18:00", dayEndTime: "18:00",
}, },
eventsData: [], eventsData: [],
columnInformation: {
owners: [
"Захарова А.О.",
"Константинопольская Ю.В.",
"Коломойцев И.К.",
"Зайцев В.С.",
],
},
}; };
}, },
methods: { methods: {
@@ -64,5 +56,5 @@ export default {
<style lang="sass" scoped> <style lang="sass" scoped>
.calendar-container .calendar-container
width: calc(100% - 80px) width: calc(100vw - 80px)
</style> </style>

View File

@@ -1,11 +1,12 @@
<template lang="pug"> <template lang="pug">
.calendar-background-wrapper.flex.flex-col( .calendar-background-wrapper.flex.flex-col(
ref="backgroundWrapper" ref="backgroundWrapper"
:class="scrollPresence"
) )
calendar-column( calendar-column(
v-for="(owner, index) in columnInformation.owners" v-for="(owner, index) in filteredOwners"
:key="owner" :key="owner.id"
:column-information="owner" :owner-data="owner"
:style="calculateColumnPosition(index)" :style="calculateColumnPosition(index)"
) )
.header(:style="backgroundExtendedWidth") .header(:style="backgroundExtendedWidth")
@@ -27,7 +28,7 @@ export default {
components: { CalendarColumn }, components: { CalendarColumn },
props: { props: {
hoursArray: Array, hoursArray: Array,
columnInformation: Object, eventsData: Array,
}, },
data() { data() {
return { return {
@@ -39,7 +40,7 @@ export default {
}, },
computed: { computed: {
ownersArrayLength() { ownersArrayLength() {
return this.columnInformation.owners.length; return this.filteredOwners.length;
}, },
backgroundExtendedWidth() { backgroundExtendedWidth() {
if (this.ownersArrayLength > 3) { if (this.ownersArrayLength > 3) {
@@ -54,6 +55,42 @@ export default {
backgroundHeight() { backgroundHeight() {
return (this.hoursArray.length - 1) * this.pixelsPerHour + 48; return (this.hoursArray.length - 1) * this.pixelsPerHour + 48;
}, },
scrollPresence() {
return {
scroll: this.ownersArrayLength > 3,
};
},
filteredOwners() {
let filteredArray = [];
let ownerAbsence = {
id: null,
last_name: null,
first_name: null,
patronymic: null,
};
this.eventsData.forEach(({ employees }) => {
let findedElement = employees.find((elem) => elem.role === "owner");
let emptyObjectPresence = this.findObjectInArray(
filteredArray,
ownerAbsence
);
if (!findedElement && !emptyObjectPresence) {
filteredArray.push(ownerAbsence);
}
if (findedElement) {
let ownerPresence = this.findObjectInArray(
filteredArray,
findedElement.employee
);
if (!ownerPresence) {
filteredArray.push(findedElement.employee);
}
}
});
return filteredArray.sort(
(previous, subsequent) => Boolean(subsequent.id) - Boolean(previous.id)
);
},
}, },
methods: { methods: {
calculateColumnPosition(elemIndex) { calculateColumnPosition(elemIndex) {
@@ -74,6 +111,11 @@ export default {
calculateBackgroundWidth() { calculateBackgroundWidth() {
this.backgroundWidth = this.$refs.backgroundWrapper.offsetWidth; this.backgroundWidth = this.$refs.backgroundWrapper.offsetWidth;
}, },
findObjectInArray(array, object) {
return array.find(
(item) => JSON.stringify(item) === JSON.stringify(object)
);
},
}, },
mounted() { mounted() {
this.calculateBackgroundWidth(); this.calculateBackgroundWidth();
@@ -82,10 +124,12 @@ export default {
</script> </script>
<style lang="sass" scoped> <style lang="sass" scoped>
.scroll
overflow-x: scroll
.calendar-background-wrapper .calendar-background-wrapper
width: 100% width: 100%
position: relative position: relative
overflow-x: scroll
.header .header
height: 48px height: 48px

View File

@@ -3,7 +3,7 @@
.header.flex.items-center.justify-between.py-2.px-6 .header.flex.items-center.justify-between.py-2.px-6
.flex.items-center .flex.items-center
img.avatar-wrapper.mr-2(src="@/assets/images/team-member.svg" alt="Team member") img.avatar-wrapper.mr-2(src="@/assets/images/team-member.svg" alt="Team member")
span.owner-name.font-medium.text-base.mr-6 {{ columnInformation }} span.owner-name.font-medium.text-base.mr-6 {{ ownerName }}
img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg") img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg")
base-doc-ok-button base-doc-ok-button
div div
@@ -15,7 +15,18 @@ export default {
name: "CalendarColumn", name: "CalendarColumn",
components: { BaseDocOkButton }, components: { BaseDocOkButton },
props: { props: {
columnInformation: String, ownerData: Object,
},
computed: {
ownerName() {
if (this.ownerData.id) {
return `${this.ownerData.last_name} ${this.ownerData.first_name.slice(
0,
1
)}.${this.ownerData.patronymic.slice(0, 1)}.`;
}
return null;
},
}, },
}; };
</script> </script>

View File

@@ -17,7 +17,7 @@
) )
calendar-background( calendar-background(
:hours-array="hoursArray" :hours-array="hoursArray"
:column-information="columnInformation" :events-data="eventsData"
) )
.time-circle-indicator.left-74px( .time-circle-indicator.left-74px(
v-if="isShownIndicator" v-if="isShownIndicator"
@@ -54,10 +54,10 @@ export default {
return {}; return {};
}, },
}, },
columnInformation: { eventsData: {
type: Object, type: Array,
default() { default() {
return {}; return [];
}, },
}, },
}, },
@@ -219,7 +219,7 @@ export default {
<style lang="sass" scoped> <style lang="sass" scoped>
.schedule .schedule
background-color: var(--default-white) background-color: var(--default-white)
width: calc(100% - 8px) width: calc(100% - 80px)
.time-line-indicator .time-line-indicator
width: calc(100% - 80px) width: calc(100% - 80px)