From b0cd599999933c430c18c64be36747f3b0df8608 Mon Sep 17 00:00:00 2001 From: Johann Hoffmann Date: Wed, 13 Nov 2024 10:41:50 +0100 Subject: [PATCH] WIP stundenplan widget tagesansicht --- application/config/routes.php | 4 +- public/js/apps/Cis/Stundenplan.js | 5 ++ .../components/DashboardWidget/Stundenplan.js | 70 ++++++++++++++----- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/application/config/routes.php b/application/config/routes.php index bb3337b23..b07497ae7 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -62,6 +62,7 @@ $route['api/v1/ressource/[B|b]etriebsmittelperson/(:any)'] = 'api/v1/ressource/b $route['api/v1/system/[S|s]prache/(:any)'] = 'api/v1/system/sprache2/$1'; $route['CisVue'] = 'CisVue/dashboard'; +$route['Cis/Stundenplan/(:any)'] = 'Cis/Stundenplan'; // load routes from extensions $subdir = 'application/config/extensions'; @@ -83,5 +84,4 @@ if ($dirlist) } } } -} - +} \ No newline at end of file diff --git a/public/js/apps/Cis/Stundenplan.js b/public/js/apps/Cis/Stundenplan.js index cb019952c..2bc3c7d00 100644 --- a/public/js/apps/Cis/Stundenplan.js +++ b/public/js/apps/Cis/Stundenplan.js @@ -8,6 +8,7 @@ const app = Vue.createApp({ data() { return { stunden: [], + lv_id: null, events: null, calendarDate: new CalendarDate(new Date()), currentlySelectedEvent: null, @@ -34,6 +35,9 @@ const app = Vue.createApp({ }, }, methods:{ + getLvID: function () { + this.lv_id = window.location.pathname + }, selectDay: function(day){ this.currentDay = day; }, @@ -99,6 +103,7 @@ const app = Vue.createApp({ }, }, created(){ + this.getLvID() this.loadEvents(); }, //TODO: Stundenplan phrase diff --git a/public/js/components/DashboardWidget/Stundenplan.js b/public/js/components/DashboardWidget/Stundenplan.js index 0afdc3845..f8ab1e51d 100644 --- a/public/js/components/DashboardWidget/Stundenplan.js +++ b/public/js/components/DashboardWidget/Stundenplan.js @@ -21,7 +21,7 @@ export default { stunden: [], minimized: true, events: null, - currentDay: new Date(), + currentDay: this.getCurrentDate(), calendarDate: new CalendarDate(new Date()), roomInfoContentID: null, ort_kurzbz: null, @@ -29,23 +29,51 @@ export default { } }, computed: { - + nextEventsGrouped() { + // groups all events of all days until end of week together + return new Map((this.events || []).filter(evt => evt.end < this.endOfWeek && evt.start >= this.currentDay).reduce((acc, cur) => { + const date = new CalendarDate(new Date(cur.datum)) + const arr = acc.find(el => el[0].compare(date)) + if(arr) { + arr[1].push(cur) + } else { + acc.push([date, [cur]]) + } + return acc + }, [])) + }, currentEvents() { - return (this.events || []).filter(evt => evt.end < this.dayAfterCurrentDay && evt.start >= this.currentDay); + return (this.events || []).filter(evt => evt.end < this.dayAfterCurrentDay && evt.start >= this.currentDay)//.sort((e1, e2) => e1.beginn > e2.beginn); }, dayAfterCurrentDay() { let currentDay = new Date(this.currentDay); currentDay.setDate(currentDay.getDate() + 1); return currentDay; }, + endOfWeek() { + let endOfWeek = new Date(this.currentDay); // + endOfWeek.setDate(this.currentDay.getDate() + (7 - this.currentDay.getDay())); + endOfWeek.setHours(23, 59, 59, 999); + return endOfWeek; + }, monthFirstDay: function () { return this.calendarDateToString(this.calendarDate.cdFirstDayOfCalendarMonth); }, monthLastDay: function () { return this.calendarDateToString(this.calendarDate.cdLastDayOfCalendarMonth); - }, + } }, methods: { + getEventStyle: function(evt) { + const styles = {'background-color': evt.color}; + if(evt.start.getTime() < Date.now()) styles.opacity = 0.5; + return styles; + }, + getCurrentDate: function() { + const today = new Date() + today.setHours(0,0,0) + return today + }, calendarDateToString: function (calendarDate) { return calendarDate instanceof CalendarDate ? @@ -127,6 +155,10 @@ export default { this.events = promise_events; }); }, + + setCalendarMaximized() { + this.minimized = false + } }, @@ -160,23 +192,29 @@ export default {
- +
-
-
- {{evt.topic}} -
- - - {{evt.ort_kurzbz}} - {{evt.start.toLocaleTimeString(undefined, {hour:'numeric',minute:'numeric'})}}-{{evt.end.toLocaleTimeString(undefined, {hour:'numeric',minute:'numeric'})}} - -
+
+
-
+ +
{{ p.t('lehre/noLvFound') }}