From fd27e3ff396f70f86892ea7147338495bedb9e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Thu, 30 Sep 2021 15:24:49 +0200 Subject: [PATCH] Adding week and day components - POC release --- .../src/app/components/day/day.component.html | 7 +++- .../src/app/components/day/day.component.ts | 4 ++- .../app/components/week/week.component.html | 4 ++- .../src/app/components/week/week.component.ts | 34 ++++++++++++++++++- .../landingpage/landingpage.component.html | 2 +- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/Frontend/src/app/components/day/day.component.html b/Frontend/src/app/components/day/day.component.html index f03a62e..3379ed0 100644 --- a/Frontend/src/app/components/day/day.component.html +++ b/Frontend/src/app/components/day/day.component.html @@ -1 +1,6 @@ -

day works!

+

Day

+

+ Titel: {{event.latest_event_summary}} + Start: {{event.latest_start_date}} + Gelöscht: {{event.changes[event.changes.length-1].is_deleted}} +

diff --git a/Frontend/src/app/components/day/day.component.ts b/Frontend/src/app/components/day/day.component.ts index dcf282e..1afc366 100644 --- a/Frontend/src/app/components/day/day.component.ts +++ b/Frontend/src/app/components/day/day.component.ts @@ -1,4 +1,5 @@ -import {Component, OnInit} from '@angular/core'; +import {Component, Input, OnInit} from '@angular/core'; +import {Event} from '../../models/event'; @Component({ selector: 'app-day', @@ -6,6 +7,7 @@ import {Component, OnInit} from '@angular/core'; styleUrls: ['./day.component.css'] }) export class DayComponent implements OnInit { + @Input() events: Event[]= []; constructor() { } diff --git a/Frontend/src/app/components/week/week.component.html b/Frontend/src/app/components/week/week.component.html index 80639e8..586ec83 100644 --- a/Frontend/src/app/components/week/week.component.html +++ b/Frontend/src/app/components/week/week.component.html @@ -1 +1,3 @@ -

week works!

+
+ +
diff --git a/Frontend/src/app/components/week/week.component.ts b/Frontend/src/app/components/week/week.component.ts index 3c0cebd..012bb26 100644 --- a/Frontend/src/app/components/week/week.component.ts +++ b/Frontend/src/app/components/week/week.component.ts @@ -1,4 +1,5 @@ -import {Component, OnInit} from '@angular/core'; +import {Component, Input, OnInit, SimpleChanges} from '@angular/core'; +import {Event} from '../../models/event'; @Component({ selector: 'app-week', @@ -6,11 +7,42 @@ import {Component, OnInit} from '@angular/core'; styleUrls: ['./week.component.css'] }) export class WeekComponent implements OnInit { + @Input() events: Event[] = []; + eventsPerDay: Event[][] = []; constructor() { } ngOnInit(): void { + this.splitEventsIntoDays(); + } + + ngOnChanges(changes: SimpleChanges): void { + this.splitEventsIntoDays(); + } + + splitEventsIntoDays() { + // Pre-fill list with 7 empty days + this.eventsPerDay = []; + for(let day = 0; day < 7; day++) { + this.eventsPerDay.push([]); + } + + this.events.forEach((event) => { + let startDate = new Date(event.latest_start_date); + let year = startDate.getFullYear().toString(); + let month = startDate.getMonth().toString().padStart(2, '0'); + let day = startDate.getDate().toString().padStart(2, '0'); + let dayIndex = startDate.getDay(); + // Because these start with fucking sunday + if(dayIndex === 0) { + dayIndex = 6; + } else { + dayIndex--; + } + + this.eventsPerDay[dayIndex].push(event); + }); } } diff --git a/Frontend/src/app/pages/landingpage/landingpage.component.html b/Frontend/src/app/pages/landingpage/landingpage.component.html index baac77d..547ce29 100644 --- a/Frontend/src/app/pages/landingpage/landingpage.component.html +++ b/Frontend/src/app/pages/landingpage/landingpage.component.html @@ -3,7 +3,7 @@
- Events: {{eventCount}} +