aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-16 14:47:05 +0100
committerChocobozzz <me@florianbigard.com>2020-11-16 14:47:05 +0100
commit5ed46c1bce29affbe101f126d58657ab484bffe7 (patch)
tree019b1649facdefea85eb2cb490a485a5fbf83c64 /client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
parent7706b3703aeb2bea686b12089959b963a7dd89f4 (diff)
downloadPeerTube-5ed46c1bce29affbe101f126d58657ab484bffe7.tar.gz
PeerTube-5ed46c1bce29affbe101f126d58657ab484bffe7.tar.zst
PeerTube-5ed46c1bce29affbe101f126d58657ab484bffe7.zip
Refactor rest table search filter
Diffstat (limited to 'client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts')
-rw-r--r--client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts34
1 files changed, 5 insertions, 29 deletions
diff --git a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
index d26047125..284ec541d 100644
--- a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
+++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
@@ -14,6 +14,8 @@ import { FeedFormat, UserRight } from '@shared/models'
14 styleUrls: [ '../../../shared/shared-moderation/moderation.scss', './video-comment-list.component.scss' ] 14 styleUrls: [ '../../../shared/shared-moderation/moderation.scss', './video-comment-list.component.scss' ]
15}) 15})
16export class VideoCommentListComponent extends RestTable implements OnInit, AfterViewInit { 16export class VideoCommentListComponent extends RestTable implements OnInit, AfterViewInit {
17 baseRoute = '/admin/moderation/video-comments/list'
18
17 comments: VideoCommentAdmin[] 19 comments: VideoCommentAdmin[]
18 totalRecords = 0 20 totalRecords = 0
19 sort: SortMeta = { field: 'createdAt', order: -1 } 21 sort: SortMeta = { field: 'createdAt', order: -1 }
@@ -44,13 +46,13 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
44 } 46 }
45 47
46 constructor ( 48 constructor (
49 protected router: Router,
50 protected route: ActivatedRoute,
47 private auth: AuthService, 51 private auth: AuthService,
48 private notifier: Notifier, 52 private notifier: Notifier,
49 private confirmService: ConfirmService, 53 private confirmService: ConfirmService,
50 private videoCommentService: VideoCommentService, 54 private videoCommentService: VideoCommentService,
51 private markdownRenderer: MarkdownService, 55 private markdownRenderer: MarkdownService,
52 private route: ActivatedRoute,
53 private router: Router,
54 private bulkService: BulkService 56 private bulkService: BulkService
55 ) { 57 ) {
56 super() 58 super()
@@ -75,39 +77,13 @@ export class VideoCommentListComponent extends RestTable implements OnInit, Afte
75 77
76 ngOnInit () { 78 ngOnInit () {
77 this.initialize() 79 this.initialize()
78 80 this.listenToSearchChange()
79 this.route.queryParams
80 .pipe(filter(params => params.search !== undefined && params.search !== null))
81 .subscribe(params => {
82 this.search = params.search
83 this.setTableFilter(params.search)
84 this.loadData()
85 })
86 } 81 }
87 82
88 ngAfterViewInit () { 83 ngAfterViewInit () {
89 if (this.search) this.setTableFilter(this.search) 84 if (this.search) this.setTableFilter(this.search)
90 } 85 }
91 86
92 onInputSearch (event: Event) {
93 this.onSearch(event)
94 this.setQueryParams((event.target as HTMLInputElement).value)
95 }
96
97 setQueryParams (search: string) {
98 const queryParams: Params = {}
99
100 if (search) Object.assign(queryParams, { search })
101 this.router.navigate([ '/admin/moderation/video-comments/list' ], { queryParams })
102 }
103
104 resetTableFilter () {
105 this.setTableFilter('')
106 this.setQueryParams('')
107 this.resetSearch()
108 }
109 /* END Table filter functions */
110
111 getIdentifier () { 87 getIdentifier () {
112 return 'VideoCommentListComponent' 88 return 'VideoCommentListComponent'
113 } 89 }