diff --git a/src/app/components/shared/_dialogs/create-comment/create-comment.component.ts b/src/app/components/shared/_dialogs/create-comment/create-comment.component.ts index 39ca5d4ea80a23857c7802d5d05291a8efdffb38..f90f25b359d44f5b9d01dc69f1fe41f5dc305080 100644 --- a/src/app/components/shared/_dialogs/create-comment/create-comment.component.ts +++ b/src/app/components/shared/_dialogs/create-comment/create-comment.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, OnInit, ViewChild } from '@angular/core'; +import { Component, Inject, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { Comment } from '../../../../models/comment'; import { NotificationService } from '../../../../services/util/notification.service'; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; @@ -15,7 +15,7 @@ import { LanguagetoolService, Language } from '../../../../services/http/languag templateUrl: './create-comment.component.html', styleUrls: ['./create-comment.component.scss'] }) -export class CreateCommentComponent implements OnInit { +export class CreateCommentComponent implements OnInit, OnDestroy { comment: Comment; @@ -47,20 +47,22 @@ export class CreateCommentComponent implements OnInit { this.translateService.use(localStorage.getItem('currentLang')); setTimeout(() => { document.getElementById('answer-input').focus(); - document.addEventListener('click', this.onDocumentClick) + document.addEventListener('click', this.onDocumentClick); }, 0); } onDocumentClick(e) { const container = document.getElementsByClassName('dropdownBlock'); Array.prototype.forEach.call(container, (elem) => { - if (!elem.contains(e.target) && (!(e.target as Node).parentElement.classList.contains('markUp') || (e.target as HTMLElement).dataset.id !== ((elem as Node).parentElement as HTMLElement).dataset.id)) + if (!elem.contains(e.target) && (!(e.target as Node).parentElement.classList.contains('markUp') + || (e.target as HTMLElement).dataset.id !== ((elem as Node).parentElement as HTMLElement).dataset.id)) { (elem as HTMLElement).style.display = 'none'; + } }); } ngOnDestroy() { - document.removeEventListener('click', this.onDocumentClick) + document.removeEventListener('click', this.onDocumentClick); } onNoClick(): void { @@ -187,7 +189,7 @@ export class CreateCommentComponent implements OnInit { } const replacement = - '<div class="markUp" data-id="' + i + '" style="position: relative; display: inline-block; border-bottom: 1px dotted black">' + + '<div class="markUp" data-id="'+i+'" style="position: relative; display: inline-block; border-bottom: 1px dotted black">' + ' <span data-id="' + i + '" style="text-decoration: underline wavy red; cursor: pointer;">' + wrongWord + ' </span>' + @@ -205,7 +207,7 @@ export class CreateCommentComponent implements OnInit { setTimeout(() => { Array.from(document.getElementsByClassName('markUp')).forEach(marked => { marked.addEventListener('click', () => { - ((marked as HTMLElement).lastChild as HTMLElement).style.display = 'block' + ((marked as HTMLElement).lastChild as HTMLElement).style.display = 'block'; setTimeout(() => { Array.from(document.getElementsByClassName('suggestions')).forEach(e => { e.addEventListener('click', () => { diff --git a/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts index 20cb797836e4e0a2892e515ad10341c314e6a15e..a8faa57be66af7fac92f41149cea1c4dcf0ba566 100644 --- a/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts +++ b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts @@ -53,7 +53,7 @@ export class SpacyDialogComponent implements OnInit, AfterContentInit { buildCreateCommentActionCallback() { return () => { - this.comment.keywordsFromQuestionaire = this.keywords.filter(kw => kw.selected).map(kw => kw.word); + this.comment.keywordsFromQuestioner = this.keywords.filter(kw => kw.selected).map(kw => kw.word); this.comment.keywordsFromSpacy = this.keywordsOriginal.map(kw => kw.word); this.dialogRef.close(this.comment); }; diff --git a/src/app/components/shared/comment/comment.component.html b/src/app/components/shared/comment/comment.component.html index 9fbc5b5462b8e75fcdab3bef5265e8aa905ef05e..f64383ad8be785425e53d38469d15abf19673ddb 100644 --- a/src/app/components/shared/comment/comment.component.html +++ b/src/app/components/shared/comment/comment.component.html @@ -320,7 +320,7 @@ <div fxLayoutAlign="center center" matTooltip="{{ 'comment-page.keywords-per-question' | translate }}" [mat-menu-trigger-for]="keywordsMenu" - *ngIf="(comment.keywordsFromQuestionaire != undefined && comment.keywordsFromQuestionaire.length > 0)" + *ngIf="(comment.keywordsFromQuestioner != undefined && comment.keywordsFromQuestioner.length > 0)" class="comment-keywords"> <mat-icon svgIcon="comment_tag"></mat-icon> <span> @@ -329,7 +329,7 @@ <mat-menu #keywordsMenu> <mat-list dense class="keywords-list"> - <mat-list-item *ngFor="let keyword of comment.keywords; let odd = odd; let even = even" + <mat-list-item *ngFor="let keyword of comment.keywordsFromQuestioner; let odd = odd; let even = even" [class.keywords-alternate]="odd" [class.keywords-even]="even"> <span class="keyword-span">{{keyword}}</span> diff --git a/src/app/models/comment.ts b/src/app/models/comment.ts index be8f2413904c5a273bf3804e1e2f2240266764c2..45a55c60dcc1bd33798e2b196bce73dd3fb680ce 100644 --- a/src/app/models/comment.ts +++ b/src/app/models/comment.ts @@ -21,7 +21,7 @@ export class Comment { userNumber: number; number: number; keywordsFromSpacy: string[]; - keywordsFromQuestionaire: string[]; + keywordsFromQuestioner: string[]; constructor(roomId: string = '', creatorId: string = '', @@ -39,7 +39,7 @@ export class Comment { answer: string = '', userNumber: number = 0, keywordsFromSpacy: string[] = [], - keywordsFromQuestionaire: string[] = []) { + keywordsFromQuestioner: string[] = []) { this.id = ''; this.roomId = roomId; this.creatorId = creatorId; @@ -58,6 +58,6 @@ export class Comment { this.answer = answer; this.userNumber = userNumber; this.keywordsFromSpacy = keywordsFromSpacy; - this.keywordsFromQuestionaire = keywordsFromQuestionaire; + this.keywordsFromQuestioner = keywordsFromQuestioner; } }