From 8ce5c9b4d84b632b658d2be119326134e9275ddf Mon Sep 17 00:00:00 2001
From: Emine Erbay <emine.erbay@mni.thm.de>
Date: Wed, 18 Sep 2019 21:06:27 +0200
Subject: [PATCH] Resolve "Add bilingual live announcer to the delete
 components"

---
 .../delete-comment.component.ts               | 21 ++++++++++++++++++-
 .../delete-comments.component.ts              | 15 +++++++++++--
 .../moderator-delete.component.ts             | 15 +++++++++++--
 .../room-delete/room-delete.component.ts      | 16 ++++++++++++--
 4 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/src/app/components/creator/_dialogs/delete-comment/delete-comment.component.ts b/src/app/components/creator/_dialogs/delete-comment/delete-comment.component.ts
index 87f87f6d0..a32d7196e 100644
--- a/src/app/components/creator/_dialogs/delete-comment/delete-comment.component.ts
+++ b/src/app/components/creator/_dialogs/delete-comment/delete-comment.component.ts
@@ -2,6 +2,8 @@ import { Component, Inject, OnInit } from '@angular/core';
 import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
 import { RoomEditComponent } from '../room-edit/room-edit.component';
 import { DialogConfirmActionButtonType } from '../../../shared/dialog/dialog-action-buttons/dialog-action-buttons.component';
+import { LiveAnnouncer } from '@angular/cdk/a11y';
+import { TranslateService } from '@ngx-translate/core';
 
 @Component({
   selector: 'app-delete-comment',
@@ -17,15 +19,32 @@ export class DeleteCommentComponent implements OnInit {
 
 
   constructor(public dialogRef: MatDialogRef<RoomEditComponent>,
-              @Inject(MAT_DIALOG_DATA) public data: any) { }
+              @Inject(MAT_DIALOG_DATA) public data: any,
+              private liveAnnouncer: LiveAnnouncer,
+              private translationService: TranslateService ) { }
 
   ngOnInit() {
+    this.announce();
   }
 
   close(type: string): void {
     this.dialogRef.close(type);
   }
 
+  public announce() {
+    const lang: string = this.translationService.currentLang;
+
+    // current live announcer content must be cleared before next read
+    this.liveAnnouncer.clear();
+
+    if (lang === 'de') {
+      this.liveAnnouncer.announce('Willst du diese Frage wirklich löschen?');
+    } else {
+      this.liveAnnouncer.announce('Do you really want to delete this question');
+    }
+  }
+
+
 
   /**
    * Returns a lambda which closes the dialog on call.
diff --git a/src/app/components/creator/_dialogs/delete-comments/delete-comments.component.ts b/src/app/components/creator/_dialogs/delete-comments/delete-comments.component.ts
index 5f743019e..67addcacc 100644
--- a/src/app/components/creator/_dialogs/delete-comments/delete-comments.component.ts
+++ b/src/app/components/creator/_dialogs/delete-comments/delete-comments.component.ts
@@ -3,6 +3,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
 import { RoomEditComponent } from '../room-edit/room-edit.component';
 import { LiveAnnouncer } from '@angular/cdk/a11y';
 import { DialogConfirmActionButtonType } from '../../../shared/dialog/dialog-action-buttons/dialog-action-buttons.component';
+import { TranslateService } from '@ngx-translate/core';
 
 @Component({
   selector: 'app-delete-comment',
@@ -19,7 +20,8 @@ export class DeleteCommentsComponent implements OnInit {
 
   constructor(public dialogRef: MatDialogRef<RoomEditComponent>,
               @Inject(MAT_DIALOG_DATA) public data: any,
-              private liveAnnouncer: LiveAnnouncer)  { }
+              private liveAnnouncer: LiveAnnouncer,
+              private translationService: TranslateService )  { }
 
 
   ngOnInit() {
@@ -28,7 +30,16 @@ export class DeleteCommentsComponent implements OnInit {
 
 
   public announce() {
-    this.liveAnnouncer.announce('Willst du wirklich alle Fragen dieser Sitzung löschen?', 'assertive');
+    const lang: string = this.translationService.currentLang;
+
+    // current live announcer content must be cleared before next read
+    this.liveAnnouncer.clear();
+
+    if (lang === 'de') {
+      this.liveAnnouncer.announce('Willst du wirklich alle Fragen dieser Sitzung löschen?');
+    } else {
+      this.liveAnnouncer.announce('Do you really want to delete all questions of this session?');
+    }
   }
 
 
diff --git a/src/app/components/creator/_dialogs/moderator-delete/moderator-delete.component.ts b/src/app/components/creator/_dialogs/moderator-delete/moderator-delete.component.ts
index a8838b3c9..3cf33799a 100644
--- a/src/app/components/creator/_dialogs/moderator-delete/moderator-delete.component.ts
+++ b/src/app/components/creator/_dialogs/moderator-delete/moderator-delete.component.ts
@@ -3,6 +3,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
 import { ModeratorsComponent } from '../moderators/moderators.component';
 import { DialogConfirmActionButtonType } from '../../../shared/dialog/dialog-action-buttons/dialog-action-buttons.component';
 import { LiveAnnouncer } from '@angular/cdk/a11y';
+import { TranslateService } from '@ngx-translate/core';
 
 @Component({
   selector: 'app-moderator-delete',
@@ -22,7 +23,8 @@ export class ModeratorDeleteComponent implements OnInit {
 
   constructor(public dialogRef: MatDialogRef<ModeratorsComponent>,
               @Inject(MAT_DIALOG_DATA) public data: any,
-              private liveAnnouncer: LiveAnnouncer) { }
+              private liveAnnouncer: LiveAnnouncer,
+              private translationService: TranslateService ) { }
 
   ngOnInit() {
     this.announce();
@@ -31,7 +33,16 @@ export class ModeratorDeleteComponent implements OnInit {
 
 
   public announce() {
-    this.liveAnnouncer.announce('Willst du wirklich diesen Moderator löschen?', 'assertive');
+    const lang: string = this.translationService.currentLang;
+
+    // current live announcer content must be cleared before next read
+    this.liveAnnouncer.clear();
+
+    if (lang === 'de') {
+      this.liveAnnouncer.announce('Willst du wirklich den Moderator ' + this.loginId + ' löschen?');
+    } else {
+      this.liveAnnouncer.announce('Do you really want to remove the moderator? ' + this.loginId);
+    }
   }
 
 
diff --git a/src/app/components/creator/_dialogs/room-delete/room-delete.component.ts b/src/app/components/creator/_dialogs/room-delete/room-delete.component.ts
index 4e9574bd3..1ae5ad484 100644
--- a/src/app/components/creator/_dialogs/room-delete/room-delete.component.ts
+++ b/src/app/components/creator/_dialogs/room-delete/room-delete.component.ts
@@ -4,6 +4,7 @@ import { Room } from '../../../../models/room';
 import { RoomEditComponent } from '../room-edit/room-edit.component';
 import { DialogConfirmActionButtonType } from '../../../shared/dialog/dialog-action-buttons/dialog-action-buttons.component';
 import { LiveAnnouncer } from '@angular/cdk/a11y';
+import { TranslateService } from '@ngx-translate/core';
 
 @Component({
   selector: 'app-room-delete',
@@ -22,7 +23,8 @@ export class RoomDeleteComponent implements OnInit {
 
   constructor(public dialogRef: MatDialogRef<RoomEditComponent>,
               @Inject(MAT_DIALOG_DATA) public data: any,
-              private liveAnnouncer: LiveAnnouncer) { }
+              private liveAnnouncer: LiveAnnouncer,
+              private translationService: TranslateService ) { }
 
 
   ngOnInit() {
@@ -31,7 +33,17 @@ export class RoomDeleteComponent implements OnInit {
 
 
   public announce() {
-    this.liveAnnouncer.announce('Willst du die Sitzung wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.', 'assertive');
+    const lang: string = this.translationService.currentLang;
+
+    // current live announcer content must be cleared before next read
+    this.liveAnnouncer.clear();
+
+    if (lang === 'de') {
+      this.liveAnnouncer.announce('Willst du die Sitzung' + this.room.name + 'wirklich löschen? ' +
+        'Diese Aktion kann nicht rückgängig gemacht werden.');
+    } else {
+      this.liveAnnouncer.announce('Do you really want to delete session' + this.room.name + '? This action can not be undone.');
+    }
   }
 
 
-- 
GitLab