From e13468c7c4f9784131c5f7f7550732325b3480c2 Mon Sep 17 00:00:00 2001 From: Thomas Lenz <Thomas.Lenz@mni.thm.de> Date: Sat, 10 Mar 2018 18:18:42 +0100 Subject: [PATCH] Add deletion confirmation --- .../creator-room/creator-room.component.html | 19 ++++++++++++++++--- .../creator-room/creator-room.component.ts | 9 +++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/app/creator-room/creator-room.component.html b/src/app/creator-room/creator-room.component.html index e3e90773a..e62eea4bd 100644 --- a/src/app/creator-room/creator-room.component.html +++ b/src/app/creator-room/creator-room.component.html @@ -1,7 +1,7 @@ <div fxLayout="column" fxLayoutAlign="start" fxLayoutGap="20px" fxFill> <div fxLayout="row" fxLayoutAlign="center"> <mat-progress-spinner *ngIf="isLoading" mode="indeterminate"></mat-progress-spinner> - <mat-card *ngIf="room"> + <mat-card *ngIf="room && !deleteDialog"> <mat-card-header> <mat-card-title><h3 class="subheading-2">{{ room.name }}</h3></mat-card-title> <mat-card-subtitle>{{ room.id }}</mat-card-subtitle> @@ -20,10 +20,11 @@ <button mat-button color="primary" matTooltip="See contents"> Contents </button> - <button mat-button color="primary" matTooltip="See room comments" routerLink="/creator/room/{{room.id}}/comments"> + <button mat-button color="primary" matTooltip="See room comments" + routerLink="/creator/room/{{room.id}}/comments"> Comments </button> - <button mat-button color="warn" matTooltip="Delete selected room" (click)="delete(room)"> + <button mat-button color="warn" matTooltip="Enables deletion dialog" (click)="enableDeletion()"> Delete room </button> <button mat-button color="primary" matTooltip="Go back to last page" (click)="goBack()"> @@ -31,6 +32,18 @@ </button> </mat-card-actions> </mat-card> + <mat-card *ngIf="deleteDialog"> + <mat-card-header><h3>Do you really want to delete this room?<br>This action can not be undone.</h3> + </mat-card-header> + <mat-card-content> + <button mat-raised-button color="warn" matTooltip="Delete selected room" (click)="delete(room)"> + Delete room + </button> + <button mat-raised-button color="primary" matTooltip="Leave delete dialog" (click)="disableDeletion()"> + Leave + </button> + </mat-card-content> + </mat-card> <div *ngIf="!isLoading && !room">Error: room could not be found!</div> </div> </div> diff --git a/src/app/creator-room/creator-room.component.ts b/src/app/creator-room/creator-room.component.ts index b0bd7a177..6ee69f133 100644 --- a/src/app/creator-room/creator-room.component.ts +++ b/src/app/creator-room/creator-room.component.ts @@ -12,6 +12,7 @@ import { Location } from '@angular/common'; }) export class CreatorRoomComponent extends RoomComponent implements OnInit { room: Room; + deleteDialog = false; constructor(protected roomService: RoomService, protected route: ActivatedRoute, @@ -29,4 +30,12 @@ export class CreatorRoomComponent extends RoomComponent implements OnInit { this.location.back(); } + enableDeletion(): void { + this.deleteDialog = true; + } + + disableDeletion(): void { + this.deleteDialog = false; + } + } -- GitLab