diff --git a/src/app/components/shared/comment-list/comment-list.component.html b/src/app/components/shared/comment-list/comment-list.component.html index 2a231bc25557b2d4ab86693122dc9ff9713d1740..47ced959bb8c89ec18f8cdb825f59157f3b49bf6 100644 --- a/src/app/components/shared/comment-list/comment-list.component.html +++ b/src/app/components/shared/comment-list/comment-list.component.html @@ -253,7 +253,8 @@ [user]="user" [disabled]="!commentsEnabled" (clickedOnTag)="clickedOnTag($event)" - (clickedUserNumber)="clickedUserNumber($event)"> + (clickedUserNumber)="clickedUserNumber($event)" + (clickedOnKeyword)="clickedOnKeyword($event)"> </app-comment> </div> 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 df09d1a86e928654615bb716e6e5762770180744..24dd7916d4b157200cacdf367f44199b810d462e 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -78,7 +78,10 @@ export class CommentListComponent implements OnInit, OnDestroy { moderator = 'moderator'; lecturer = 'lecturer'; tag = 'tag'; + selectedTag = ''; userNumber = 'userNumber'; + keyword = 'keyword'; + selectedKeyword = ''; answer = 'answer'; unanswered = 'unanswered'; owner = 'owner'; @@ -258,6 +261,8 @@ export class CommentListComponent implements OnInit, OnDestroy { filter.filterSelected = this.currentFilter; filter.paused = this.freeze; filter.periodSet = this.period; + filter.keywordSelected = this.selectedKeyword; + filter.tagSelected = this.selectedTag; if (filter.periodSet == Period.FROMNOW) { filter.timeStampNow = new Date().getTime(); @@ -495,6 +500,7 @@ export class CommentListComponent implements OnInit, OnDestroy { this.sortComments(this.currentSort); return; } + console.log(compare); this.filteredComments = this.commentsFilteredByTime.filter(c => { switch (type) { case this.correct: @@ -510,9 +516,13 @@ export class CommentListComponent implements OnInit, OnDestroy { case this.unread: return !c.read; case this.tag: + this.selectedTag = compare; return c.tag === compare; case this.userNumber: return c.userNumber === compare; + case this.keyword: + this.selectedKeyword = compare; + return c.keywords != null ? c.keywords.includes(compare) : false; case this.answer: return c.answer; case this.unanswered: @@ -564,6 +574,10 @@ export class CommentListComponent implements OnInit, OnDestroy { this.filterComments(this.tag, tag); } + clickedOnKeyword(keyword: string): void { + this.filterComments(this.keyword, keyword); + } + clickedUserNumber(usrNumber: number): void { this.filterComments(this.userNumber, usrNumber); } @@ -575,7 +589,7 @@ export class CommentListComponent implements OnInit, OnDestroy { this.notificationService.show(msg); }); - let filter = CommentFilterOptions.generateFilterUntil(this.currentFilter, this.period, new Date().getTime()); + let filter = CommentFilterOptions.generateFilterUntil(this.currentFilter, this.period, new Date().getTime(), this.selectedTag, this.selectedKeyword); filter.writeFilter(); } diff --git a/src/app/components/shared/comment/comment.component.html b/src/app/components/shared/comment/comment.component.html index 6a509b76846379d666f6f38c5d6acea5a62b76cc..9883190bfbb4899063a78e6857db95fe59e1e4a4 100644 --- a/src/app/components/shared/comment/comment.component.html +++ b/src/app/components/shared/comment/comment.component.html @@ -324,15 +324,15 @@ class="comment-keywords"> <mat-icon svgIcon="comment_tag"></mat-icon> <span> - {{ 'comment-page.keywords' | translate }} + {{ this.selectedKeyword === '' ? ('comment-page.keywords' | translate ) : this.selectedKeyword}} </span> <mat-menu #keywordsMenu> <mat-list dense class="keywords-list"> <mat-list-item *ngFor="let keyword of comment.keywords; let odd = odd; let even = even" [class.keywords-alternate]="odd" - [class.keywords-even]="even"> - <span class="keyword-span">{{keyword}}</span> + [class.keywords-even]="even"> + <span (click)="this.clickedOnKeyword.emit(keyword)" class="keyword-span">{{keyword}}</span> </mat-list-item> </mat-list> </mat-menu> diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index 6943f71cf754333dfac1d13ff49efc176e50fe98..9e316cf823c1665625ed416eb3a20b7cd41cf157 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -42,6 +42,7 @@ export class CommentComponent implements OnInit, AfterViewInit { @Input() user: User; @Input() disabled = false; @Output() clickedOnTag = new EventEmitter<string>(); + @Output() clickedOnKeyword = new EventEmitter<string>(); @Output() clickedUserNumber = new EventEmitter<number>(); isStudent = false; isCreator = false; @@ -58,6 +59,7 @@ export class CommentComponent implements OnInit, AfterViewInit { @ViewChild('commentExpander', { static: true })commentExpander: RowComponent; isExpanded = false; isExpandable = false; + selectedKeyword: string = ''; constructor(protected authenticationService: AuthenticationService, private route: ActivatedRoute, diff --git a/src/app/utils/filter-comments.ts b/src/app/utils/filter-comments.ts index d23b880587dcc85657f9f289b7217a56ebe7dae6..103a381b434b7c912ff266ff2d9e5433efdcd0a9 100644 --- a/src/app/utils/filter-comments.ts +++ b/src/app/utils/filter-comments.ts @@ -70,6 +70,13 @@ export class CommentFilterUtils { } } + if (filter.keywordSelected != '') { + return com.keywords.includes(filter.keywordSelected); + } + if (filter.tagSelected != ''){ + return com.tag === filter.tagSelected; + } + return true; } diff --git a/src/app/utils/filter-options.ts b/src/app/utils/filter-options.ts index 0aae11a6db36e1cec60f307f021f76d62fc1c583..e00ed0f05ea143ef9ab39fb65c74e4aafeec6f73 100644 --- a/src/app/utils/filter-options.ts +++ b/src/app/utils/filter-options.ts @@ -14,6 +14,8 @@ export const enum FilterNames { export class CommentFilterOptions { filterSelected : string; + keywordSelected : string; + tagSelected : string; paused: boolean; timeStampUntil : number; @@ -23,6 +25,8 @@ export class CommentFilterOptions { constructor() { this.filterSelected = ''; + this.keywordSelected = ''; + this.tagSelected = ''; this.paused = false; this.periodSet = Period.ALL; } @@ -46,19 +50,25 @@ export class CommentFilterOptions { filter.filterSelected = filterSelected; filter.paused = false; + filter.tagSelected = ''; + filter.keywordSelected = ''; + filter.periodSet = Period.FROMNOW; filter.timeStampNow = new Date().getTime(); return filter; } - public static generateFilterUntil(filterSelected : string, periodSelected : Period, untilTime : number) : CommentFilterOptions { + public static generateFilterUntil(filterSelected : string, periodSelected : Period, untilTime : number, tagSelected : string, keywordSelected : string) : CommentFilterOptions { let filter = new CommentFilterOptions(); filter.filterSelected = filterSelected; filter.paused = true; filter.timeStampUntil = untilTime; + + filter.tagSelected = tagSelected; + filter.keywordSelected = keywordSelected; filter.periodSet = periodSelected;