Skip to content
Snippets Groups Projects
Commit f8d276e8 authored by Mohammad Alayoub's avatar Mohammad Alayoub
Browse files

Enable searching on the blacklist tab; adjust the length of keywords in te icon

parent bec7abfd
No related merge requests found
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
<p [ngClass]="{'animation-blink': searchMode}" <p [ngClass]="{'animation-blink': searchMode}"
matTooltip="{{'topic-cloud-dialog.keyword-counter' | translate}}"> matTooltip="{{'topic-cloud-dialog.keyword-counter' | translate}}">
{{searchMode ? filteredKeywords.length : {{searchMode ? filteredKeywords.length :
keywords.length}}</p> selectedTabIndex === 0 ? keywords.length : blacklistKeywords.length}}</p>
</div> </div>
<div class="margin-left vertical-center"> <div class="margin-left vertical-center">
<button [ngClass]="{'animation-blink': sortMode!=='alphabetic'}" mat-icon-button [matMenuTriggerFor]="sortMenu"> <button [ngClass]="{'animation-blink': sortMode!=='alphabetic'}" mat-icon-button [matMenuTriggerFor]="sortMenu">
...@@ -361,16 +361,15 @@ ...@@ -361,16 +361,15 @@
</button> </button>
</mat-menu> </mat-menu>
<mat-card class="color-surface"
*ngIf="(keywords.length === 0 || (searchMode && filteredKeywords.length === 0))&&!isLoading">
<p class="color-on-surface" fxLayoutAlign="center">
{{'topic-cloud-dialog.no-keywords-note' | translate}}
</p>
</mat-card>
<mat-accordion> <mat-accordion>
<mat-tab-group animationDuration="0ms" mat-stretch-tabs mat-align-tabs="center"> <mat-tab-group [selectedIndex]="selectedTabIndex" (selectedIndexChange)="changeTabIndex()" animationDuration="0ms" mat-stretch-tabs mat-align-tabs="center">
<mat-tab label="{{'topic-cloud-dialog.keywords' | translate}}"> <mat-tab label="{{'topic-cloud-dialog.keywords' | translate}}">
<mat-card class="color-surface"
*ngIf="(keywords.length === 0 || (searchMode && filteredKeywords.length === 0))&&!isLoading">
<p class="color-on-surface" fxLayoutAlign="center">
{{'topic-cloud-dialog.no-keywords-note' | translate}}
</p>
</mat-card>
<div *ngFor="let keyword of (searchMode ? filteredKeywords : keywords); let i = index"> <div *ngFor="let keyword of (searchMode ? filteredKeywords : keywords); let i = index">
<mat-expansion-panel class="color-surface" (opened)="panelOpenState = true" <mat-expansion-panel class="color-surface" (opened)="panelOpenState = true"
(closed)="panelOpenState = edit = false" [attr.data-index]="i" (closed)="panelOpenState = edit = false" [attr.data-index]="i"
......
...@@ -59,6 +59,7 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { ...@@ -59,6 +59,7 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
minUpvotes: string; minUpvotes: string;
startDate: string; startDate: string;
endDate: string; endDate: string;
selectedTabIndex = 0;
keywords: Keyword[] = []; keywords: Keyword[] = [];
private topicCloudAdminData: TopicCloudAdminData; private topicCloudAdminData: TopicCloudAdminData;
...@@ -105,6 +106,13 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { ...@@ -105,6 +106,13 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
this.initializeKeywords(); this.initializeKeywords();
} }
changeTabIndex() {
this.selectedTabIndex = this.selectedTabIndex === 0 ? 1 : 0;
if (this.searchMode) {
this.searchKeyword();
}
}
removeFromKeywords(comment: Comment) { removeFromKeywords(comment: Comment) {
for (const keyword of this.keywords) { for (const keyword of this.keywords) {
keyword.comments.forEach(_comment => { keyword.comments.forEach(_comment => {
...@@ -450,10 +458,11 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { ...@@ -450,10 +458,11 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
} }
searchKeyword(): void { searchKeyword(): void {
const toFilteredKeywords = this.selectedTabIndex === 0 ? this.keywords : this.blacklistKeywords;
if (!this.searchedKeyword) { if (!this.searchedKeyword) {
this.searchMode = false; this.searchMode = false;
} else { } else {
this.filteredKeywords = this.keywords.filter(keyword => this.filteredKeywords = toFilteredKeywords.filter(keyword =>
keyword.keyword.toLowerCase().includes(this.searchedKeyword.toLowerCase()) keyword.keyword.toLowerCase().includes(this.searchedKeyword.toLowerCase())
); );
this.searchMode = true; this.searchMode = true;
......
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