diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3030bf8481f28e2fc52011d0abfc12def479f984..0de7b9567e4d934cc07a7f101747004f09ced28b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -63,7 +63,6 @@ import { TagCloudComponent } from './components/shared/tag-cloud/tag-cloud.compo import { MatDialogModule } from '@angular/material/dialog'; import {TagCloudModule} from 'angular-tag-cloud-module'; import {SpacyService} from './services/http/spacy.service'; -// import { SearchFilterPipe } from './pipe/search-filter.pipe'; // TODO: delete line export function dialogClose(dialogResult: any) { @@ -101,9 +100,7 @@ export function initializeApp(appConfig: AppConfig) { DemoEnComponent, HelpEnComponent, OverlayComponent, - TagCloudComponent, -// SearchFilterPipe, //TODO: delete line - + TagCloudComponent ], imports: [ MatomoModule, @@ -179,9 +176,6 @@ export function initializeApp(appConfig: AppConfig) { useValue: [] } ], - exports: [ - // SearchFilterPipe // TODO: delete line - ], bootstrap: [AppComponent] }) export class AppModule { diff --git a/src/app/components/participant/participant.module.ts b/src/app/components/participant/participant.module.ts index 8daf19bcec381ceecb01c1ee6047783b91b54401..e0d7fa04bd43b7039ab89f318480f9dd2254784c 100644 --- a/src/app/components/participant/participant.module.ts +++ b/src/app/components/participant/participant.module.ts @@ -25,10 +25,8 @@ import { MarkdownModule } from 'ngx-markdown'; }), MarkdownModule ], - exports: [ - ], declarations: [ - RoomParticipantPageComponent, + RoomParticipantPageComponent ] }) export class ParticipantModule { 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 2f520f13561a2d05d2414ecd07986686504eb35e..ef1b5175541ee3ab08ce4979b93ad4a8f7fa9c8b 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 @@ -1,95 +1,99 @@ <mat-dialog-content> - <mat-card> - <mat-slide-toggle [(ngModel)]="considerVotes">{{'topic-cloud-dialog.considerVotes' | translate}}</mat-slide-toggle> - <mat-slide-toggle [(ngModel)]="tagsLowerCase">{{'topic-cloud-dialog.tags-lowercase' | translate}}</mat-slide-toggle> - </mat-card> - - <div align="end"> - <mat-form-field class="example-full-width"> - <input - [formControl]="control" - [matAutocomplete]="auto" - (input)="searchComments()" [(ngModel)]="searchInput" class="toolbar-search" type="text" matInput> - <mat-placeholder>Search</mat-placeholder> - <mat-icon matSuffix style="font-size: 1.2em">search</mat-icon> - </mat-form-field> - <mat-autocomplete #auto="matAutocomplete"> - </mat-autocomplete> - <!--mat-autocomplete #auto="matAutoComplete"></mat-autocomplete--> - + <mat-card> + <mat-slide-toggle [(ngModel)]="considerVotes">{{'topic-cloud-dialog.considerVotes' | translate}}</mat-slide-toggle> + <mat-slide-toggle [(ngModel)]="tagsLowerCase">{{'topic-cloud-dialog.tags-lowercase' | translate}}</mat-slide-toggle> + </mat-card> + + <div fxLayout="row" style="margin-top: 10px;"> + <mat-label fxLayoutAlign="center center"> + <mat-icon>search</mat-icon> + </mat-label> + <div style="margin-left: 10px;"> + <mat-form-field class="example-form-field"> + <input #searchBox id="searchBox" (input)="searchKeyword()" + [(ngModel)]="searchedKeyword" matInput type="text" + placeholder="{{'topic-cloud-dialog.keyword-search' | translate}}"> + <button *ngIf="searchedKeyword !== ''" + (click)="searchedKeyword = ''; hideKeywords = false;" + mat-button matSuffix mat-icon-button aria-label="topic-cloud-dialog.keyword-search"> + <mat-icon>close</mat-icon> + </button> + </mat-form-field> + </div> + <div fxLayoutAlign="end" style="margin-left: 52%;"> <button mat-button [matMenuTriggerFor]="sortMenu" mat-ripple> <mat-icon>sort</mat-icon> </button> </div> + </div> - <mat-menu #sortMenu> - <button mat-menu-item (click)="sortQuestions(sortModeEnum.ALPHABETIC)"> + <mat-menu #sortMenu> + <button mat-menu-item (click)="sortQuestions(sortModeEnum.ALPHABETIC)"> + <mat-icon>sort_by_alpha</mat-icon> + {{'topic-cloud-dialog.sort-Alpha' | translate}} </button> + <button mat-menu-item (click)="sortQuestions(sortModeEnum.QUESTIONSCOUNT)"> + <mat-icon>swap_vert</mat-icon> + {{'topic-cloud-dialog.sort-Count' | translate}} </button> + <!-- <button mat-menu-item (click)="sortScore(true)" aria-labelledby="sort-lbl-rating">{{'question-wall.sort-score' | translate}}</button> --> + </mat-menu> - <mat-icon>sort_by_alpha</mat-icon> - {{'topic-cloud-dialog.sort-Alpha' | translate}} </button> - <button mat-menu-item (click)="sortQuestions(sortModeEnum.QUESTIONSCOUNT)"> - <mat-icon>swap_vert</mat-icon> - {{'topic-cloud-dialog.sort-Count' | translate}} </button> - <!-- <button mat-menu-item (click)="sortScore(true)" aria-labelledby="sort-lbl-rating">{{'question-wall.sort-score' | translate}}</button> --> - </mat-menu> - <mat-accordion> - <mat-expansion-panel (opened)="panelOpenState = true" - (closed)="panelOpenState = false" - *ngFor="let keyword of keywordsSubject | async | searchFilter: searchInput"> - <mat-expansion-panel-header class="color"> - <mat-panel-title [ngClass]="{'edit-keyword': editedKeyword}"> - {{keyword.keyword}} - - </mat-panel-title> - <mat-panel-description> - {{keyword.questions.length}} - {{'topic-cloud-dialog.question-count-'+(keyword.questions.length > 1 ? 'plural' : 'singular') | translate}} - </mat-panel-description> - </mat-expansion-panel-header> - <div *ngFor="let question of keyword.questions"> - <mat-divider></mat-divider> - <app-topic-dialog-comment - [question]="question" - [keyword] ="keyword.keyword" - [maxShowedCharachters] = "140" - [isCollapsed] = "!panelOpenState" - ></app-topic-dialog-comment> - <!--<p [ngClass]="{'hideText': question.length > maxShowedCharachters || isReadMore}"> - {{(question.length < maxShowedCharachters || isReadMore) ? question : question | slice:0:70}} - <button mat-icon-button *ngIf="question.length > maxShowedCharachters" style="background: none; font-weight: bold;" (click)="showText()"> - {{ !isReadMore ? '...more': '...less' }} - </button> - </p>--> - </div> + <mat-accordion> + <mat-expansion-panel (opened)="panelOpenState = true" + (closed)="panelOpenState = false" + *ngFor="let keyword of (hideKeywords ? filteredKeywords : keywords)"> + <mat-expansion-panel-header class="color"> + <mat-panel-title [ngClass]="{'edit-keyword': editedKeyword}"> + {{keyword.keyword}} + </mat-panel-title> + <mat-panel-description> + {{keyword.questions.length}} + {{'topic-cloud-dialog.question-count-'+(keyword.questions.length > 1 ? 'plural' : 'singular') | translate}} + </mat-panel-description> + </mat-expansion-panel-header> + <div *ngFor="let question of keyword.questions"> + <mat-divider></mat-divider> + <app-topic-dialog-comment + [question]="question" + [keyword]="keyword.keyword" + [maxShowedCharachters]="140" + [isCollapsed]="!panelOpenState" + ></app-topic-dialog-comment> + <!--<p [ngClass]="{'hideText': question.length > maxShowedCharachters || isReadMore}"> + {{(question.length < maxShowedCharachters || isReadMore) ? question : question | slice:0:70}} + <button mat-icon-button *ngIf="question.length > maxShowedCharachters" style="background: none; font-weight: bold;" (click)="showText()"> + {{ !isReadMore ? '...more': '...less' }} + </button> + </p>--> + </div> - <!-- Only visible when not editing --> - <div *ngIf="!edit && isCreatorOrMod" align="end"> - <mat-divider></mat-divider> + <!-- Only visible when not editing --> + <div *ngIf="!edit && isCreatorOrMod" align="end"> + <mat-divider></mat-divider> - <button class="margin-right" mat-icon-button style="align-self:flex-end;" (click)="editKeyword()"> - <mat-icon class="primary">edit</mat-icon> - </button> - <button class="margin-right" mat-icon-button style="align-self:flex-end;" - (click)="openConfirmDialog(keyword)"> - <mat-icon class="red">delete</mat-icon> - </button> - </div> + <button class="margin-right" mat-icon-button style="align-self:flex-end;" (click)="editKeyword()"> + <mat-icon class="primary">edit</mat-icon> + </button> + <button class="margin-right" mat-icon-button style="align-self:flex-end;" + (click)="openConfirmDialog(keyword)"> + <mat-icon class="red">delete</mat-icon> + </button> + </div> - <!-- Only visible when editing --> - <div *ngIf="edit"> - <mat-divider></mat-divider> + <!-- Only visible when editing --> + <div *ngIf="edit"> + <mat-divider></mat-divider> - <mat-form-field> - <mat-label>{{'topic-cloud-dialog.editkeyword-tipp' | translate}}</mat-label> - <input matInput #keywordInput [(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.keywordID)">{{'topic-cloud-dialog.save' | translate}}</button> - </div> + <mat-form-field> + <mat-label>{{'topic-cloud-dialog.editkeyword-tipp' | translate}}</mat-label> + <input matInput #keywordInput [(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.keywordID)">{{'topic-cloud-dialog.save' | translate}}</button> </div> + </div> - </mat-expansion-panel> - </mat-accordion> - </mat-dialog-content> + </mat-expansion-panel> + </mat-accordion> +</mat-dialog-content> 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 7cd9222bd970e088cd7041a03c42d337a4524dc5..9c8bdb6a76afe5060fbfb75744c26b9042f3b383 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 @@ -7,13 +7,6 @@ import { AuthenticationService } from '../../../../services/http/authentication. import { UserRole } from '../../../../models/user-roles.enum'; import { TranslateService } from '@ngx-translate/core'; import { LanguageService } from '../../../../services/util/language.service'; -import {FormControl} from "@angular/forms"; -import { SearchFilterPipe } from '../../../../pipe/search-filter.pipe'; -import { EventService } from '../../../../services/util/event.service'; -import {startWith, map, filter} from 'rxjs/operators'; -import {BehaviorSubject, Observable} from "rxjs"; - - @Component({ selector: 'app-topic-cloud-administration', @@ -31,24 +24,9 @@ export class TopicCloudAdministrationComponent implements OnInit { sortMode: SortMode = SortMode.ALPHABETIC; sortModeEnum: typeof SortMode = SortMode; // needed for use in template editedKeyword:boolean = false; - - keywordsSubject: BehaviorSubject<Keyword[]> = new BehaviorSubject<Keyword[]>([]); - - // public searchFilter: any = ''; - - control=new FormControl(); - searchInput = ''; - search = false; - hideKeyWordList=true; - newkey:Keyword[]; - - - searchPlaceholder = ''; - - - - - + searchedKeyword: string = ""; + hideKeywords: boolean = false; + filteredKeywords: Keyword[] = []; keywords: Keyword[] = [ { @@ -134,14 +112,12 @@ export class TopicCloudAdministrationComponent implements OnInit { } ngOnInit(): void { - this.keywordsSubject.next(this.keywords); this.translateService.use(localStorage.getItem('currentLang')); this.checkIfUserIsModOrCreator(); this.checkIfThereAreQuestions(); this.sortQuestions(); } - sortQuestions(sortMode?: SortMode) { if (sortMode !== undefined) { this.sortMode = sortMode; @@ -194,20 +170,11 @@ export class TopicCloudAdministrationComponent implements OnInit { } deleteKeyword(id: number): void{ - - this.keywords.map(keyword => { - if (keyword.keywordID == id) { - console.log("before" , this.keywords); - //console.log( this.keywords.splice(this.keywords.indexOf(keyword, 0), 1)); - this.keywords.splice(this.keywords.indexOf(keyword, 0), 1); - console.log("after" , this.keywords); - - } + if (keyword.keywordID == id) + this.keywords.splice(this.keywords.indexOf(keyword, 0), 1); }); if (this.keywords.length == 0) { - //console.log(this.cloudDialogRef.close()); - // this.keywords=this.newkey; this.cloudDialogRef.close(); } } @@ -239,35 +206,17 @@ export class TopicCloudAdministrationComponent implements OnInit { } }) } - searchComments(): void { - this.search = true; - if (this.searchInput) { - if (this.searchInput.length > 1) { - for (let keyword of this.keywords) { - this.keywords= this.keywords - .filter(c => this.checkIfIncludesKeyWord(c.keyword, this.searchInput)); - } - } else if (this.searchInput.length === 0 ) { - this.hideKeyWordList = false; - } + searchKeyword(): void{ + if (this.searchedKeyword === ''){ + this.hideKeywords = false; + } else{ + this.filteredKeywords = this.keywords.filter(keyword => + keyword.keyword.toLowerCase().includes(this.searchedKeyword) + ); + this.hideKeywords = true; } } - - checkIfIncludesKeyWord(body: string, keyword: string) { - return body.toLowerCase().includes(keyword.toLowerCase()); - } - - private _filter(value: string): Keyword[] { - const filterValue = this._normalizeValue(value); - - return this.keywords.filter(key => this._normalizeValue(key.keyword).includes(filterValue)); - } - - private _normalizeValue(value: string): string { - - return value.toLowerCase().replace(/\s/g, ''); - } } export enum SortMode { diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 2a5aebf6f24061f7ea3112c84679c93ee8e2b20d..0ba2b4cd88d899533ba19ff0c1ea56cf380e4245 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -98,7 +98,6 @@ export class CommentListComponent implements OnInit, OnDestroy { fromNow: number; moderatorIds: string[]; - constructor( private commentService: CommentService, private translateService: TranslateService, @@ -472,7 +471,6 @@ export class CommentListComponent implements OnInit, OnDestroy { this.currentFilter = ''; this.sortComments(this.currentSort); return; - } this.filteredComments = this.commentsFilteredByTime.filter(c => { switch (type) { diff --git a/src/app/components/shared/shared.module.ts b/src/app/components/shared/shared.module.ts index d8deca9b088016657d7f741ed3bde716f08f14c4..80e4999179ef44d0f585a40fcb29a7499767df2e 100644 --- a/src/app/components/shared/shared.module.ts +++ b/src/app/components/shared/shared.module.ts @@ -33,7 +33,6 @@ import { TagCloudModule } from 'angular-tag-cloud-module'; import { TopicCloudConfirmDialogComponent } from './_dialogs/topic-cloud-confirm-dialog/topic-cloud-confirm-dialog.component'; import { TopicCloudAdministrationComponent } from './_dialogs/topic-cloud-administration/topic-cloud-administration.component'; import { TopicDialogCommentComponent } from './dialog/topic-dialog-comment/topic-dialog-comment.component'; -import { SearchFilterPipe } from '../../pipe/search-filter.pipe'; @NgModule({ imports: [ @@ -44,7 +43,7 @@ import { SearchFilterPipe } from '../../pipe/search-filter.pipe'; ArsModule, MarkdownModule, QRCodeModule, - TagCloudModule, + TagCloudModule ], declarations: [ RoomJoinComponent, @@ -71,8 +70,7 @@ import { SearchFilterPipe } from '../../pipe/search-filter.pipe'; MotdMessageComponent, TopicCloudConfirmDialogComponent, TopicCloudAdministrationComponent, - TopicDialogCommentComponent, - SearchFilterPipe + TopicDialogCommentComponent ], exports: [ RoomJoinComponent, @@ -88,7 +86,6 @@ import { SearchFilterPipe } from '../../pipe/search-filter.pipe'; CommentComponent, DialogActionButtonsComponent, UserBonusTokenComponent, - SearchFilterPipe ] }) export class SharedModule { diff --git a/src/app/pipe/search-filter.pipe.spec.ts b/src/app/pipe/search-filter.pipe.spec.ts deleted file mode 100644 index d4dcbe54343d0310eb0c0a703f29deda70a1beab..0000000000000000000000000000000000000000 --- a/src/app/pipe/search-filter.pipe.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { SearchFilterPipe } from './search-filter.pipe'; - -describe('SearchFilterPipe', () => { - it('create an instance', () => { - const pipe = new SearchFilterPipe(); - expect(pipe).toBeTruthy(); - }); -}); diff --git a/src/app/pipe/search-filter.pipe.ts b/src/app/pipe/search-filter.pipe.ts deleted file mode 100644 index 49429e492d18425d06df710516b12c7f895de9d1..0000000000000000000000000000000000000000 --- a/src/app/pipe/search-filter.pipe.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; - -@Pipe({ - name: 'searchFilter' -}) - - -export class SearchFilterPipe implements PipeTransform { - - // TOO: import a specific type Keyword for safety - transform(value: any[], args?: any): any[] { - if(!value) return null; - if(!args) return value; - - args = args.toLowerCase(); - - console.log("Filtering ", value, "after", args) - - return value.filter(function(data){ - return data.keyword.toLowerCase().includes(args); - }); - } - -} diff --git a/src/assets/i18n/home/de.json b/src/assets/i18n/home/de.json index 3c77f80ca70ed8e7506f56f4002bbb4e4a8b7c27..1a3f345777495449273025c247fe33a1ebd541f4 100644 --- a/src/assets/i18n/home/de.json +++ b/src/assets/i18n/home/de.json @@ -305,7 +305,8 @@ "nokeyword-note": "Es gibt keine Themen", "considerVotes": "Votes berücksichtigen", "sort-Alpha": "alphabetisch", - "sort-Count": "Fragenanzahl" + "sort-Count": "Fragenanzahl", + "keyword-search": "Keyword suchen" }, "topic-cloud-confirm-dialog":{ "cancel": "abbrechen", diff --git a/src/assets/i18n/home/en.json b/src/assets/i18n/home/en.json index 61c0c4ca80318854329145762af2a9f3e2c00c67..0f230a058d0f8482194fa9b0b81efb4ed2e64913 100644 --- a/src/assets/i18n/home/en.json +++ b/src/assets/i18n/home/en.json @@ -308,7 +308,8 @@ "nokeyword-note": "there are no topics!", "considerVotes": "Consider Votes", "sort-Alpha": "Alphabetically", - "sort-Count": "questions count" + "sort-Count": "questions count", + "keyword-search": "search keyword" }, "topic-cloud-confirm-dialog":{ "cancel": "cancel", diff --git a/src/assets/i18n/participant/de.json b/src/assets/i18n/participant/de.json index 1ee55c1b65fa6775cbd6e652f03027eea8ff7a12..54fff81c08f28a17e61ab277ddcec177ec873932 100644 --- a/src/assets/i18n/participant/de.json +++ b/src/assets/i18n/participant/de.json @@ -228,7 +228,8 @@ "considerVotes": "Votes berücksichtigen", "tags-lowercase": "Themen klein schreiben", "sort-Alpha": "Alphabetisch", - "sort-Count": "Fragenanzahl" + "sort-Count": "Fragenanzahl", + "keyword-search": "keyword suchen" }, "topic-cloud-confirm-dialog":{ "cancel": "Abbrechen", diff --git a/src/assets/i18n/participant/en.json b/src/assets/i18n/participant/en.json index 85051cf0a37a6e294f6a3beb6665525fd86a74d8..c57489bbd03778f4e1b452c208274d6624afaeb3 100644 --- a/src/assets/i18n/participant/en.json +++ b/src/assets/i18n/participant/en.json @@ -234,7 +234,8 @@ "considerVotes": "Consider Votes", "tags-lowercase": "Topics in lowercase", "sort-Alpha": "Alphabetically", - "sort-Count": "Questions count" + "sort-Count": "Questions count", + "keyword-search": "search keyword" }, "topic-cloud-confirm-dialog":{ "cancel": "Cancel",