From 7eef95353f9202e1f3285606282fc8fd904c90ef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Aug 2016 19:05:52 +0200 Subject: Client: reset pagination when we search something --- client/src/app/videos/video-list/video-list.component.ts | 10 ++++++++-- client/tsconfig.json | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts index 062340ec5..7c6d4b992 100644 --- a/client/src/app/videos/video-list/video-list.component.ts +++ b/client/src/app/videos/video-list/video-list.component.ts @@ -66,6 +66,8 @@ export class VideoListComponent implements OnInit, OnDestroy { // Subscribe to search changes this.subSearch = this.searchService.searchUpdated.subscribe(search => { this.search = search; + // Reset pagination + this.pagination.currentPage = 1; this.navigateToNewParams(); }); @@ -76,7 +78,7 @@ export class VideoListComponent implements OnInit, OnDestroy { this.subSearch.unsubscribe(); } - getVideos(detectChanges = true) { + getVideos() { this.loading.next(true); this.videos = []; @@ -153,7 +155,11 @@ export class VideoListComponent implements OnInit, OnDestroy { this.sort = routeParams['sort'] || '-createdDate'; - this.pagination.currentPage = parseInt(routeParams['page']) || 1; + if (routeParams['page'] !== undefined) { + this.pagination.currentPage = parseInt(routeParams['page']); + } else { + this.pagination.currentPage = 1; + } this.changeDetector.detectChanges(); } diff --git a/client/tsconfig.json b/client/tsconfig.json index 7de2a1a75..20938ce55 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -35,12 +35,12 @@ "src/app/admin/admin.routes.ts", "src/app/admin/friends/friend-list/friend-list.component.ts", "src/app/admin/friends/friend-list/index.ts", + "src/app/admin/friends/friends.component.ts", "src/app/admin/friends/friends.routes.ts", "src/app/admin/friends/index.ts", "src/app/admin/friends/shared/friend.model.ts", "src/app/admin/friends/shared/friend.service.ts", "src/app/admin/friends/shared/index.ts", - "src/app/admin/friends/users.component.ts", "src/app/admin/index.ts", "src/app/admin/menu-admin.component.ts", "src/app/admin/users/index.ts", -- cgit v1.2.3