---- Pending * Table width for the points column in incentive * Linting * keyboard navigation where it was used earlier * can remove the unused totals calculated serverside in productledger * spinner and loading bars * Activate Guard for Employee Function tabs * Progress for Fingerprint uploads * deleted reconcile and receipe features as they were not being used * focus the right control on component load
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
|
import {MatPaginator, MatSort} from '@angular/material';
|
|
import {AccountListDataSource} from './account-list-datasource';
|
|
import {Account} from '../account';
|
|
import {ActivatedRoute} from '@angular/router';
|
|
import {Observable} from 'rxjs';
|
|
import {FormBuilder, FormGroup} from '@angular/forms';
|
|
import {debounceTime, distinctUntilChanged, startWith} from 'rxjs/operators';
|
|
|
|
@Component({
|
|
selector: 'app-account-list',
|
|
templateUrl: './account-list.component.html',
|
|
styleUrls: ['./account-list.component.css']
|
|
})
|
|
export class AccountListComponent implements OnInit, AfterViewInit {
|
|
@ViewChild('filterElement') filterElement: ElementRef;
|
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
|
@ViewChild(MatSort) sort: MatSort;
|
|
dataSource: AccountListDataSource;
|
|
filter: Observable<string>;
|
|
form: FormGroup;
|
|
list: Account[];
|
|
|
|
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
|
displayedColumns = ['name', 'type', 'isActive', 'isReconcilable', 'costCentre'];
|
|
|
|
constructor(private route: ActivatedRoute, private fb: FormBuilder) {
|
|
this.createForm();
|
|
this.filter = this.listenToFilterChange();
|
|
}
|
|
|
|
createForm() {
|
|
this.form = this.fb.group({
|
|
filter: ''
|
|
});
|
|
}
|
|
|
|
listenToFilterChange() {
|
|
return this.form.get('filter').valueChanges
|
|
.pipe(
|
|
startWith(''),
|
|
debounceTime(150),
|
|
distinctUntilChanged()
|
|
);
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.route.data
|
|
.subscribe((data: { list: Account[] }) => {
|
|
this.list = data.list;
|
|
});
|
|
this.dataSource = new AccountListDataSource(this.paginator, this.sort, this.filter, this.list);
|
|
}
|
|
|
|
ngAfterViewInit() {
|
|
setTimeout(() => {
|
|
this.filterElement.nativeElement.focus();
|
|
}, 0);
|
|
}
|
|
}
|