Сделала карточку и фильтрацию событий по дате

This commit is contained in:
Daria Golova
2022-10-24 18:08:16 +03:00
parent 65afb4c60f
commit 47b4eddb91
6 changed files with 150 additions and 57 deletions

118
server.js
View File

@@ -255,8 +255,8 @@ export function clientsServer() {
results: [ results: [
{ {
id: "6faa6bb6-1de6-422c-a401-1b35cd455303", id: "6faa6bb6-1de6-422c-a401-1b35cd455303",
start: "2022-10-20T20:23:49Z", start: "2022-10-24T20:23:49Z",
end: "2022-10-20T21:23:53Z", end: "2022-10-24T21:23:53Z",
kind: "call", kind: "call",
subkind: null, subkind: null,
description: "", description: "",
@@ -296,10 +296,53 @@ export function clientsServer() {
}, },
], ],
}, },
{
id: "6faa6bb6-1de6-422c-a401-1b35cd455303",
start: "2022-10-24T15:23:49Z",
end: "2022-10-24T16:23:53Z",
kind: "call",
subkind: null,
description: "",
location: null,
members: [
{
id: "f7648f9a-e824-4bb3-a260-2b32dae9bc74",
person: {
id: "98dd401c-2b7b-4d9a-9159-720c74d8b23v",
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: "owner",
},
],
},
{ {
id: "7faa7bb7-2de6-422c-a401-1b35cd455303", id: "7faa7bb7-2de6-422c-a401-1b35cd455303",
start: "2022-10-20T10:00:00Z", start: "2022-10-23T10:00:00Z",
end: "2022-10-20T11:10:00Z", end: "2022-10-23T11:10:00Z",
kind: "call", kind: "call",
subkind: null, subkind: null,
description: "", description: "",
@@ -315,6 +358,16 @@ export function clientsServer() {
}, },
role: null, role: null,
}, },
{
id: "a9239f9a-e824-4bb3-a260-2b32dae9bc76",
person: {
id: "15ff465c-2b7b-4d9a-9159-720c74d8b56d",
last_name: "Елесеевская",
first_name: "Татьяна",
patronymic: "Ивановна",
},
role: "primary",
},
], ],
employees: [ employees: [
{ {
@@ -341,20 +394,20 @@ export function clientsServer() {
}, },
{ {
id: "2faa7bb2-2de6-422c-a401-1b35cd455223", id: "2faa7bb2-2de6-422c-a401-1b35cd455223",
start: "2022-10-20T10:00:00Z", start: "2022-10-24T10:00:00Z",
end: "2022-10-20T11:10:00Z", end: "2022-10-24T11:10:00Z",
kind: "call", kind: "call",
subkind: null, subkind: null,
description: "", description: "",
location: null, location: null,
members: [ members: [
{ {
id: "b0509f9a-e824-4bb3-a260-2b32dae9bc81", id: "a9239f9a-e824-4bb3-a260-2b32dae9bc76",
person: { person: {
id: "14ff401c-2b7b-4d9a-9159-720c74d8b23c", id: "15ff465c-2b7b-4d9a-9159-720c74d8b56d",
last_name: "Гагарин", last_name: "Елесеевская",
first_name: "Юрий", first_name: "Татьяна",
patronymic: "Алексеевич", patronymic: "Ивановна",
}, },
role: null, role: null,
}, },
@@ -382,49 +435,6 @@ export function clientsServer() {
}, },
], ],
}, },
{
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

@@ -8,6 +8,7 @@
:key="owner.id" :key="owner.id"
:owner-data="owner" :owner-data="owner"
:style="calculateColumnPosition(index)" :style="calculateColumnPosition(index)"
:day-events="filterEventsByOwner(owner)"
) )
.header(:style="backgroundExtendedWidth") .header(:style="backgroundExtendedWidth")
.body.flex.flex-col( .body.flex.flex-col(
@@ -29,6 +30,7 @@ export default {
props: { props: {
hoursArray: Array, hoursArray: Array,
eventsData: Array, eventsData: Array,
currentDate: Object,
}, },
data() { data() {
return { return {
@@ -91,6 +93,12 @@ export default {
(previous, subsequent) => Boolean(subsequent.id) - Boolean(previous.id) (previous, subsequent) => Boolean(subsequent.id) - Boolean(previous.id)
); );
}, },
filteredEventsByDate() {
return this.eventsData.filter(
({ start }) =>
start.slice(0, 10) === this.currentDate.format("YYYY-MM-DD")
);
},
}, },
methods: { methods: {
calculateColumnPosition(elemIndex) { calculateColumnPosition(elemIndex) {
@@ -116,6 +124,18 @@ export default {
(item) => JSON.stringify(item) === JSON.stringify(object) (item) => JSON.stringify(item) === JSON.stringify(object)
); );
}, },
filterEventsByOwner(owner) {
let filteredArray = [];
this.filteredEventsByDate.forEach((item) => {
let foundEvent = item.employees.find(
(elem) =>
JSON.stringify(elem.employee) === JSON.stringify(owner) &&
elem.role === "owner"
);
if (foundEvent) filteredArray.push(item);
});
return filteredArray;
},
}, },
mounted() { mounted() {
this.calculateBackgroundWidth(); this.calculateBackgroundWidth();

View File

@@ -54,7 +54,7 @@ export default {
<style lang="sass" scoped> <style lang="sass" scoped>
.current-time .current-time
color: var(--time-indicator-color) color: var(--bg-event-red-color)
.calendar-clock-column .calendar-clock-column
width: 80px width: 80px

View File

@@ -6,16 +6,23 @@
span.owner-name.font-medium.text-base.mr-6 {{ ownerName }} 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 .px-1
calendar-event-card(
v-for="event in dayEvents"
:key="event.id"
:ownerEvent="event"
)
</template> </template>
<script> <script>
import BaseDocOkButton from "@/components/base/buttons/BaseDocOkButton.vue"; import BaseDocOkButton from "@/components/base/buttons/BaseDocOkButton.vue";
import CalendarEventCard from "./CalendarEventCard.vue";
export default { export default {
name: "CalendarColumn", name: "CalendarColumn",
components: { BaseDocOkButton }, components: { BaseDocOkButton, CalendarEventCard },
props: { props: {
ownerData: Object, ownerData: Object,
dayEvents: Array,
}, },
computed: { computed: {
ownerName() { ownerName() {

View File

@@ -0,0 +1,55 @@
<template lang="pug">
.wrapper.flex.px-2.my-1.cursor-pointer
.header.flex.justify-between.items-center
.header-text
span.inline-block.align-middle.font-bold.text-base.mr-4 {{ eventTime }}
span.inline-block.align-middle.font-medium.text-base {{ eventMember }}
</template>
<script>
export default {
name: "CalendarEventCard",
props: {
ownerEvent: Object,
},
computed: {
eventTime() {
return `${this.trimTime(this.ownerEvent.start)} - ${this.trimTime(
this.ownerEvent.end
)}`;
},
eventMember() {
let membersArray = this.ownerEvent.members;
if (membersArray.length > 1) {
let primaryMember = membersArray.find(
(elem) => elem.role === "primary"
);
return this.composeFullName(primaryMember.person);
}
return this.composeFullName(membersArray[0].person);
},
},
methods: {
trimTime(time) {
return time.slice(11, -4);
},
composeFullName(object) {
return `${object.last_name} ${object.first_name} ${object.patronymic}`;
},
},
};
</script>
<style lang="sass" scoped>
.wrapper
width: 100%
height: 23px
border-radius: 4px
background-color: var(--bg-event-yellow-color)
color: var(--font-black-color)
position: relative
z-index: 2
.header
width: 100%
</style>

View File

@@ -16,6 +16,7 @@
:day-end-time="validateEndTime" :day-end-time="validateEndTime"
) )
calendar-background( calendar-background(
:current-date="currentDate"
:hours-array="hoursArray" :hours-array="hoursArray"
:events-data="eventsData" :events-data="eventsData"
) )