diff --git a/public/css/components/calendar.css b/public/css/components/calendar.css index 67ee558fb..4f10a5eaf 100644 --- a/public/css/components/calendar.css +++ b/public/css/components/calendar.css @@ -185,8 +185,25 @@ aspect-ratio: 1; } + + +.fhc-calendar-past { + background-color:#F5E9D7; + border-color: #E8E8E8; + opacity: 0.5; +} + .fhc-calendar-month-page-day-highlight { - background-color: #f5f5f5; + /*background-color: #f5f5f5;*/ + /*background-color: red;*/ + } +.fhc-highlight-week { + /*border-color: black !important;*/ +} + +.fhc-highlight-day { + border-width: 2px !important; + border-color: black !important; } .fhc-calendar-sm .fhc-calendar-month-page-day.active .no, diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index 4690c067d..17b59c235 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -78,6 +78,11 @@ const app = Vue.createApp({ appSideMenuEntries: {} }), components: {}, + computed: { + isMobile() { + return /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); + } + }, methods: { isInternalRoute(href) { const internalBase = window.location.origin @@ -97,6 +102,11 @@ const app = Vue.createApp({ if(!res?.matched?.length) return event.preventDefault(); // Prevent browser navigation + + if(this.isMobile) { // toggle the menu + document.getElementById('nav-main-btn').click(); + } + this.$router.push(route); } } diff --git a/public/js/components/Calendar/Calendar.js b/public/js/components/Calendar/Calendar.js index 6c0aecdf8..fb947a585 100644 --- a/public/js/components/Calendar/Calendar.js +++ b/public/js/components/Calendar/Calendar.js @@ -8,7 +8,9 @@ import CalendarMinimized from './Minimized.js'; import CalendarDate from '../../composables/CalendarDate.js'; import CalendarDates from '../../composables/CalendarDates.js'; -// TODO(chris): week/month toggle + +const todayDate = new Date(new Date().setHours(0, 0, 0, 0)); +const today = todayDate.getTime() export default { components: { @@ -22,6 +24,8 @@ export default { }, provide() { return { + today, + todayDate, date: this.date, focusDate: this.focusDate, size: Vue.computed({ get: () => this.size, set: v => this.size = v }), diff --git a/public/js/components/Calendar/Day/Page.js b/public/js/components/Calendar/Day/Page.js index f545c61ae..0c2e3212e 100644 --- a/public/js/components/Calendar/Day/Page.js +++ b/public/js/components/Calendar/Day/Page.js @@ -17,11 +17,14 @@ export default { data() { return { hourPosition: null, + curHourPosition: null, hourPositionTime: null, lvMenu: null, } }, inject: [ + 'today', + 'todayDate', 'date', 'focusDate', 'size', @@ -107,12 +110,6 @@ export default { datum: this.day.toLocaleString(this.$p.user_locale.value, [{ day: 'numeric', month: 'numeric' }, { day: 'numeric', month: 'numeric' }, { day: 'numeric', month: 'numeric' }, { dateStyle: 'short' }][this.size]), } }, - dayGridStyle() { - return { - 'grid-template-columns': '1 1fr', - 'grid-template-rows': 'repeat(' + (this.hours.length * 60 / this.smallestTimeFrame) + ', 1fr)', - } - }, noLvStyle() { return { top: (this.calendarScrollTop + 100) + 'px', @@ -135,6 +132,22 @@ export default { right: 0, } }, + curTime() { + const now = new Date(); + return String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0'); + }, + curIndicatorStyle() { + return { + 'pointer-events': 'none', + 'padding-left': '7rem', + 'margin-top': '-1px', + 'z-index': 2, + 'border-color': '#00649C!important', + top: this.getDayTimePercent + '%', + left: 0, + right: 0, + } + }, noEventsCondition() { return !this.isSliding && this.filteredEvents?.length === 0; }, @@ -192,8 +205,32 @@ export default { smallestTimeFrame() { return [30, 15, 10, 5][this.size]; }, + lookingAtToday() { + return this.date.compare(this.todayDate) + }, + getDayTimePercent() { + const now = new Date(Date.now()) + const currentMinutes = now.getMinutes() + now.getHours() * 60 + let timePercentage = ((currentMinutes - (this.hours[0] * 60)) / (this.hours.length * 60)) * 100; + + return timePercentage + } }, methods: { + dayGridStyle(day) { + const styleObj = { + 'grid-template-columns': '1 1fr', + 'grid-template-rows': 'repeat(' + (this.hours.length * 60 / this.smallestTimeFrame) + ', 1fr)', + } + + if(this.date.compare(this.todayDate)) { + styleObj['backgroundImage'] = 'linear-gradient(to bottom, #F5E9D7 '+this.getDayTimePercent+'%, #FFFFFF '+this.getDayTimePercent+'%)' + styleObj['border-color'] = '#E8E8E8'; + // styleObj.opacity = 0.5; // would opaque the whole column + } + + return styleObj + }, fetchLvMenu(event) { if (event && event.type == 'lehreinheit') { this.$fhcApi.factory.stundenplan.getLehreinheitStudiensemester(event.lehreinheit_id[0]).then( @@ -270,6 +307,7 @@ export default { // calculate the minutes percentage of the total minutes timePercentage = ((currentMinutes - (this.hours[0] * 60)) / (this.hours.length * 60)) * 100; // calculate the relative position of the time percentage + console.log('height: ', height) position = height * (timePercentage / 100); this.hourPosition = position; @@ -290,13 +328,9 @@ export default { }, dateToMinutesOfDay(day) { return Math.floor(((day.getHours() - 7) * 60 + day.getMinutes()) / this.smallestTimeFrame) + 1; - }, + } }, - mounted() { - const container = document.getElementById("calendarContainer") - if(container) container.style.overflow = 'hidden' - }, template: /*html*/`
this is a placeholder which means that no template was passed to the Calendar Page slot
this is a placeholder which means that no template was passed to the Calendar Page slot