Skip to content
Snippets Groups Projects
Commit ef80621a authored by Stefan Plociennik's avatar Stefan Plociennik
Browse files

removed cloned keyword array

parent f75bc4c1
No related merge requests found
......@@ -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}}
......
......@@ -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();
}
......
......@@ -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
......
......@@ -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()) ?
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment