Изменила архитектуру
This commit is contained in:
@@ -26,7 +26,7 @@ export default {
|
|||||||
currentDate: moment(),
|
currentDate: moment(),
|
||||||
timeInformation: {
|
timeInformation: {
|
||||||
dayStartTime: "0:00",
|
dayStartTime: "0:00",
|
||||||
dayEndTime: "20:00",
|
dayEndTime: "22:00",
|
||||||
},
|
},
|
||||||
eventsData: [],
|
eventsData: [],
|
||||||
teamData: [],
|
teamData: [],
|
||||||
|
|||||||
@@ -1,22 +1,9 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.calendar-background-wrapper.flex.flex-col(
|
.calendar-background-wrapper.flex.flex-col(
|
||||||
ref="backgroundWrapper"
|
ref="backgroundWrapper"
|
||||||
:class="horizontalScrollPresence"
|
:style="backgroundExtendedWidth"
|
||||||
)
|
)
|
||||||
.header-wrapper
|
.body.flex.flex-col
|
||||||
.header(:style="backgroundExtendedWidth")
|
|
||||||
calendar-column(
|
|
||||||
v-for="(owner, index) in filteredOwners"
|
|
||||||
:key="owner.id"
|
|
||||||
:owner-data="owner"
|
|
||||||
:style="calculateColumnPosition(index)"
|
|
||||||
:day-events="filterEventsByOwner(owner)"
|
|
||||||
:day-start-time="dayStartTime"
|
|
||||||
:day-end-time="dayEndTime"
|
|
||||||
)
|
|
||||||
.body.flex.flex-col(
|
|
||||||
:style="backgroundExtendedWidth"
|
|
||||||
)
|
|
||||||
.line-wrapper
|
.line-wrapper
|
||||||
.line.flex.items-center(
|
.line.flex.items-center(
|
||||||
v-for="hour in timeCoil"
|
v-for="hour in timeCoil"
|
||||||
@@ -26,10 +13,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CalendarColumn from "./CalendarColumn.vue";
|
|
||||||
export default {
|
export default {
|
||||||
name: "CalendarBackground",
|
name: "CalendarBackground",
|
||||||
components: { CalendarColumn },
|
|
||||||
props: {
|
props: {
|
||||||
timeCoil: Array,
|
timeCoil: Array,
|
||||||
filteredOwners: Array,
|
filteredOwners: Array,
|
||||||
@@ -38,6 +23,7 @@ export default {
|
|||||||
sidebarWidth: String,
|
sidebarWidth: String,
|
||||||
dayStartTime: Number,
|
dayStartTime: Number,
|
||||||
dayEndTime: Number,
|
dayEndTime: Number,
|
||||||
|
ownersCount: Number,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -52,24 +38,18 @@ export default {
|
|||||||
return this.filteredOwners.length;
|
return this.filteredOwners.length;
|
||||||
},
|
},
|
||||||
backgroundExtendedWidth() {
|
backgroundExtendedWidth() {
|
||||||
if (this.ownersArrayLength > 3) {
|
if (this.ownersCount > 3) {
|
||||||
return {
|
return {
|
||||||
width: `${this.defaultColumnWidth * this.ownersArrayLength}px`,
|
width: `${this.defaultColumnWidth * this.ownersCount}px`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
width: "auto",
|
width: "100%",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
backgroundHeight() {
|
backgroundHeight() {
|
||||||
return (this.timeCoil.length - 1) * this.pixelsPerHour + 48;
|
return (this.timeCoil.length - 1) * this.pixelsPerHour + 48;
|
||||||
},
|
},
|
||||||
filteredEventsByDate() {
|
|
||||||
return this.eventsData.filter(
|
|
||||||
({ start }) =>
|
|
||||||
start.slice(0, 10) === this.currentDate.format("YYYY-MM-DD")
|
|
||||||
);
|
|
||||||
},
|
|
||||||
horizontalScrollPresence() {
|
horizontalScrollPresence() {
|
||||||
return {
|
return {
|
||||||
"scroll-x": this.ownersArrayLength > 3,
|
"scroll-x": this.ownersArrayLength > 3,
|
||||||
@@ -97,18 +77,6 @@ export default {
|
|||||||
calculateBackgroundWidth() {
|
calculateBackgroundWidth() {
|
||||||
this.backgroundWidth = this.$refs.backgroundWrapper.scrollWidth;
|
this.backgroundWidth = this.$refs.backgroundWrapper.scrollWidth;
|
||||||
},
|
},
|
||||||
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();
|
||||||
@@ -117,11 +85,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
.scroll-x
|
|
||||||
overflow-x: auto
|
|
||||||
|
|
||||||
.calendar-background-wrapper
|
.calendar-background-wrapper
|
||||||
width: 100%
|
|
||||||
position: relative
|
position: relative
|
||||||
|
|
||||||
.header-wrapper
|
.header-wrapper
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.calendar-clock-column.flex.flex-col.items-end.gap-y-43.pt-9.pb-45px.px-3
|
.calendar-clock-column.flex.flex-col.items-end.gap-y-43.pb-45px.px-3
|
||||||
span.text-base(
|
span.text-base(
|
||||||
v-for="hour in timeCoil"
|
v-for="hour in timeCoil"
|
||||||
:key="hour"
|
:key="hour"
|
||||||
@@ -59,6 +59,4 @@ export default {
|
|||||||
width: 80px
|
width: 80px
|
||||||
height: 100%
|
height: 100%
|
||||||
color: var(--font-dark-blue-color)
|
color: var(--font-dark-blue-color)
|
||||||
position: sticky
|
|
||||||
left: 0
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -75,19 +75,15 @@ export default {
|
|||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
.calendar-column-wrapper
|
.calendar-column-wrapper
|
||||||
position: absolute
|
|
||||||
border-right: 1px solid var(--border-light-grey-color)
|
border-right: 1px solid var(--border-light-grey-color)
|
||||||
&:nth-last-child(2) .header
|
&:nth-last-child(2) .header
|
||||||
border-right: none
|
border-right: none
|
||||||
&:nth-last-child(2)
|
&:last-child
|
||||||
border-right: none
|
border-right: none
|
||||||
|
|
||||||
.header
|
.header
|
||||||
height: 48px
|
|
||||||
position: sticky
|
position: sticky
|
||||||
z-index: 5
|
z-index: 5
|
||||||
width: inherit
|
|
||||||
border-right: 1px solid var(--border-light-grey-color)
|
|
||||||
background-color: var(--default-white)
|
background-color: var(--default-white)
|
||||||
|
|
||||||
.body
|
.body
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.calendar-header-wrapper.flex.items-center.justify-between.py-3.pl-5.pr-6.top-0
|
.calendar-header-wrapper.flex.items-center.justify-between.py-3.pl-5.pr-6
|
||||||
.flex
|
.flex
|
||||||
base-arrow-button.left-arrow.mr-4(@click="previousHandler")
|
base-arrow-button.left-arrow.mr-4(@click="previousHandler")
|
||||||
base-arrow-button.right-arrow.mr-6(@click="nextHandler")
|
base-arrow-button.right-arrow.mr-6(@click="nextHandler")
|
||||||
@@ -51,7 +51,6 @@ export default {
|
|||||||
background-color: var(--default-white)
|
background-color: var(--default-white)
|
||||||
height: 56px
|
height: 56px
|
||||||
border-radius: 4px
|
border-radius: 4px
|
||||||
position: sticky
|
|
||||||
z-index: 10
|
z-index: 10
|
||||||
|
|
||||||
.left-arrow
|
.left-arrow
|
||||||
|
|||||||
@@ -10,32 +10,43 @@
|
|||||||
@next-date="nextDate"
|
@next-date="nextDate"
|
||||||
@selected-layout="selectedLayout"
|
@selected-layout="selectedLayout"
|
||||||
)
|
)
|
||||||
.schedule-body.flex(
|
.schedule-body
|
||||||
)
|
.column-wrapper.flex.ml-20.absolute(:style="columnWrapperWidth")
|
||||||
div
|
calendar-column(
|
||||||
calendar-clock-column(
|
v-for="(owner, index) in filteredOwners"
|
||||||
:timeCoil="timeCoil"
|
:key="owner.id"
|
||||||
:current-time="currentTime"
|
:owner-data="owner"
|
||||||
:is-current-date="isCurrentDate"
|
:day-events="filterEventsByOwner(owner)"
|
||||||
|
:day-start-time="validateStartTime"
|
||||||
:day-end-time="validateEndTime"
|
:day-end-time="validateEndTime"
|
||||||
|
:style="columnWidth"
|
||||||
|
)
|
||||||
|
.flex.w-full.relative
|
||||||
|
.time-coil-wrapper.left-0.-mt-3
|
||||||
|
calendar-clock-column(
|
||||||
|
:timeCoil="timeCoil"
|
||||||
|
:current-time="currentTime"
|
||||||
|
:is-current-date="isCurrentDate"
|
||||||
|
:day-end-time="validateEndTime"
|
||||||
|
)
|
||||||
|
.flex
|
||||||
|
calendar-background(
|
||||||
|
:current-date="currentDate"
|
||||||
|
:time-coil="timeCoil"
|
||||||
|
:events-data="eventsData"
|
||||||
|
:sidebar-width="sidebarWidth"
|
||||||
|
:day-start-time="validateStartTime"
|
||||||
|
:day-end-time="validateEndTime"
|
||||||
|
:owners-count="ownersCount"
|
||||||
|
)
|
||||||
|
.time-circle-indicator.left-74px(
|
||||||
|
v-if="isShownIndicator"
|
||||||
|
:style="circleIndicatorLocation"
|
||||||
|
)
|
||||||
|
span.time-line-indicator.block.left-20(
|
||||||
|
v-if="isShownIndicator"
|
||||||
|
:style="lineIndicatorLocation"
|
||||||
)
|
)
|
||||||
calendar-background(
|
|
||||||
:current-date="currentDate"
|
|
||||||
:time-coil="timeCoil"
|
|
||||||
:events-data="eventsData"
|
|
||||||
:filtered-owners="filteredOwners"
|
|
||||||
:sidebar-width="sidebarWidth"
|
|
||||||
:day-start-time="validateStartTime"
|
|
||||||
:day-end-time="validateEndTime"
|
|
||||||
)
|
|
||||||
.time-circle-indicator.left-74px(
|
|
||||||
v-if="isShownIndicator"
|
|
||||||
:style="circleIndicatorLocation"
|
|
||||||
)
|
|
||||||
span.time-line-indicator.block.left-20(
|
|
||||||
v-if="isShownIndicator"
|
|
||||||
:style="lineIndicatorLocation"
|
|
||||||
)
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -43,12 +54,14 @@ import * as moment from "moment/moment";
|
|||||||
import CalendarHeader from "./CalendarHeader.vue";
|
import CalendarHeader from "./CalendarHeader.vue";
|
||||||
import CalendarBackground from "./CalendarBackground.vue";
|
import CalendarBackground from "./CalendarBackground.vue";
|
||||||
import CalendarClockColumn from "./CalendarClockColumn.vue";
|
import CalendarClockColumn from "./CalendarClockColumn.vue";
|
||||||
|
import CalendarColumn from "./CalendarColumn.vue";
|
||||||
export default {
|
export default {
|
||||||
name: "CalendarSchedule",
|
name: "CalendarSchedule",
|
||||||
components: {
|
components: {
|
||||||
CalendarHeader,
|
CalendarHeader,
|
||||||
CalendarBackground,
|
CalendarBackground,
|
||||||
CalendarClockColumn,
|
CalendarClockColumn,
|
||||||
|
CalendarColumn,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
currentDate: {
|
currentDate: {
|
||||||
@@ -81,7 +94,6 @@ export default {
|
|||||||
pixelsPerHour: 62,
|
pixelsPerHour: 62,
|
||||||
columnHeaderHeight: 48,
|
columnHeaderHeight: 48,
|
||||||
defaultColumnWidth: 470,
|
defaultColumnWidth: 470,
|
||||||
sheduleHeight: 0,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -101,9 +113,9 @@ export default {
|
|||||||
return this.verifyTime(this.timeInformation.dayEndTime);
|
return this.verifyTime(this.timeInformation.dayEndTime);
|
||||||
},
|
},
|
||||||
lineIndicatorLocation() {
|
lineIndicatorLocation() {
|
||||||
if (this.filteredOwners.length > 3 && this.timeCoil.length - 1 > 13) {
|
if (this.ownersCount > 3 && this.timeCoil.length - 1 > 13) {
|
||||||
return {
|
return {
|
||||||
width: `${this.filteredOwners.length * this.defaultColumnWidth}px`,
|
width: `${this.ownersCount * this.defaultColumnWidth}px`,
|
||||||
top: `${this.calculateIndicatorLocation()}px`,
|
top: `${this.calculateIndicatorLocation()}px`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -161,6 +173,37 @@ export default {
|
|||||||
(previous, subsequent) => Boolean(subsequent.id) - Boolean(previous.id)
|
(previous, subsequent) => Boolean(subsequent.id) - Boolean(previous.id)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
ownersCount() {
|
||||||
|
return this.filteredOwners.length;
|
||||||
|
},
|
||||||
|
filteredEventsByDate() {
|
||||||
|
return this.eventsData.filter(
|
||||||
|
({ start }) =>
|
||||||
|
start.slice(0, 10) === this.currentDate.format("YYYY-MM-DD")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
columnWidth() {
|
||||||
|
if (this.ownersCount > 3) {
|
||||||
|
console.log(this.defaultColumnWidth * this.ownersCount);
|
||||||
|
return {
|
||||||
|
width: `${this.defaultColumnWidth}px`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
width: `calc(100% / ${this.ownersCount})`,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
columnWrapperWidth() {
|
||||||
|
if (this.ownersCount > 3) {
|
||||||
|
console.log(this.defaultColumnWidth * this.ownersCount);
|
||||||
|
return {
|
||||||
|
width: `${this.defaultColumnWidth * this.ownersCount}px`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
width: "100%",
|
||||||
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
previousDate() {
|
previousDate() {
|
||||||
@@ -224,8 +267,7 @@ export default {
|
|||||||
.map((elem) => parseInt(elem, 10));
|
.map((elem) => parseInt(elem, 10));
|
||||||
let result =
|
let result =
|
||||||
(newTime[0] - this.validateStartTime) * this.pixelsPerHour +
|
(newTime[0] - this.validateStartTime) * this.pixelsPerHour +
|
||||||
newTime[1] * this.pixelsPerMinute +
|
newTime[1] * this.pixelsPerMinute;
|
||||||
this.columnHeaderHeight;
|
|
||||||
if (result > this.scheduleHeight || result < 0) {
|
if (result > this.scheduleHeight || result < 0) {
|
||||||
this.isShownIndicator = false;
|
this.isShownIndicator = false;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -237,6 +279,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;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
currentTime() {
|
currentTime() {
|
||||||
@@ -281,8 +335,6 @@ export default {
|
|||||||
background-color: var(--default-white)
|
background-color: var(--default-white)
|
||||||
width: calc(100% - (var(--sidebar-width) + 8px))
|
width: calc(100% - (var(--sidebar-width) + 8px))
|
||||||
height: calc(100vh - 56px - 8px)
|
height: calc(100vh - 56px - 8px)
|
||||||
overflow-y: auto
|
|
||||||
overflow-x: hidden
|
|
||||||
|
|
||||||
.time-line-indicator
|
.time-line-indicator
|
||||||
width: calc(100% - 80px)
|
width: calc(100% - 80px)
|
||||||
@@ -296,6 +348,18 @@ export default {
|
|||||||
border-radius: 50%
|
border-radius: 50%
|
||||||
position: absolute
|
position: absolute
|
||||||
|
|
||||||
|
.column-wrapper
|
||||||
|
height: 48px
|
||||||
|
background-color: var(--default-white)
|
||||||
|
|
||||||
|
.time-coil-wrapper
|
||||||
|
position: sticky
|
||||||
|
z-index: 5
|
||||||
|
background-color: var(--default-white)
|
||||||
|
|
||||||
.schedule-body
|
.schedule-body
|
||||||
position: relative
|
width: 100%
|
||||||
|
height: calc(100vh - 56px - 8px - 56px)
|
||||||
|
overflow-y: auto
|
||||||
|
overflow-x: auto
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user