Enable UI to work with event status

This commit is contained in:
Patrick Müller 2023-05-15 21:00:28 +02:00
parent 39ffa5e52c
commit 0962a36b59
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE
5 changed files with 30 additions and 6 deletions

View File

@ -28,6 +28,12 @@
<td class="{{invalidUrlError? 'has-error' : ''}}">
<input type="text" [(ngModel)]="event!.url">
</td>
<td>
<select [(ngModel)]="event!.status">
<option value="DRAFT">Draft</option>
<option value="PUBLIC">Published</option>
</select>
</td>
<td>
<button (click)="toggleEdit()">Save</button>
<p class="has-error" *ngIf="showDateError">Start Date must not be after end date!</p>
@ -69,6 +75,9 @@
<td>
{{event?.url}}
</td>
<td>
{{getEventStatusFriendlyName()}}
</td>
<td>
<button (click)="toggleEdit()">Edit</button>
</td>

View File

@ -175,4 +175,15 @@ export class EventComponent implements OnInit {
return validUrl;
}
getEventStatusFriendlyName(): string {
switch (this.event!.status) {
case 'DRAFT':
return 'Draft';
case 'PUBLIC':
return 'Published';
default:
return 'Error';
}
}
}

View File

@ -9,6 +9,7 @@
<th>Location</th>
<th>Created by</th>
<th>URL</th>
<th>Status</th>
<th>Edit</th>
<th>Delete</th>
</tr>

View File

@ -11,4 +11,5 @@ export interface Event {
createdBy: string;
url: string;
wholeDay: boolean;
status: string;
}

View File

@ -52,12 +52,14 @@ export class AdminComponent implements OnInit {
this.api.getEvents(this.selectedCalendar).subscribe((events: Event[]): void => {
for (let event of events) {
this.events.push({
...event,
startDateTime: new Date(event.startDateTime),
endDateTime: new Date(event.endDateTime),
createdDate: new Date(event.createdDate)
});
if(event.status !== 'DELETED') {
this.events.push({
...event,
startDateTime: new Date(event.startDateTime),
endDateTime: new Date(event.endDateTime),
createdDate: new Date(event.createdDate)
});
}
}
this.filterEvents();
this.sortEvents();