From d4eab417b64acfa87cd0160af6b0f8998237e18b Mon Sep 17 00:00:00 2001 From: mohammad <mohammad.alayoub@mni.thm.de> Date: Wed, 9 Jun 2021 18:10:27 +0200 Subject: [PATCH] add word in lower case to the blacklist; don't show moderator tools for participants --- .../topic-cloud-administration.component.html | 195 +++++++++--------- .../topic-cloud-administration.component.ts | 2 +- .../util/topic-cloud-admin.service.ts | 2 +- 3 files changed, 101 insertions(+), 98 deletions(-) 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 b109b9935..17dd5e40c 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 @@ -27,81 +27,85 @@ <mat-slide-toggle [(ngModel)]="considerVotes"> {{'topic-cloud-dialog.consider-votes' | translate}} </mat-slide-toggle> - <mat-slide-toggle (change)="refreshAllLists()" [(ngModel)]="profanityFilter"> - {{'topic-cloud-dialog.profanity' | translate}} - </mat-slide-toggle> - <mat-slide-toggle [(ngModel)]="blacklistIsActive"> - {{'topic-cloud-dialog.hide-blacklist-words' | translate}} - </mat-slide-toggle> + <div *ngIf="isCreatorOrMod"> + <mat-slide-toggle (change)="refreshAllLists()" [(ngModel)]="profanityFilter"> + {{'topic-cloud-dialog.profanity' | translate}} + </mat-slide-toggle> + <mat-slide-toggle [(ngModel)]="blacklistIsActive"> + {{'topic-cloud-dialog.hide-blacklist-words' | translate}} + </mat-slide-toggle> + </div> <mat-accordion class="new-profanity-word" multi> - <mat-expansion-panel class="color-background" (opened)="enterProfanityWord=true; focusInput('bad-word-input')" - (closed)="enterProfanityWord = false"> - <mat-expansion-panel-header class="color-background"> - <mat-panel-title> - {{'topic-cloud-dialog.edit-profanity-list' | translate}} - </mat-panel-title> - </mat-expansion-panel-header> - - <mat-form-field> - <mat-label>{{'topic-cloud-dialog.enter-word' | translate}}</mat-label> - <input matInput id="bad-word-input" [(ngModel)]="newProfanityWord"> - </mat-form-field> - - <button mat-stroked-button color="primary" class="margin-left" (click)="addProfanityWord()"> - {{'topic-cloud-dialog.add-word' | translate}} - </button> - - <mat-list role="list" *ngIf="showProfanityList" class="margin-bottom"> - <mat-list-item class="color-on-surface" *ngFor="let word of getProfanityList()" role="listitem">{{word}} - <button style="margin-left: auto" mat-icon-button class="red" (click)="removeWordFromProfanityList(word)"> - <mat-icon mat-list-icon style="margin-bottom: 6px;">delete</mat-icon> - </button> - </mat-list-item> - </mat-list> - - <div> - <button mat-raised-button *ngIf="getProfanityList().length > 0" class="primaryBackground" - (click)="showProfanityList=!showProfanityList"> - {{showProfanityList ? ('topic-cloud-dialog.hide-profanity-list' | translate) : - ('topic-cloud-dialog.show-profanity-list' | translate)}} + <div *ngIf="isCreatorOrMod"> + <mat-expansion-panel class="color-background" (opened)="enterProfanityWord=true; focusInput('bad-word-input')" + (closed)="enterProfanityWord = false"> + <mat-expansion-panel-header class="color-background"> + <mat-panel-title> + {{'topic-cloud-dialog.edit-profanity-list' | translate}} + </mat-panel-title> + </mat-expansion-panel-header> + + <mat-form-field> + <mat-label>{{'topic-cloud-dialog.enter-word' | translate}}</mat-label> + <input matInput id="bad-word-input" [(ngModel)]="newProfanityWord"> + </mat-form-field> + + <button mat-stroked-button color="primary" class="margin-left" (click)="addProfanityWord()"> + {{'topic-cloud-dialog.add-word' | translate}} </button> - </div> - </mat-expansion-panel> - - <mat-expansion-panel class="color-background margin-bottom" - (opened)="enterBlacklistWord = true; focusInput('blacklist-word-input')" - (closed)="enterBlacklistWord = false"> - <mat-expansion-panel-header class="color-background"> - <mat-panel-title> - {{'topic-cloud-dialog.edit-blacklist-list' | translate}} - </mat-panel-title> - </mat-expansion-panel-header> - - <mat-form-field> - <mat-label>{{'topic-cloud-dialog.enter-word' | translate}}</mat-label> - <input matInput id="blacklist-word-input" [(ngModel)]="newBlacklistWord"> - </mat-form-field> - - <button mat-stroked-button color="primary" class="margin-left" (click)="addBlacklistWord()"> - {{'topic-cloud-dialog.add-word' | translate}} - </button> - <mat-list role="list" *ngIf="showBlacklistWordList && blacklist.length > 0" class="margin-bottom"> - <mat-list-item class="color-on-surface" *ngFor="let word of blacklist" role="listitem">{{word}} - <button style="margin-left: auto" mat-icon-button class="red" (click)="removeWordFromBlacklist(word)"> - <mat-icon mat-list-icon style="margin-bottom: 6px;">delete</mat-icon> + + <mat-list role="list" *ngIf="showProfanityList" class="margin-bottom"> + <mat-list-item class="color-on-surface" *ngFor="let word of getProfanityList()" role="listitem">{{word}} + <button style="margin-left: auto" mat-icon-button class="red" (click)="removeWordFromProfanityList(word)"> + <mat-icon mat-list-icon style="margin-bottom: 6px;">delete</mat-icon> + </button> + </mat-list-item> + </mat-list> + + <div> + <button mat-raised-button *ngIf="getProfanityList().length > 0" class="primaryBackground" + (click)="showProfanityList=!showProfanityList"> + {{showProfanityList ? ('topic-cloud-dialog.hide-profanity-list' | translate) : + ('topic-cloud-dialog.show-profanity-list' | translate)}} </button> - </mat-list-item> - </mat-list> - - <div> - <button mat-raised-button class="primaryBackground" *ngIf="blacklist.length > 0" - (click)="showBlacklistWordList=!showBlacklistWordList"> - {{showBlacklistWordList ? ('topic-cloud-dialog.hide-blacklist' | translate) : - ('topic-cloud-dialog.show-blacklist' | translate)}} + </div> + </mat-expansion-panel> + + <mat-expansion-panel class="color-background margin-bottom" + (opened)="enterBlacklistWord = true; focusInput('blacklist-word-input')" + (closed)="enterBlacklistWord = false"> + <mat-expansion-panel-header class="color-background"> + <mat-panel-title> + {{'topic-cloud-dialog.edit-blacklist-list' | translate}} + </mat-panel-title> + </mat-expansion-panel-header> + + <mat-form-field> + <mat-label>{{'topic-cloud-dialog.enter-word' | translate}}</mat-label> + <input matInput id="blacklist-word-input" [(ngModel)]="newBlacklistWord"> + </mat-form-field> + + <button mat-stroked-button color="primary" class="margin-left" (click)="addBlacklistWord()"> + {{'topic-cloud-dialog.add-word' | translate}} </button> - </div> - </mat-expansion-panel> + <mat-list role="list" *ngIf="showBlacklistWordList && blacklist.length > 0" class="margin-bottom"> + <mat-list-item class="color-on-surface" *ngFor="let word of blacklist" role="listitem">{{word}} + <button style="margin-left: auto" mat-icon-button class="red" (click)="removeWordFromBlacklist(word)"> + <mat-icon mat-list-icon style="margin-bottom: 6px;">delete</mat-icon> + </button> + </mat-list-item> + </mat-list> + + <div> + <button mat-raised-button class="primaryBackground" *ngIf="blacklist.length > 0" + (click)="showBlacklistWordList=!showBlacklistWordList"> + {{showBlacklistWordList ? ('topic-cloud-dialog.hide-blacklist' | translate) : + ('topic-cloud-dialog.show-blacklist' | translate)}} + </button> + </div> + </mat-expansion-panel> + </div> <mat-expansion-panel class="color-background"> <mat-expansion-panel-header class="color-background"> <mat-panel-title> @@ -216,32 +220,31 @@ [isCollapsed]="!panelOpenState" [profanityFilter]="profanityFilter"></app-topic-dialog-comment> </div> - <!-- Only visible when not editing --> - <div *ngIf="!edit" align="end"> - <mat-divider></mat-divider> - - <button class="margin-right" mat-icon-button style="align-self:flex-end;" (click)="editKeyword(i)"> - <mat-icon class="primary">edit</mat-icon> - </button> - <button class="margin-right" mat-icon-button style="align-self:flex-end;" - (click)="openConfirmDialog('delete-message','delete',keyword)"> - <mat-icon class="red">delete</mat-icon> - </button> - </div> - - <!-- Only visible when editing --> - <div *ngIf="edit"> - <mat-divider></mat-divider> - <mat-form-field> - <mat-label>{{'topic-cloud-dialog.edit-keyword-tip' | translate}}</mat-label> - <input matInput id="{{'edit-input'+i}}" [(ngModel)]="newKeyword"> - </mat-form-field> - <!-- TODO: textinput and buttons in one row --> - <div align="end"> - <button mat-raised-button class="redBackground margin-right" - (click)="cancelEdit()">{{'topic-cloud-dialog.cancel' | translate}}</button> - <button mat-raised-button class="primaryBackground" (click)="confirmEdit(keyword)">{{'topic-cloud-dialog.save' - | translate}}</button> + <div *ngIf="isCreatorOrMod"> + <!-- Only visible when not editing --> + <div *ngIf="!edit" align="end"> + <mat-divider></mat-divider> + <button class="margin-right" mat-icon-button style="align-self:flex-end;" (click)="editKeyword(i)"> + <mat-icon class="primary">edit</mat-icon> + </button> + <button class="margin-right" mat-icon-button style="align-self:flex-end;" + (click)="openConfirmDialog('delete-message','delete',keyword)"> + <mat-icon class="red">delete</mat-icon> + </button> + </div> + <!-- Only visible when editing --> + <div *ngIf="edit"> + <mat-divider></mat-divider> + <mat-form-field> + <mat-label>{{'topic-cloud-dialog.edit-keyword-tip' | translate}}</mat-label> + <input matInput id="{{'edit-input'+i}}" [(ngModel)]="newKeyword"> + </mat-form-field> + <div align="end"> + <button mat-raised-button class="redBackground margin-right" + (click)="cancelEdit()">{{'topic-cloud-dialog.cancel' | translate}}</button> + <button mat-raised-button class="primaryBackground" (click)="confirmEdit(keyword)">{{'topic-cloud-dialog.save' + | translate}}</button> + </div> </div> </div> </mat-expansion-panel> 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 106a6638f..a249a2236 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 @@ -72,7 +72,7 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { ngOnInit(): void { this.wsCommentServiceService.getCommentStream(localStorage.getItem('roomId')).subscribe(_ => this.updateKeywords()); this.blacklistSubscription = this.topicCloudAdminService.getBlacklist().subscribe(list => this.blacklist = list); - this.isCreatorOrMod = this.data ? (this.data.user.role !== UserRole.PARTICIPANT) : true; + this.isCreatorOrMod = this.data.user.role !== UserRole.PARTICIPANT; this.translateService.use(localStorage.getItem('currentLang')); this.spacyLabels = spacyLabels; this.wantedLabels = undefined; diff --git a/src/app/services/util/topic-cloud-admin.service.ts b/src/app/services/util/topic-cloud-admin.service.ts index f6a09715c..b94ef044b 100644 --- a/src/app/services/util/topic-cloud-admin.service.ts +++ b/src/app/services/util/topic-cloud-admin.service.ts @@ -131,7 +131,7 @@ export class TopicCloudAdminService { this.getRoom().subscribe(room => { const newlist = JSON.parse(room.blacklist); if (!newlist.includes(word)){ - newlist.push(word); + newlist.push(word.toLowerCase()); } this.updateBlacklist(newlist, room); }); -- GitLab