Merge pull request #48 from dderbentsov/UC-20

WIP Настроила высоту колонок с учетом скролла
This commit is contained in:
Daria Golova
2022-10-20 19:13:39 +03:00
committed by GitHub
7 changed files with 226 additions and 71 deletions

View File

@@ -35,6 +35,46 @@ export function clientsServer() {
},
],
}));
this.get("/registry/event/", () => ({
count: 1,
next: null,
previous: null,
results: [
{
id: "6faa6bb6-1de6-422c-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: "db831a14-e836-481f-a653-6325de7c311e",
last_name: "Жмыхов",
first_name: "Егор",
patronymic: "Сергеевич",
},
role: "owner",
},
],
},
],
}));
this.passthrough("http://45.84.227.122:8080/**");
},
});

View File

@@ -3,6 +3,7 @@
calendar-schedule(
:current-date="currentDate"
:time-information="timeInformation"
:column-information="columnInformation"
@previous-date="switchPreviousDate"
@next-date="switchNextDate"
@selected-layout="changeCalendarLayout"
@@ -24,6 +25,14 @@ export default {
dayEndTime: "18:00",
},
eventsData: [],
columnInformation: {
owners: [
"Захарова А.О.",
"Константинопольская Ю.В.",
"Коломойцев И.К.",
"Зайцев В.С.",
],
},
};
},
methods: {
@@ -40,7 +49,7 @@ export default {
this.eventsData = res.results;
},
fetchEventsData() {
fetch("http://45.84.227.122:8080/registry/event/")
fetch("/registry/event/")
.then((res) => res.json())
.then((res) => this.saveEventsData(res));
},
@@ -53,5 +62,5 @@ export default {
<style lang="sass" scoped>
.calendar-container
width: 100%
width: calc(100% - 80px)
</style>

View File

@@ -1,78 +1,82 @@
<template lang="pug">
.calendar-background-wrapper.flex.flex-col
.header.flex.items-center.justify-between.py-2.px-6
.body.flex.flex-col
.calendar-background-wrapper.flex.flex-col(
ref="backgroundWrapper"
)
calendar-column(
v-for="(owner, index) in columnInformation.owners"
:key="owner"
:column-information="owner"
:style="calculateColumnPosition(index)"
)
.header(:style="backgroundExtendedWidth")
.body.flex.flex-col(
:style="backgroundExtendedWidth"
)
.line-wrapper
.line.flex.items-center(
v-for="hour in hoursArray"
:key="hour"
)
.middle-line
.time-circle-indicator.-left-6px(
v-if="isShownIndicator"
:style="circleIndicatorLocation"
)
span.time-line-indicator.block(
v-if="isShownIndicator"
:style="lineIndicatorLocation"
)
</template>
<script>
import * as moment from "moment/moment";
import CalendarColumn from "./CalendarColumn.vue";
export default {
name: "CalendarBackground",
components: { CalendarColumn },
props: {
hoursArray: Array,
currentTime: String,
currentDate: Object,
dayStartTime: Number,
dayEndTime: Number,
columnInformation: Object,
},
data() {
return {
isShownIndicator: true,
backgroundWidth: 0,
columnWidth: 0,
defaultColumnWidth: 470,
pixelsPerHour: 62,
};
},
computed: {
lineIndicatorLocation() {
ownersArrayLength() {
return this.columnInformation.owners.length;
},
backgroundExtendedWidth() {
if (this.ownersArrayLength > 3) {
return {
width: `${this.defaultColumnWidth * this.ownersArrayLength}px`,
};
}
return {
top: `${this.calculateIndicatorLocation()}px`,
width: "auto",
};
},
circleIndicatorLocation() {
return {
top: `${this.calculateIndicatorLocation() - 6}px`,
};
},
scheduleSize() {
return (this.dayEndTime - this.dayStartTime) * this.pixelsPerHour;
},
pixelsPerMinute() {
return this.pixelsPerHour / 60;
backgroundHeight() {
return (this.hoursArray.length - 1) * this.pixelsPerHour + 48;
},
},
methods: {
calculateIndicatorLocation() {
let newTime = this.currentTime
.split(":")
.map((elem) => parseInt(elem, 10));
let result =
(newTime[0] - this.dayStartTime) * this.pixelsPerHour +
newTime[1] * this.pixelsPerMinute;
if (result > this.scheduleSize || result < 0) {
this.isShownIndicator = false;
return 0;
calculateColumnPosition(elemIndex) {
if (this.ownersArrayLength < 4) {
this.columnWidth = this.backgroundWidth / this.ownersArrayLength;
return {
width: `${this.columnWidth}px`,
height: `${this.backgroundHeight}px`,
left: `${elemIndex * this.columnWidth}px`,
};
}
return result;
return {
width: `${this.defaultColumnWidth}px`,
height: `${this.backgroundHeight}px`,
left: `${elemIndex * this.defaultColumnWidth}px`,
};
},
calculateBackgroundWidth() {
this.backgroundWidth = this.$refs.backgroundWrapper.offsetWidth;
},
},
watch: {
currentDate: function () {
this.isShownIndicator =
this.currentDate.format("DD.MM.YYYY") === moment().format("DD.MM.YYYY");
},
mounted() {
this.calculateBackgroundWidth();
},
};
</script>
@@ -80,6 +84,8 @@ export default {
<style lang="sass" scoped>
.calendar-background-wrapper
width: 100%
position: relative
overflow-x: scroll
.header
height: 48px
@@ -99,16 +105,4 @@ export default {
.middle-line
border-top: 1px dashed var(--border-light-grey-color)
width: 100%
.time-line-indicator
width: 100%
border-top: 1px solid var(--time-indicator-color)
position: absolute
.time-circle-indicator
width: 12px
height: 12px
background-color: var(--time-indicator-color)
border-radius: 50%
position: absolute
</style>

View File

@@ -1,6 +1,6 @@
<template lang="pug">
.calendar-clock-column.flex.flex-col.items-end.gap-y-43.pt-9.pb-12.px-3
span.font-medium.text-base(
span.text-base(
v-for="hour in hoursArray"
:key="hour"
:class="currentHourStyle(hour)"
@@ -42,6 +42,7 @@ export default {
}
return {
"current-time": false,
"font-medium": true,
};
},
convertTime(str, startIndex, endIndex) {

View File

@@ -0,0 +1,41 @@
<template lang="pug">
.calendar-column-wrapper.flex.flex-col
.header.flex.items-center.justify-between.py-2.px-6
.flex.items-center
img.avatar-wrapper.mr-2(src="@/assets/images/team-member.svg" alt="Team member")
span.owner-name.font-medium.text-base.mr-6 {{ columnInformation }}
img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg")
base-doc-ok-button
div
</template>
<script>
import BaseDocOkButton from "@/components/base/buttons/BaseDocOkButton.vue";
export default {
name: "CalendarColumn",
components: { BaseDocOkButton },
props: {
columnInformation: String,
},
};
</script>
<style lang="sass" scoped>
.calendar-column-wrapper
position: absolute
border-right: 1px solid var(--border-light-grey-color)
.header
height: 48px
.avatar-wrapper
width: 32px
height: 32px
.icon-wrapper
width: 24px
height: 24px
.owner-name
color: var(--font-dark-blue-color)
</style>

View File

@@ -8,18 +8,24 @@
@selected-layout="selectedLayout"
)
.schedule-body.flex
calendar-clock-column(
:hours-array="hoursArray"
:current-time="currentTime"
:is-current-date="isCurrentDate"
:day-end-time="validateEndTime"
)
div
calendar-clock-column(
:hours-array="hoursArray"
:current-time="currentTime"
:is-current-date="isCurrentDate"
:day-end-time="validateEndTime"
)
calendar-background(
:hours-array="hoursArray"
:current-time="currentTime"
:current-date="currentDate"
:day-start-time="validateStartTime"
:day-end-time="validateEndTime"
:column-information="columnInformation"
)
.time-circle-indicator.left-74px(
v-if="isShownIndicator"
:style="circleIndicatorLocation"
)
span.time-line-indicator.block.left-20(
v-if="isShownIndicator"
:style="lineIndicatorLocation"
)
</template>
@@ -30,7 +36,11 @@ import CalendarBackground from "./CalendarBackground.vue";
import CalendarClockColumn from "./CalendarClockColumn.vue";
export default {
name: "CalendarSchedule",
components: { CalendarHeader, CalendarBackground, CalendarClockColumn },
components: {
CalendarHeader,
CalendarBackground,
CalendarClockColumn,
},
props: {
currentDate: {
type: Object,
@@ -44,6 +54,12 @@ export default {
return {};
},
},
columnInformation: {
type: Object,
default() {
return {};
},
},
},
data() {
return {
@@ -51,6 +67,9 @@ export default {
hoursArray: [],
timer: null,
isCurrentDate: true,
isShownIndicator: true,
pixelsPerHour: 62,
columnHeaderHeight: 48,
};
},
computed: {
@@ -69,6 +88,25 @@ export default {
validateEndTime() {
return this.verifyTime(this.timeInformation.dayEndTime);
},
lineIndicatorLocation() {
return {
top: `${this.calculateIndicatorLocation()}px`,
};
},
circleIndicatorLocation() {
return {
top: `${this.calculateIndicatorLocation() - 6}px`,
};
},
pixelsPerMinute() {
return this.pixelsPerHour / 60;
},
scheduleSize() {
return (
(this.validateEndTime - this.validateStartTime) * this.pixelsPerHour +
this.columnHeaderHeight
);
},
},
methods: {
previousDate() {
@@ -126,6 +164,20 @@ export default {
convertTime(str, startIndex, endIndex) {
return parseInt(str.slice(startIndex, endIndex), 10);
},
calculateIndicatorLocation() {
let newTime = this.currentTime
.split(":")
.map((elem) => parseInt(elem, 10));
let result =
(newTime[0] - this.validateStartTime) * this.pixelsPerHour +
newTime[1] * this.pixelsPerMinute +
this.columnHeaderHeight;
if (result > this.scheduleSize || result < 0) {
this.isShownIndicator = false;
return 0;
}
return result;
},
},
watch: {
currentTime() {
@@ -141,6 +193,7 @@ export default {
currentDate: function () {
this.isCurrentDate =
this.currentDate.format("DD.MM.YYYY") === moment().format("DD.MM.YYYY");
this.isShownIndicator = this.isCurrentDate;
if (this.timer) {
this.stopTimer();
this.hoursArrayInitialization();
@@ -166,4 +219,20 @@ export default {
<style lang="sass" scoped>
.schedule
background-color: var(--default-white)
width: calc(100% - 8px)
.time-line-indicator
width: calc(100% - 80px)
border-top: 1px solid var(--time-indicator-color)
position: absolute
.time-circle-indicator
width: 12px
height: 12px
background-color: var(--time-indicator-color)
border-radius: 50%
position: absolute
.schedule-body
position: relative
</style>

View File

@@ -27,6 +27,7 @@ module.exports = {
"6px": "6px",
"10px": "10px",
"3px": "3px",
"74px": "74px",
},
},
},