diff --git a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.html b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.html index b5c37e048819e5fe3c8f59ab25ef712db83d664c..681b238242516fa464d899900d61115c0a971ecb 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.html +++ b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.html @@ -114,8 +114,7 @@ <mat-expansion-panel (opened)="panelOpenState = true" (closed)="panelOpenState = edit = false" *ngFor="let keyword of - (searchMode ? filteredKeywords : - (profanityFilter ? keywordsWithProfanity : keywords)); let i = index" [attr.data-index]="i"> + (searchMode ? filteredKeywords : keywords); let i = index" [attr.data-index]="i"> <mat-expansion-panel-header class="color"> <mat-panel-title [ngClass]="{'edit-keyword': editedKeyword}"> {{keyword.keyword}} 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 ca9d02ce61f908f32104c23c811ff9057b3ab803..e8cd5099d766e7eb1e6d9da320c01b6ef7a7453a 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 @@ -23,16 +23,15 @@ export class TopicCloudAdministrationComponent implements OnInit { newKeyword = undefined; edit = false; isCreatorOrMod: boolean; - enterBadword: boolean = false; + enterBadword = false; newBadWord: string = undefined; - keywordsWithProfanity: Keyword[] = []; sortMode = 'alphabetic'; editedKeyword = false; searchedKeyword = undefined; searchMode = false; filteredKeywords: Keyword[] = []; - model=new FormControl(''); + model = new FormControl(''); output: any | undefined; newOutput: []; @@ -88,6 +87,8 @@ export class TopicCloudAdministrationComponent implements OnInit { 'Englisch: Fuck you!', 'Deutsch: Fick dich!', 'Französisch: Gros con!', + 'Multi language: Ficken, Fuck, con', + 'Custom: Nieder mit KQC' ] }, @@ -111,13 +112,7 @@ export class TopicCloudAdministrationComponent implements OnInit { this.translateService.use(localStorage.getItem('currentLang')); this.checkIfUserIsModOrCreator(); this.checkIfThereAreQuestions(); - this.refreshProfanityFilter(); this.sortQuestions(); - this.cloneKeywords(); - } - - cloneKeywords(){ - this.keywordsWithProfanity = JSON.parse(JSON.stringify(this.keywords)); } sortQuestions(sortMode?: string) { @@ -214,15 +209,9 @@ export class TopicCloudAdministrationComponent implements OnInit { if (!this.searchedKeyword){ this.searchMode = false; } else { - if (this.profanityFilter){ - this.filteredKeywords = this.keywordsWithProfanity.filter(keyword => - keyword.keyword.toLowerCase().includes(this.searchedKeyword.toLowerCase()) - ); - } else { this.filteredKeywords = this.keywords.filter(keyword => keyword.keyword.toLowerCase().includes(this.searchedKeyword.toLowerCase()) ); - } this.searchMode = true; } } @@ -277,25 +266,14 @@ export class TopicCloudAdministrationComponent implements OnInit { selectedLang = localStorage.getItem('currentLang'); comment: Comment; - addBadword(){ + addBadword() { this.topicCloudAdminService.addToBadwordList(this.newBadWord); this.newBadWord = undefined; - this.refreshProfanityFilter(); if (this.searchMode){ this.searchKeyword(); } } - refreshProfanityFilter(){ - for (let i = 0; i < this.keywordsWithProfanity.length; i++){ - // TODO: filter also keywords - for (let j = 0; j < this.keywordsWithProfanity[i].questions.length; j++){ - this.keywordsWithProfanity[i].questions[j] = - this.topicCloudAdminService.filterProfanityWords(this.keywords[i].questions[j]); - } - } - } - refreshAllLists(){ this.searchKeyword(); } 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 18d28570e498e2bdfcbffaefdc6bdc972a9c5f5d..73b5b508b750e6094a9fe7492bffe5c3b29d7d75 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 @@ -21,13 +21,14 @@ export class TopicDialogCommentComponent implements OnInit, OnChanges { constructor(private topicCloudAdminService: TopicCloudAdminService) { } - ngOnChanges(changes: SimpleChanges){ + ngOnChanges(changes: SimpleChanges) { } get partsOfQuestion() { if (this.profanityFilter) { - return this.questionWithProfinity - .slice(0,this.isCollapsed? this.questionWithProfinity.length: this.maxShowedCharachters) + const question = this.topicCloudAdminService.filterProfanityWords(this.question); + return question + .slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters) .split(new RegExp(this.keyword,'i')); } else { return this.question diff --git a/src/app/services/util/topic-cloud-admin.service.ts b/src/app/services/util/topic-cloud-admin.service.ts index defa915a5efcb915732ab0a6cb59b0016a0e1924..e4bec1924f185010b23a3127728757488c077c03 100644 --- a/src/app/services/util/topic-cloud-admin.service.ts +++ b/src/app/services/util/topic-cloud-admin.service.ts @@ -15,13 +15,13 @@ export class TopicCloudAdminService { constructor() { this.badWords = BadWords; - this.badWords['custom'] = ['nieder mit kqc']; + this.badWords['custom'] = []; } filterProfanityWords(str: string): string { let questionWithProfanity = str; const questionLowerCase = str.toLowerCase(); - + // German Profanity this.badWords['de'].map(word =>{ questionWithProfanity = questionLowerCase.includes(word.toLowerCase()) ?