Skip to content

Commit

Permalink
Merge pull request #175 from KB-iGOT/search-issue-fix
Browse files Browse the repository at this point in the history
search issue fix
  • Loading branch information
vishnubansaltarento authored Feb 15, 2025
2 parents a80db06 + 97297d5 commit c60cb0c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class UserCardComponent implements OnInit, OnChanges, AfterViewChecked, A
@Input() activeTab: any
@Input() forMentor = false
@Input() pendingApprovals?: any = []
@Input() resetPagination?: any = {}
@Output() paginationData = new EventEmitter()
@Output() searchByEnterKey = new EventEmitter()
@Output() disableButton = new EventEmitter()
Expand Down Expand Up @@ -243,6 +244,12 @@ export class UserCardComponent implements OnInit, OnChanges, AfterViewChecked, A
this.getApprovalData()
}
}
if (Object.keys(this.resetPagination).length) {
if (this.paginator) {
this.paginator.pageIndex = 0
// this.onChangePage(this.resetPagination)
}
}
}

ngAfterViewChecked() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
<ws-widget-user-card [currentFilter]="currentFilter" [usersData]="profileVerificationData"
[isApprovals]="true" [totalRecords]="totalProfileVerificationRecords" [tabChangeIndex]="pageIndex"
(searchByEnterKey)="onEnterkySearch($event)" (disableButton)="showButton()"
(paginationData)="onPaginateChange($event)" (updateList)="fetchApprovals()"></ws-widget-user-card>
(paginationData)="onPaginateChange($event)" (updateList)="fetchApprovals()"
[resetPagination]="resetPagination"></ws-widget-user-card>
</ng-container>
<ng-container *ngIf="totalProfileVerificationRecords === 0">
<p class="margin-top-xl margin-bottom-xl">No approvals</p>
Expand All @@ -71,7 +72,8 @@
<ws-widget-user-card [currentFilter]="currentFilter" [usersData]="transfersData" [isApprovals]="true"
[totalRecords]="totalTransfersRecords" [tabChangeIndex]="pageIndex"
(searchByEnterKey)="onEnterkySearch($event)" (disableButton)="showButton()"
(paginationData)="onPaginateChange($event)" (updateList)="fetchTransfers()"></ws-widget-user-card>
(paginationData)="onPaginateChange($event)" (updateList)="fetchTransfers()"
[resetPagination]="resetPagination"></ws-widget-user-card>
</ng-container>
<ng-container *ngIf="totalTransfersRecords === 0">
<p class="margin-top-xl margin-bottom-xl">No transfers</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class ApprovalPendingComponent implements OnInit, OnDestroy {
cacheOffset: any = 0
searchfilterValue = ''

resetPagination: any = {}
constructor(
private router: Router,
private apprService: ApprovalsService,
Expand Down Expand Up @@ -98,7 +99,20 @@ export class ApprovalPendingComponent implements OnInit, OnDestroy {

filter(key: string | 'timestamp' | 'best' | 'saved') {
this.tabChange = 1
if (key) {
if (key !== this.currentFilter) {
this.searchfilterValue = ''
this.currentFilter = key
this.pageIndex = 0
this.currentOffset = 0
this.limit = 20
if (key === 'profileverification') {
this.fetchApprovals('')
} else if (key === 'transfers') {
this.fetchTransfers(1)
}
}
else if (key) {

this.currentFilter = key
this.pageIndex = 0
this.currentOffset = 0
Expand Down Expand Up @@ -333,6 +347,15 @@ export class ApprovalPendingComponent implements OnInit, OnDestroy {
}

onSearch(enterValue: any) {
this.pageIndex = 0
this.currentOffset = 0
this.limit = 20
if (this.currentFilter === 'profileverification') {
this.resetPagination = { pageIndex: this.pageIndex, pageSize: this.limit, length: this.totalProfileVerificationRecords }
} else if (this.currentFilter === 'transfers') {
this.resetPagination = { pageIndex: this.pageIndex, pageSize: this.limit, length: this.totalTransfersRecords }
}

this.searchfilterValue = enterValue.searchText.toLowerCase() ? enterValue.searchText : ''
this.getSortOrderValue = this.getSortOrder(enterValue.sortOrder)
if (this.getSortOrderValue && this.currentFilter === 'profileverification') {
Expand All @@ -352,6 +375,7 @@ export class ApprovalPendingComponent implements OnInit, OnDestroy {
onPaginateChange(event: PageEvent) {
this.pageIndex = event.pageIndex
this.limit = event.pageSize
this.resetPagination = {}
// Clear the cache only for the current tab
const cacheKey = `${this.currentFilter}DataCache`
const cacheTimestampKey = `${this.currentFilter}CacheTimestamp`
Expand Down

0 comments on commit c60cb0c

Please sign in to comment.