From 1540c2f9ac366ed53c8518e94f0a49fd3c9a53c8 Mon Sep 17 00:00:00 2001
From: Stefan Plociennik <stefan.plociennik@mni.thm.de>
Date: Tue, 11 May 2021 20:34:01 +0200
Subject: [PATCH] replaced empty strings with undefined

---
 .../topic-cloud-administration.component.ts   | 29 +++++++++----------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts
index ca8a05f30..da4ef5439 100644
--- a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts
+++ b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts
@@ -17,13 +17,15 @@ export class TopicCloudAdministrationComponent implements OnInit {
   public panelOpenState = false;
   public considerVotes: boolean; // should be sent back to tagCloud component
   public tagsLowerCase: boolean; // should be sent back to tagCloud component
-  newKeyword = '';
+  newKeyword = undefined;
   edit = false;
   isCreatorOrMod: boolean;
-  sortMode: SortMode = SortMode.alphabetic;
-  sortModeEnum: typeof SortMode = SortMode;
+
+  sortMode = 'alphabetic';
+  // sortMode: SortMode = SortMode.alphabetic;
+  // sortModeEnum: typeof SortMode = SortMode;
   editedKeyword = false;
-  searchedKeyword = '';
+  searchedKeyword = undefined;
   searchMode = false;
   filteredKeywords: Keyword[] = [];
 
@@ -93,16 +95,16 @@ export class TopicCloudAdministrationComponent implements OnInit {
     this.sortQuestions();
   }
 
-  sortQuestions(sortMode?: SortMode) {
+  sortQuestions(sortMode?: string) {
     if (sortMode !== undefined) {
       this.sortMode = sortMode;
     }
 
     switch (this.sortMode) {
-      case SortMode.alphabetic:
+      case 'alphabetic':
         this.keywords.sort((a, b) => a.keyword.localeCompare(b.keyword));
         break;
-      case SortMode.questionsCount:
+      case 'questionsCount':
         this.keywords.sort((a, b) => b.questions.length - a.questions.length);
         break;
     }
@@ -157,7 +159,7 @@ export class TopicCloudAdministrationComponent implements OnInit {
 
   cancelEdit(): void {
     this.edit = false;
-    this.newKeyword = '';
+    this.newKeyword = undefined;
   }
 
   confirmEdit(id: number): void {
@@ -168,7 +170,7 @@ export class TopicCloudAdministrationComponent implements OnInit {
     });
     this.edit = false;
     this.editedKeyword = true;
-    this.newKeyword = '';
+    this.newKeyword = undefined;
     this.sortQuestions();
     if (this.searchMode){
       this.searchKeyword();
@@ -188,9 +190,9 @@ export class TopicCloudAdministrationComponent implements OnInit {
   }
 
   searchKeyword(): void{
-    if (this.searchedKeyword === ''){
+    if (this.searchedKeyword){
         this.searchMode = false;
-    } else{
+    } else {
       this.filteredKeywords = this.keywords.filter(keyword =>
         keyword.keyword.toLowerCase().includes(this.searchedKeyword.toLowerCase())
       );
@@ -199,11 +201,6 @@ export class TopicCloudAdministrationComponent implements OnInit {
   }
 }
 
-export enum SortMode {
-  alphabetic,
-  questionsCount
-}
-
 interface Keyword {
   keywordID: number;
   keyword: string;
-- 
GitLab