Updated to angular 11

Now compiling with strict mode in typescript
Need to error checking now
This commit is contained in:
2020-11-22 10:13:37 +05:30
parent cabd6f2ea1
commit 6567f560ab
187 changed files with 1709 additions and 1184 deletions

View File

@ -3,4 +3,12 @@ export class BillSettlementReportItem {
billId: string;
amount: number;
settlement: string;
public constructor(init?: Partial<BillSettlementReportItem>) {
this.date = '';
this.billId = '';
this.amount = 0;
this.settlement = '';
Object.assign(this, init);
}
}

View File

@ -1,4 +1,4 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { BillSettlementReportComponent } from './bill-settlement-report.component';
@ -6,11 +6,13 @@ describe('BillSettlementReportComponent', () => {
let component: BillSettlementReportComponent;
let fixture: ComponentFixture<BillSettlementReportComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [BillSettlementReportComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [BillSettlementReportComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(BillSettlementReportComponent);

View File

@ -14,9 +14,12 @@ import { BillSettlementReportDataSource } from './bill-settlement-report-datasou
styleUrls: ['./bill-settlement-report.component.css'],
})
export class BillSettlementReportComponent implements OnInit {
dataSource: BillSettlementReportDataSource;
info: BillSettlementReport = new BillSettlementReport();
dataSource: BillSettlementReportDataSource = new BillSettlementReportDataSource(
this.info.amounts,
);
form: FormGroup;
info: BillSettlementReport;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['date', 'billId', 'amount', 'settlement'];
@ -27,11 +30,16 @@ export class BillSettlementReportComponent implements OnInit {
private fb: FormBuilder,
private toCsv: ToCsvService,
) {
this.createForm();
// Create form
this.form = this.fb.group({
startDate: '',
finishDate: '',
});
}
ngOnInit() {
this.route.data.subscribe((data: { info: BillSettlementReport }) => {
this.route.data.subscribe((value) => {
const data = value as { info: BillSettlementReport };
this.info = data.info;
this.form.setValue({
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
@ -51,20 +59,13 @@ export class BillSettlementReportComponent implements OnInit {
});
}
createForm() {
this.form = this.fb.group({
startDate: '',
finishDate: '',
});
}
getInfo(): BillSettlementReport {
const formModel = this.form.value;
return {
return new BillSettlementReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
};
});
}
exportCsv() {

View File

@ -16,7 +16,7 @@ const serviceName = 'BillSettlementReportService';
export class BillSettlementReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
get(startDate: string, finishDate): Observable<BillSettlementReport> {
get(startDate: string | null, finishDate: string | null): Observable<BillSettlementReport> {
const options = { params: new HttpParams() };
if (startDate !== null) {
options.params = options.params.set('s', startDate);

View File

@ -3,5 +3,12 @@ import { BillSettlementReportItem } from './bill-settlement-report-item';
export class BillSettlementReport {
startDate: string;
finishDate: string;
amounts?: BillSettlementReportItem[];
amounts: BillSettlementReportItem[];
public constructor(init?: Partial<BillSettlementReport>) {
this.startDate = '';
this.finishDate = '';
this.amounts = [];
Object.assign(this, init);
}
}