Skip to content

Commit

Permalink
Add text search timers to all list pages
Browse files Browse the repository at this point in the history
  • Loading branch information
dhlevi committed Oct 11, 2023
1 parent f4f8d07 commit d0223eb
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="table-search-header flex-y-fixed">
<div class="search-and-filters">
<div class="field search-input">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="search()">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="searchByText()">
<button mat-mdc-button matSuffix mat-mdc-icon-button class="input-clear-button" *ngIf="searchText"
aria-label="Clear" (click)="searchText=undefined; search(); $event.stopPropagation()"
aria-label="Clear" (click)="searchText=undefined; searchByText(); $event.stopPropagation()"
matTooltip="Clear">
<span class="button-wrapper">
<mat-icon>close</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="search-and-filters">
<div class="field search-input">
<mat-icon class="search-icon" matSuffix>search</mat-icon>
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="search()">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="searchByText()">
</div>
<button mat-fab matTooltip="Filter by Location" class="filter-button"
aria-label="By Location" (click)="searchByLocation(); $event.stopPropagation()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AreaRestrictionListComponent implements OnInit {
public selectedSortOrder = 'DESC'
public sortOptions = [{ description: 'Fire Centre', code: 'fireCentre'}, { description: 'Name', code: 'name'}, { description: 'Issued On', code: 'issuedOn'}]
public searchText

public searchTimer
columnsToDisplay = ["name", "issuedOn", "fireCentre", "distance", "viewMap", "details"];

constructor ( private agolService: AGOLService, private cdr: ChangeDetectorRef, private commonUtilityService: CommonUtilityService ) {}
Expand Down Expand Up @@ -87,4 +87,15 @@ export class AreaRestrictionListComponent implements OnInit {
sortData (event: any) {
this.cdr.detectChanges()
}

searchByText() {
if (this.searchTimer) {
clearTimeout(this.searchTimer)
this.searchTimer = null
}

this.searchTimer = setTimeout(() => {
this.search()
}, 1000)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="table-search-header flex-y-fixed">
<div class="search-and-filters">
<div class="field search-input">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="search()">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="searchByText()">
<button mat-mdc-button matSuffix mat-mdc-icon-button class="input-clear-button" *ngIf="searchText"
aria-label="Clear" (click)="searchText=undefined; search(); $event.stopPropagation()"
aria-label="Clear" (click)="searchText=undefined; searchByText(); $event.stopPropagation()"
matTooltip="Clear">
<span class="button-wrapper">
<mat-icon>close</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="search-and-filters">
<div class="field search-input">
<mat-icon class="search-icon" matSuffix>search</mat-icon>
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="search()">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="searchByText()">
</div>
<button mat-fab matTooltip="Filter by Location" class="filter-button"
aria-label="By Location" (click)="searchByLocation(); $event.stopPropagation()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class BansListComponent implements OnInit {
public category1 = true
public category2 = true
public category3 = true

public searchTimer
columnsToDisplay = ["fireCentre", "type", "details", "issuedOn", "viewMap", "fullDetails"];

constructor ( private agolService: AGOLService, private cdr: ChangeDetectorRef ) {}
Expand Down Expand Up @@ -102,4 +102,15 @@ export class BansListComponent implements OnInit {
sortData (event: any) {
this.cdr.detectChanges()
}

searchByText() {
if (this.searchTimer) {
clearTimeout(this.searchTimer)
this.searchTimer = null
}

this.searchTimer = setTimeout(() => {
this.search()
}, 1000)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="table-search-header flex-y-fixed">
<div class="search-and-filters">
<div class="field search-input">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="search()">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="searchByText()">
<button mat-mdc-button matSuffix mat-mdc-icon-button class="input-clear-button" *ngIf="searchText"
aria-label="Clear" (click)="searchText=undefined; search(); $event.stopPropagation()"
aria-label="Clear" (click)="searchText=undefined; searchByText(); $event.stopPropagation()"
matTooltip="Clear">
<span class="button-wrapper">
<mat-icon>close</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="search-and-filters">
<div class="field search-input">
<mat-icon class="search-icon" matSuffix>search</mat-icon>
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="search()">
<input matInput class="search-input" aria-label="Search" placeholder=" Search" [(ngModel)]="searchText" (ngModelChange)="searchByText()">
</div>
<button mat-fab matTooltip="Filter by Location" class="filter-button"
aria-label="By Location" (click)="searchByLocation(); $event.stopPropagation()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class EvacListComponent implements OnInit {
public selectedSortOrder = 'DESC'
public sortOptions = [{ description: 'Name', code: 'name'}, { description: 'Status', code: 'status'}, { description: 'Agency', code: 'agency'}, { description: 'Issued On', code: 'issuedOn'}]
public searchText

public searchTimer
public order = true
public alert = true

Expand Down Expand Up @@ -112,4 +112,15 @@ export class EvacListComponent implements OnInit {
sortData (event: any) {
this.cdr.detectChanges()
}

searchByText() {
if (this.searchTimer) {
clearTimeout(this.searchTimer)
this.searchTimer = null
}

this.searchTimer = setTimeout(() => {
this.search()
}, 1000)
}
}

0 comments on commit d0223eb

Please sign in to comment.