Skip to content

Commit

Permalink
fix(list-view): let table back to first page after jump
Browse files Browse the repository at this point in the history
for fixing pagination error
  • Loading branch information
ElonH committed May 28, 2020
1 parent 38f8326 commit 5f3e51b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/app/pages/manager/fileMode/listView/listView.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import {
Component,
OnInit,
OnDestroy,
Input,
Output,
EventEmitter,
ViewChild,
} from '@angular/core';
import { Columns, Config, DefaultConfig } from 'ngx-easy-table';
import { OperationsListFlowOutItemNode, OperationsListFlow } from 'src/app/@dataflow/rclone';
import { Subscription } from 'rxjs';
import { NavigationFlowOutNode } from 'src/app/@dataflow/extra';
import { API, APIDefinition } from 'ngx-easy-table';

@Component({
selector: 'manager-listView',
template: `
<ngx-table
#table
[configuration]="configuration"
[data]="data"
[columns]="columns"
Expand All @@ -23,6 +33,14 @@ export class ListViewComponent implements OnInit, OnDestroy {

public data: OperationsListFlowOutItemNode[];

@ViewChild('table') table: APIDefinition;
resetCurrentPage() {
this.table.apiEvent({
type: API.setPaginationCurrentPage,
value: 1,
});
}

constructor() {}

@Output() jump = new EventEmitter<NavigationFlowOutNode>();
Expand All @@ -34,6 +52,7 @@ export class ListViewComponent implements OnInit, OnDestroy {
const item = $event.value.row;
if (item.IsDir) {
this.jump.emit({ remote: this.remote, path: item.Path });
this.resetCurrentPage();
}
}
}
Expand Down Expand Up @@ -64,5 +83,6 @@ export class ListViewComponent implements OnInit, OnDestroy {
private listScrb: Subscription;
ngOnDestroy() {
this.listScrb.unsubscribe();
this.resetCurrentPage();
}
}

0 comments on commit 5f3e51b

Please sign in to comment.