Adding ability to hide deleted events
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2021-10-02 12:13:18 +02:00
parent 59682c3091
commit 6b55c438f6
10 changed files with 50 additions and 7 deletions

View File

@ -15,8 +15,6 @@ import {EventDetailComponent} from './components/event-detail/event-detail.compo
import {HttpClientModule} from '@angular/common/http'; import {HttpClientModule} from '@angular/common/http';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {ApiService} from './services/api/api.service'; import {ApiService} from './services/api/api.service';
import {MatDialogModule} from '@angular/material/dialog';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({ @NgModule({
declarations: [ declarations: [

View File

@ -3,7 +3,7 @@
} }
.switchWeekButton { .switchWeekButton {
background-color: dimgrey; /* Green */ background-color: dimgrey;
border: none; border: none;
color: #E0E5E9; color: #E0E5E9;
padding: .15em .5em; padding: .15em .5em;
@ -13,6 +13,24 @@
margin: .5em; margin: .5em;
} }
.showDeletedBtn {
border: none;
color: #E0E5E9;
padding: .15em .5em;
text-align: center;
display: inline-block;
border-radius: .5em;
margin: .5em;
}
.show {
background-color: green;
}
.hide {
background-color: darkred;
}
.datePickerDropdown { .datePickerDropdown {
background-color: dimgrey; background-color: dimgrey;
border: none; border: none;

View File

@ -17,5 +17,6 @@
</option> </option>
</select> </select>
<button (click)="switchToToday()" class="switchWeekButton">Today</button> <button (click)="switchToToday()" class="switchWeekButton">Today</button>
<button (click)="switchShowDeletedEvents()" class="showDeletedBtn {{switchDeletedBtnClass}}">{{showingDeletedBtnText}}</button>
<button (click)="switchToNextWeek()" class="switchWeekButton">Next week &gt;&gt;</button> <button (click)="switchToNextWeek()" class="switchWeekButton">Next week &gt;&gt;</button>
</div> </div>

View File

@ -16,6 +16,11 @@ export class DatepickerComponent implements OnInit {
itIsWednesday: boolean = false; itIsWednesday: boolean = false;
internalShowDeletedEvents: boolean = true;
@Output() showDeletedEvents = new EventEmitter<boolean>();
switchDeletedBtnClass: string = 'show';
showingDeletedBtnText: string = 'Showing deleted events';
@Output() selectedMonday = new EventEmitter<string>(); @Output() selectedMonday = new EventEmitter<string>();
constructor() { constructor() {
@ -190,4 +195,18 @@ export class DatepickerComponent implements OnInit {
this.selectedDay = currentDate.getDate().toString().padStart(2, '0'); this.selectedDay = currentDate.getDate().toString().padStart(2, '0');
this.handleDateChange(); this.handleDateChange();
} }
switchShowDeletedEvents() {
if(this.internalShowDeletedEvents) {
this.internalShowDeletedEvents = false;
this.showDeletedEvents.emit(false);
this.switchDeletedBtnClass = 'hide';
this.showingDeletedBtnText = 'Deleted events hidden';
} else {
this.internalShowDeletedEvents = true;
this.showDeletedEvents.emit(true);
this.switchDeletedBtnClass = 'show';
this.showingDeletedBtnText = 'Showing deleted events';
}
}
} }

View File

@ -1,4 +1,4 @@
<h1>{{weekDayName}}</h1> <h1>{{weekDayName}}</h1>
<div *ngFor="let event of events"> <div *ngFor="let event of events">
<app-event [event]="event"></app-event> <app-event [event]="event" *ngIf="!(!showDeletedEvents && event.changes[event.changes.length-1].is_deleted)"></app-event>
</div> </div>

View File

@ -9,6 +9,7 @@ import {Event} from '../../models/event';
export class DayComponent implements OnInit { export class DayComponent implements OnInit {
@Input() events: Event[] = []; @Input() events: Event[] = [];
@Input() dayOfWeek: number = 0; @Input() dayOfWeek: number = 0;
@Input() showDeletedEvents: boolean = true;
weekDayName: string = ''; weekDayName: string = '';

View File

@ -1,5 +1,5 @@
<div id="week" class="container-fluid"> <div id="week" class="container-fluid">
<div class="row"> <div class="row">
<app-day *ngFor="let day of eventsPerDay" [events]="day" [dayOfWeek]="eventsPerDay.indexOf(day)" class="col"></app-day> <app-day *ngFor="let day of eventsPerDay" [events]="day" [dayOfWeek]="eventsPerDay.indexOf(day)" [showDeletedEvents]="showDeletedEvents" class="col"></app-day>
</div> </div>
</div> </div>

View File

@ -8,6 +8,7 @@ import {Event} from '../../models/event';
}) })
export class WeekComponent implements OnInit { export class WeekComponent implements OnInit {
@Input() events: Event[] = []; @Input() events: Event[] = [];
@Input() showDeletedEvents: boolean = true;
eventsPerDay: Event[][] = []; eventsPerDay: Event[][] = [];
constructor() { constructor() {

View File

@ -1,9 +1,9 @@
<header> <header>
<p>TINF19B4 RaPla Changes</p> <p>TINF19B4 RaPla Changes</p>
<app-datepicker (selectedMonday)="dateChangedFromPicker($event)"></app-datepicker> <app-datepicker (selectedMonday)="dateChangedFromPicker($event)" (showDeletedEvents)="showDeletedChangedFromPicker($event)"></app-datepicker>
</header> </header>
<div id="content"> <div id="content">
<app-week [events]="events"></app-week> <app-week [events]="events" [showDeletedEvents]="showDeletedEvents"></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

View File

@ -12,6 +12,7 @@ export class LandingpageComponent implements OnInit {
eventCount: number = 0; eventCount: number = 0;
selectedDate: string = ''; selectedDate: string = '';
showDeletedEvents: boolean = true;
constructor( constructor(
private apiService: ApiService private apiService: ApiService
@ -32,4 +33,8 @@ export class LandingpageComponent implements OnInit {
this.selectedDate = newDate; this.selectedDate = newDate;
this.getEvents(); this.getEvents();
} }
showDeletedChangedFromPicker(newShowDeleted: boolean) {
this.showDeletedEvents = newShowDeleted;
}
} }