Files
brewman/overlord/src/app/unposted/unposted.component.ts
tanshu 2972203148 Removed the use of any and enabled the rule in eslint.
Now according to me the conversion is final.
Testing is required.
2020-11-24 08:03:43 +05:30

64 lines
1.7 KiB
TypeScript

import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { ActivatedRoute, Router } from '@angular/router';
import { Unposted } from './unposted';
import { UnpostedDataSource } from './unposted-datasource';
import { UnpostedService } from './unposted.service';
@Component({
selector: 'app-unposted',
templateUrl: './unposted.component.html',
styleUrls: ['./unposted.component.css'],
})
export class UnpostedComponent implements OnInit {
@ViewChild(MatPaginator, { static: true }) paginator?: MatPaginator;
@ViewChild(MatSort, { static: true }) sort?: MatSort;
info: Unposted[] = [];
dataSource: UnpostedDataSource = new UnpostedDataSource(this.info);
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = [
'date',
'voucherType',
'narration',
'debitName',
'debitAmount',
'creditName',
'creditAmount',
];
panelOpenState = false;
unposted: boolean | undefined = undefined;
constructor(
private route: ActivatedRoute,
private router: Router,
private ser: UnpostedService,
) {}
ngOnInit() {
this.route.data.subscribe((value) => {
const data = value as { info: Unposted[] };
this.info = data.info;
});
this.dataSource = new UnpostedDataSource(this.info, this.paginator, this.sort);
}
refresh() {
this.ser.list().subscribe((info: Unposted[]) => {
this.info = info;
});
}
toggleUnposted() {
if (this.unposted === undefined) {
this.unposted = false;
} else if (!this.unposted) {
this.unposted = true;
} else {
this.unposted = undefined;
}
}
}