Moved from tslint to eslint as tslint was depreciated.

Added prettier and also prettied all the typescript files using prettier

ESLint is using the AirBnB rules which are the most strict to lint the files.
This commit is contained in:
tanshu committed 2020-10-01 21:28:12 +05:30
1 parent 40e79ff949
commit 1350870f9e
545 files changed
+8455 -7036

No files matched your search

+36 -35
View File
@@ -1,23 +1,23 @@
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import {ActivatedRoute, Router} from '@angular/router';
import {Observable, of as observableOf} from 'rxjs';
import {debounceTime, distinctUntilChanged, map, startWith, switchMap} from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
import * as moment from 'moment';
import {LedgerDataSource} from './ledger-datasource';
import {Ledger} from './ledger';
import {Account} from '../core/account';
import {LedgerService} from './ledger.service';
import {AccountService} from '../core/account.service';
import {ToCsvService} from '../shared/to-csv.service';
import { LedgerDataSource } from './ledger-datasource';
import { Ledger } from './ledger';
import { Account } from '../core/account';
import { LedgerService } from './ledger.service';
import { AccountService } from '../core/account.service';
import { ToCsvService } from '../shared/to-csv.service';
@Component({
selector: 'app-ledger',
templateUrl: './ledger.component.html',
styleUrls: ['./ledger.component.css']
styleUrls: ['./ledger.component.css'],
})
export class LedgerComponent implements OnInit, AfterViewInit {
@ViewChild('accountElement', { static: true }) accountElement: ElementRef;
@@ -41,31 +41,30 @@ export class LedgerComponent implements OnInit, AfterViewInit {
private fb: FormBuilder,
private toCsv: ToCsvService,
private ser: LedgerService,
private accountSer: AccountService
private accountSer: AccountService,
) {
this.createForm();
this.accounts = this.form.get('account').valueChanges
.pipe(
startWith(null),
map(x => (x !== null && x.length >= 1) ? x : null),
debounceTime(150),
distinctUntilChanged(),
switchMap(x => (x === null) ? observableOf([]) : this.accountSer.autocomplete(x))
);
this.accounts = this.form.get('account').valueChanges.pipe(
startWith(null),
map((x) => (x !== null && x.length >= 1 ? x : null)),
debounceTime(150),
distinctUntilChanged(),
switchMap((x) => (x === null ? observableOf([]) : this.accountSer.autocomplete(x))),
);
}
ngOnInit() {
this.route.data.subscribe((data: { info: Ledger }) => {
this.info = data.info;
this.calculateTotals();
this.form.setValue({
account: this.info.account,
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate()
});
this.dataSource = new LedgerDataSource(this.paginator, this.sort, this.info.body);
this.info = data.info;
this.calculateTotals();
this.form.setValue({
account: this.info.account,
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
});
this.dataSource = new LedgerDataSource(this.paginator, this.sort, this.info.body);
});
}
ngAfterViewInit() {
@@ -109,8 +108,8 @@ export class LedgerComponent implements OnInit, AfterViewInit {
this.router.navigate(['ledger', info.account.id], {
queryParams: {
startDate: info.startDate,
finishDate: info.finishDate
}
finishDate: info.finishDate,
},
});
}
@@ -118,7 +117,7 @@ export class LedgerComponent implements OnInit, AfterViewInit {
this.form = this.fb.group({
startDate: '',
finishDate: '',
account: ''
account: '',
});
}
@@ -128,7 +127,7 @@ export class LedgerComponent implements OnInit, AfterViewInit {
return {
account: formModel.account,
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY')
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
};
}
@@ -141,9 +140,11 @@ export class LedgerComponent implements OnInit, AfterViewInit {
Debit: 'debit',
Credit: 'credit',
Running: 'running',
Posted: 'posted'
Posted: 'posted',
};
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {
type: 'text/csv;charset=utf-8;',
});
const link = document.createElement('a');
link.href = window.URL.createObjectURL(csvData);
link.setAttribute('download', 'ledger.csv');