Skip to content

Commit

Permalink
Merge 3faf541 into 0ad510c
Browse files Browse the repository at this point in the history
  • Loading branch information
anandsinghparihar committed Jan 5, 2018
2 parents 0ad510c + 3faf541 commit bc379d4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
<div fxLayout="row" fxLayoutGap="35px">

<mat-form-field fxFlex="1 1 100%" class="search-address">
<input matInput type="text" name="query" placeholder="Filter by label or address..." [(ngModel)]="query">
<input matInput type="text" name="query" (ngModelChange)="resetPagination()"
placeholder="Filter by label or address..." [(ngModel)]="query">
</mat-form-field>

<mat-select fxFlex="1 0 130px" name="filter" [(ngModel)]="filter" class="address-type uc-first" *ngIf="allowFilter">
<mat-select fxFlex="1 0 130px" name="filter" [(ngModel)]="filter" class="address-type uc-first"
*ngIf="allowFilter">
<mat-option *ngFor="let addressType of addressTypes" [value]="addressType">
{{ addressType }}
</mat-option>
Expand Down Expand Up @@ -45,6 +47,7 @@
</mat-list>

<app-paginator
#paginator
[length]="getTotalCountForPagination()"
[pageSize]="MAX_ADDRESSES_PER_PAGE"
(page)="pageChanged($event)">
Expand Down
10 changes: 9 additions & 1 deletion src/app/wallet/wallet/addresslookup/addresslookup.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
import { RpcService } from '../../../core/core.module';

import { Contact } from './contact.model';
Expand All @@ -15,6 +15,8 @@ export class AddressLookupComponent implements OnInit {

@Output() selectAddressCallback: EventEmitter<AddressLookUpCopy> = new EventEmitter<AddressLookUpCopy>();

@ViewChild('paginator') paginator: any;

log: any = Log.create('addresslookup.component');

filter: string = 'All types';
Expand Down Expand Up @@ -123,4 +125,10 @@ export class AddressLookupComponent implements OnInit {
this.dialogRef.close();
}

// Reset pagination
resetPagination(): void {
this.current_page = 1;
this.paginator.resetPagination(0);
}

}
2 changes: 1 addition & 1 deletion src/app/wallet/wallet/receive/receive.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
<mat-form-field class="icon-input search-address" fxFlex="0 1 400px" (click)="selectInput()">
<input matInput type="text" class="header-input" id="searchbar" [(ngModel)]="query"
placeholder="Search receive addresses">
placeholder="Search receive addresses" (ngModelChange)="resetPagination()">
<mat-icon fontSet="partIcon" fontIcon="part-search" matTooltip="Search For Address"
matTooltipPosition="after"></mat-icon>
</mat-form-field>
Expand Down
13 changes: 9 additions & 4 deletions src/app/wallet/wallet/receive/receive.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ export class ReceiveComponent implements OnInit {

if (this.inSearchMode()) {
type = 'query';
if (this.paginator) {
this.page = 1;
this.paginator.resetPagination(0);
}

this.addresses.query = this.addresses[this.type].filter(el => {
if (el) {
return (
Expand All @@ -84,6 +81,14 @@ export class ReceiveComponent implements OnInit {
);
}

// Reset pagination
resetPagination(): void {
if (this.paginator) {
this.page = 1;
this.paginator.resetPagination(0);
}
}

/** Returns the unused addresses to display in the UI. */
getUnusedAddress(): Object {
return this.addresses[this.type][0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
import { Component, OnInit, Input, Output, EventEmitter, ViewChild, OnChanges } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { MatDialog } from '@angular/material';
import { Log } from 'ng2-logger';
Expand All @@ -19,7 +19,7 @@ import { SignatureAddressModalComponent } from '../signature-address-modal/signa
templateUrl: './address-table.component.html',
styleUrls: ['./address-table.component.scss']
})
export class AddressTableComponent implements OnInit {
export class AddressTableComponent implements OnInit, OnChanges {

// Determines what fields are displayed in the Transaction Table.
// header and utils
Expand Down Expand Up @@ -74,19 +74,27 @@ export class AddressTableComponent implements OnInit {
error => console.log('addresstable-component subscription error:' + error));
}

ngOnChanges(): void {
this.resetPagination();
}

/** Returns the addresses to display in the UI with regards to both pagination and search/query. */
public getSinglePage(): Array<Address> {
if (this.inSearchMode()) { // in search mode
if (this.paginator) {
this.currentPage = 1;
this.paginator.resetPagination(0);
}
return this.paginateArray(this.getSearchSubset());
} else { // not in seach mode
return this.paginateArray(this.addresses);
}
}

// Reset pagination
resetPagination(): void {
if (this.paginator) {
this.currentPage = 1;
this.paginator.resetPagination(0);
}
}

private inSearchMode(): boolean {
return (this.query !== undefined && this.query !== '');
}
Expand Down

0 comments on commit bc379d4

Please sign in to comment.