From f157cd0963fed4313987d1ef41709de2aa0165b1 Mon Sep 17 00:00:00 2001
From: mohammad <mohammad.alayoub@mni.thm.de>
Date: Tue, 15 Jun 2021 19:48:59 +0200
Subject: [PATCH] enable collapsing long questions again

---
 .../topic-dialog-comment.component.html       |  2 +-
 .../topic-dialog-comment.component.ts         | 21 ++++++++++++++-----
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.html b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.html
index ef9738a6a..8465d971e 100644
--- a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.html
+++ b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.html
@@ -1,6 +1,6 @@
 <div>
   <p>
-    <span *ngFor="let part Of partsOfQuestion; let i = index">{{part}}<mark *ngIf="i < partsOfQuestion.length -1">{{keyword}}</mark></span>
+    <span *ngFor="let part Of (isCollapsed?partsOfQuestion:partsOfShortQuestion); let i = index">{{part}}<mark *ngIf="i < partsOfQuestion.length-1">{{keyword}}</mark></span>
     <button
           *ngIf = "question.length > maxShowedCharachters"
           (click)="isCollapsed = !isCollapsed">
diff --git a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts
index 0b9fabd09..3a8869b37 100644
--- a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts
+++ b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts
@@ -17,9 +17,10 @@ export class TopicDialogCommentComponent implements OnInit {
   public badWords = [];
   questionWithoutProfanity: string = undefined;
 
-  public shortQuestion: string;
   public parts: string[];
   public partsWithoutProfanity: string[];
+  public partsShort: string[];
+  public partsWithoutProfanityShort: string[];
 
   constructor(private topicCloudAdminService: TopicCloudAdminService) { }
 
@@ -31,11 +32,21 @@ export class TopicDialogCommentComponent implements OnInit {
     }
   }
 
+  get partsOfShortQuestion(){
+    if (this.profanityFilter) {
+      return this.partsWithoutProfanityShort;
+    } else {
+      return this.partsShort;
+    }
+  }
+
   ngOnInit(): void {
     this.questionWithoutProfanity = this.topicCloudAdminService.filterProfanityWords(this.question);
-    this.partsWithoutProfanity = this.questionWithoutProfanity.slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters)
-                                                              .split(new RegExp(this.keyword,'i'));
-    this.parts = this.question.slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters)
-                              .split(new RegExp(this.keyword,'i'));
+    this.partsWithoutProfanity = this.questionWithoutProfanity.split(new RegExp(this.keyword,'i'));
+    this.parts = this.question.split(new RegExp(this.keyword,'i'));
+    this.partsShort = this.question.slice(0, this.maxShowedCharachters)
+    .split(new RegExp(this.keyword,'i'));
+    this.partsWithoutProfanityShort = this.questionWithoutProfanity.slice(0, this.maxShowedCharachters)
+    .split(new RegExp(this.keyword,'i'));
   }
 }
-- 
GitLab