From 36c129fcaf8173de4cf65b2d514c3f3da82efa7e Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 25 Nov 2024 11:41:22 +0100 Subject: [PATCH] reafactor(Calendar/Day/Page.js-Calendar/Week/Page.js): refactors styles of elements for easier readability --- public/js/components/Calendar/Day/Page.js | 34 +++++++----- public/js/components/Calendar/Week/Page.js | 61 ++++++++++++++++++++-- 2 files changed, 78 insertions(+), 17 deletions(-) diff --git a/public/js/components/Calendar/Day/Page.js b/public/js/components/Calendar/Day/Page.js index c8fb9aae7..6477c41ad 100644 --- a/public/js/components/Calendar/Day/Page.js +++ b/public/js/components/Calendar/Day/Page.js @@ -82,6 +82,15 @@ export default { } }, computed: { + pageHeaderStyle(){ + return { + 'z-index': 4, + 'grid-template-columns': 'repeat(' + this.day.length + ', 1fr)', + 'grid-template-rows': 1, + position: 'sticky', + top: 0, + } + }, dayGridStyle(){ return { 'grid-template-columns': '1 1fr', @@ -191,6 +200,17 @@ export default { 'z-index': 0, } }, + eventGridStyle(day, event) { + return { + 'z-index': 1, + 'grid-column-start': 1 + (event.lane - 1) * day.lanes / event.maxLane, + 'grid-column-end': 1 + event.lane * day.lanes / event.maxLane, + 'grid-row-start': this.dateToMinutesOfDay(event.start), + 'grid-row-end': this.dateToMinutesOfDay(event.end), + 'background-color': event.orig.color, + '--test': this.dateToMinutesOfDay(event.end), + } + }, showModal: function (evt) { let event = evt.orig; this.setSelectedEvent(event); @@ -258,17 +278,7 @@ export default { dateToMinutesOfDay(day) { return Math.floor(((day.getHours() - 7) * 60 + day.getMinutes()) / this.smallestTimeFrame) + 1; }, - eventGridStyle(day,event){ - return { - 'z-index': 1, - 'grid-column-start': 1 + (event.lane - 1) * day.lanes / event.maxLane, - 'grid-column-end': 1 + event.lane * day.lanes / event.maxLane, - 'grid-row-start': this.dateToMinutesOfDay(event.start), - 'grid-row-end': this.dateToMinutesOfDay(event.end), - 'background-color': event.orig.color, - '--test': this.dateToMinutesOfDay(event.end), - } - } + }, template: /*html*/`
@@ -277,7 +287,7 @@ export default {
-
+
{{day.toLocaleString(undefined, {weekday: size < 2 ? 'narrow' : (size < 3 ? 'short' : 'long')})}}
{{day.toLocaleString(undefined, [{day:'numeric',month:'numeric'},{day:'numeric',month:'numeric'},{day:'numeric',month:'numeric'},{dateStyle:'short'}][this.size])}} diff --git a/public/js/components/Calendar/Week/Page.js b/public/js/components/Calendar/Week/Page.js index 2288984f2..222e4b4e7 100644 --- a/public/js/components/Calendar/Week/Page.js +++ b/public/js/components/Calendar/Week/Page.js @@ -31,6 +31,27 @@ export default { 'input', ], computed: { + pageHeaderStyle(){ + return { + 'z-index': 4, + 'grid-template-columns': 'repeat(' + this.days.length + ', 1fr)', + 'grid-template-rows': 1, + position: 'sticky', + top: 0, + } + }, + indicatorStyle() { + return { + 'pointer-events': 'none', + 'padding-left': '3.5rem', + 'margin-top': '-1px', + 'z-index': 2, + 'border-color': '#00649C!important', + top: this.hourPosition + 'px', + left: 0, + right: 0, + } + }, hours(){ // returns an array with elements starting at 7 and ending at 24 return [...Array(24).keys()].filter(hour => hour >= 7 && hour <= 24); @@ -88,6 +109,36 @@ export default { } }, methods: { + hourGridIdentifier(hour) { + // this is the id attribute that is responsible to scroll the calender to the first event + return 'scroll' + hour + this.focusDate.d + this.week; + }, + hourGridStyle(hour) { + return { + 'pointer-events': 'none', + top: this.getAbsolutePositionForHour(hour), + left: 0, + right: 0, + 'z-index': 0, + } + }, + dayGridStyle(day) { + return { + 'grid-template-columns': 'repeat(' + day.lanes + ', 1fr)', + 'grid-template-rows': 'repeat(' + (this.hours.length * 60 / this.smallestTimeFrame) + ', 1fr)', + } + }, + eventGridStyle(day, event) { + return { + 'z-index': 1, + 'grid-column-start': 1 + (event.lane - 1) * day.lanes / event.maxLane, + 'grid-column-end': 1 + event.lane * day.lanes / event.maxLane, + 'grid-row-start': this.dateToMinutesOfDay(event.start), + 'grid-row-end': this.dateToMinutesOfDay(event.end), + 'background-color': event.orig.color, + '--test': this.dateToMinutesOfDay(event.end), + } + }, calcHourPosition(event) { let height = this.$refs.eventcontainer.getBoundingClientRect().height; let top = this.$refs.eventcontainer.getBoundingClientRect().top; @@ -155,23 +206,23 @@ export default {
-
+
-
-
+
+
{{hourPositionTime}}
{{hour}}:00
-
-
+
+

this is a placeholder which means that no template was passed to the Calendar Page slot