Adding week and day components - POC release
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2021-09-30 15:24:49 +02:00
parent e97cafd1ac
commit fd27e3ff39
5 changed files with 46 additions and 5 deletions

View File

@ -1 +1,6 @@
<p>day works!</p> <h1>Day</h1>
<p *ngFor="let event of events">
Titel: {{event.latest_event_summary}}
Start: {{event.latest_start_date}}
Gelöscht: {{event.changes[event.changes.length-1].is_deleted}}
</p>

View File

@ -1,4 +1,5 @@
import {Component, OnInit} from '@angular/core'; import {Component, Input, OnInit} from '@angular/core';
import {Event} from '../../models/event';
@Component({ @Component({
selector: 'app-day', selector: 'app-day',
@ -6,6 +7,7 @@ import {Component, OnInit} from '@angular/core';
styleUrls: ['./day.component.css'] styleUrls: ['./day.component.css']
}) })
export class DayComponent implements OnInit { export class DayComponent implements OnInit {
@Input() events: Event[]= [];
constructor() { constructor() {
} }

View File

@ -1 +1,3 @@
<p>week works!</p> <div id="week">
<app-day *ngFor="let day of eventsPerDay" [events]="day"></app-day>
</div>

View File

@ -1,4 +1,5 @@
import {Component, OnInit} from '@angular/core'; import {Component, Input, OnInit, SimpleChanges} from '@angular/core';
import {Event} from '../../models/event';
@Component({ @Component({
selector: 'app-week', selector: 'app-week',
@ -6,11 +7,42 @@ import {Component, OnInit} from '@angular/core';
styleUrls: ['./week.component.css'] styleUrls: ['./week.component.css']
}) })
export class WeekComponent implements OnInit { export class WeekComponent implements OnInit {
@Input() events: Event[] = [];
eventsPerDay: Event[][] = [];
constructor() { constructor() {
} }
ngOnInit(): void { 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);
});
} }
} }

View File

@ -3,7 +3,7 @@
<app-datepicker (selectedMonday)="dateChangedFromPicker($event)"></app-datepicker> <app-datepicker (selectedMonday)="dateChangedFromPicker($event)"></app-datepicker>
</header> </header>
<div id="content"> <div id="content">
Events: {{eventCount}} <app-week [events]="events"></app-week>
</div> </div>
<footer class="fixed-bottom start-50 translate-middle"> <footer class="fixed-bottom start-50 translate-middle">
Copyright &#169; 2021 - Patrick Müller Copyright &#169; 2021 - Patrick Müller