From dd21fbcbd93194d256a9748b2e2fb29701258181 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Sat, 9 Feb 2019 17:04:44 +0100
Subject: [PATCH] Adjust dialog-closing-messanges and use switchCase instead of
 if

---
 .../content-edit/content-edit.component.html  |  4 +--
 .../content-list/content-list.component.ts    | 30 +++++++++----------
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/app/components/creator/_dialogs/content-edit/content-edit.component.html b/src/app/components/creator/_dialogs/content-edit/content-edit.component.html
index 6a0ee94f4..7554243a0 100644
--- a/src/app/components/creator/_dialogs/content-edit/content-edit.component.html
+++ b/src/app/components/creator/_dialogs/content-edit/content-edit.component.html
@@ -6,10 +6,10 @@
     <textarea matInput [(ngModel)]="content.body" rows="3" maxlength="100" placeholder="Inhalt" name="body"></textarea>
   </mat-form-field>
   <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px">
-    <button (click)="dialogRef.close()" mat-button color="primary">
+    <button (click)="dialogRef.close('abort')" mat-button color="primary">
       {{ 'room-page.abort' | translate }}
     </button>
-    <button (click)="dialogRef.close('edit')" mat-raised-button color="primary">
+    <button (click)="dialogRef.close('update')" mat-raised-button color="primary">
       {{ 'room-page.update' | translate }}
     </button>
   </div>
diff --git a/src/app/components/creator/content-list/content-list.component.ts b/src/app/components/creator/content-list/content-list.component.ts
index 911909ef7..766db7dff 100644
--- a/src/app/components/creator/content-list/content-list.component.ts
+++ b/src/app/components/creator/content-list/content-list.component.ts
@@ -113,7 +113,7 @@ export class ContentListComponent implements OnInit {
     const index = this.findIndexOfSubject(delContent.subject);
     this.contentBackup = delContent;
     const dialogRef = this.dialog.open(ContentDeleteComponent, {
-      width: '800px'
+      width: '400px'
     });
     dialogRef.componentInstance.content = delContent;
     dialogRef.afterClosed()
@@ -131,7 +131,7 @@ export class ContentListComponent implements OnInit {
 
     const index = this.findIndexOfSubject(edContent.subject);
     const dialogRef = this.dialog.open(ContentEditComponent, {
-      width: '800px'
+      width: '400px'
     });
     dialogRef.componentInstance.content = edContent;
     dialogRef.afterClosed()
@@ -144,20 +144,18 @@ export class ContentListComponent implements OnInit {
     if (!action) {
       this.contents[index] = this.contentBackup;
     } else {
-      if (action.valueOf() === 'delete') {
-        this.notificationService.show('Content "' + this.contents[index].subject + '" deleted.');
-        this.contentService.deleteContent(this.contents[index].id).subscribe();
-        this.contents.splice(index, 1);
-        if (this.contents.length === 0) {
-          this.location.back();
-        }
-      }
-      if (action.valueOf() === 'edit') {
-        this.notificationService.show('Content "' + this.contents[index].subject + '" updated.');
-        this.contentService.updateContent(this.contents[index]);
-      }
-      if (action.valueOf() === 'abort') {
-        this.contents[index] = this.contentBackup;
+      switch (action.valueOf()) {
+        case 'delete':
+          this.notificationService.show('Content "' + this.contents[index].subject + '" deleted.');
+          this.contentService.deleteContent(this.contents[index].id).subscribe();
+          this.contents.splice(index, 1);
+          if (this.contents.length === 0) {
+            this.location.back();
+          }
+          break;
+        case 'abort':
+          this.contents[index] = this.contentBackup;
+          break;
       }
     }
   }
-- 
GitLab