Prettied, Linted and updated angular.json according to the latest schematic of Angular CLI.
Now all that is needed is to make it ready for strict compiling. Removed eslint-plugin-prettier as it is not recommended and causes errors for both eslint and prettier Bumped to v8.0.0
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Inventory, Journal } from '../core/voucher';
|
||||
|
||||
import { Inventory } from '../core/inventory';
|
||||
|
||||
export class IssueDataSource extends DataSource<Inventory> {
|
||||
constructor(private data: Observable<Inventory[]>) {
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<mat-autocomplete
|
||||
#autoB="matAutocomplete"
|
||||
autoActiveFirstOption
|
||||
[displayWith]="displayBatchName"
|
||||
[displayWith]="displayFn"
|
||||
(optionSelected)="batchSelected($event)"
|
||||
>
|
||||
<mat-option *ngFor="let batch of batches | async" [value]="batch">{{
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { MathService } from '../shared/math.service';
|
||||
import { Batch } from '../core/voucher';
|
||||
import { Observable } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, startWith, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { Batch } from '../core/batch';
|
||||
import { BatchService } from '../core/batch.service';
|
||||
import { MathService } from '../shared/math.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-issue-dialog',
|
||||
@ -47,17 +48,14 @@ export class IssueDialogComponent implements OnInit {
|
||||
listenToBatchAutocompleteChange(): void {
|
||||
const control = this.form.get('batch');
|
||||
this.batches = control.valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
startWith(''),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) =>
|
||||
x === null ? observableOf([]) : this.batchSer.autocomplete(this.data.date, x),
|
||||
),
|
||||
switchMap((x) => this.batchSer.autocomplete(this.data.date, x)),
|
||||
);
|
||||
}
|
||||
|
||||
displayBatchName(batch?: Batch): string | undefined {
|
||||
displayFn(batch?: Batch): string | undefined {
|
||||
return batch ? batch.name : undefined;
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const url = '/api/issue-grid';
|
||||
const serviceName = 'IssueGridService';
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { Voucher } from '../core/voucher';
|
||||
import { VoucherService } from '../core/voucher.service';
|
||||
|
||||
@ -10,12 +11,11 @@ import { VoucherService } from '../core/voucher.service';
|
||||
export class IssueResolver implements Resolve<Voucher> {
|
||||
constructor(private ser: VoucherService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Voucher> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<Voucher> {
|
||||
const id = route.paramMap.get('id');
|
||||
if (id === null) {
|
||||
return this.ser.getOfType('Issue');
|
||||
} else {
|
||||
return this.ser.get(id, 'Issue');
|
||||
}
|
||||
return this.ser.get(id, 'Issue');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { IssueResolver } from './issue-resolver.service';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { IssueComponent } from './issue.component';
|
||||
import { CostCentreListResolver } from '../cost-centre/cost-centre-list-resolver.service';
|
||||
|
||||
import { IssueResolver } from './issue-resolver.service';
|
||||
import { IssueComponent } from './issue.component';
|
||||
|
||||
const issueRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
<mat-autocomplete
|
||||
#autoB="matAutocomplete"
|
||||
autoActiveFirstOption
|
||||
[displayWith]="displayBatchName"
|
||||
[displayWith]="displayFn"
|
||||
(optionSelected)="batchSelected($event)"
|
||||
>
|
||||
<mat-option *ngFor="let batch of batches | async" [value]="batch">{{
|
||||
@ -142,7 +142,6 @@
|
||||
<mat-label>Narration</mat-label>
|
||||
<textarea
|
||||
matInput
|
||||
matTextareaAutosize
|
||||
matAutosizeMinRows="5"
|
||||
placeholder="Narration"
|
||||
formControlName="narration"
|
||||
|
||||
@ -3,23 +3,27 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
import { IssueDataSource } from './issue-datasource';
|
||||
import { VoucherService } from '../core/voucher.service';
|
||||
import { Batch, Inventory, Voucher } from '../core/voucher';
|
||||
import * as moment from 'moment';
|
||||
import { round } from 'mathjs';
|
||||
import { MathService } from '../shared/math.service';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { IssueDialogComponent } from './issue-dialog.component';
|
||||
import { BatchService } from '../core/batch.service';
|
||||
import { IssueGridService } from './issue-grid.service';
|
||||
import { CostCentre } from '../core/cost-centre';
|
||||
import { IssueGridDataSource } from './issue-grid-datasource';
|
||||
import { Hotkey, HotkeysService } from 'angular2-hotkeys';
|
||||
import { round } from 'mathjs';
|
||||
import * as moment from 'moment';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { Batch } from '../core/batch';
|
||||
import { BatchService } from '../core/batch.service';
|
||||
import { CostCentre } from '../core/cost-centre';
|
||||
import { Inventory } from '../core/inventory';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { Voucher } from '../core/voucher';
|
||||
import { VoucherService } from '../core/voucher.service';
|
||||
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MathService } from '../shared/math.service';
|
||||
|
||||
import { IssueDataSource } from './issue-datasource';
|
||||
import { IssueDialogComponent } from './issue-dialog.component';
|
||||
import { IssueGridDataSource } from './issue-grid-datasource';
|
||||
import { IssueGridService } from './issue-grid.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-issue',
|
||||
@ -70,7 +74,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.hotkeys.add(
|
||||
new Hotkey(
|
||||
'f2',
|
||||
(event: KeyboardEvent): boolean => {
|
||||
(): boolean => {
|
||||
setTimeout(() => {
|
||||
this.dateElement.nativeElement.focus();
|
||||
}, 0);
|
||||
@ -82,7 +86,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.hotkeys.add(
|
||||
new Hotkey(
|
||||
'ctrl+s',
|
||||
(event: KeyboardEvent): boolean => {
|
||||
(): boolean => {
|
||||
if (this.canSave()) {
|
||||
this.save();
|
||||
}
|
||||
@ -152,7 +156,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
this.voucher.inventories.push({
|
||||
id: null,
|
||||
quantity: quantity,
|
||||
quantity,
|
||||
rate: this.batch.rate,
|
||||
tax: this.batch.tax,
|
||||
discount: this.batch.discount,
|
||||
@ -189,7 +193,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
const dialogRef = this.dialog.open(IssueDialogComponent, {
|
||||
width: '750px',
|
||||
data: {
|
||||
inventory: Object.assign({}, row),
|
||||
inventory: { ...row },
|
||||
date: moment(this.form.value.date).format('DD-MMM-YYYY'),
|
||||
},
|
||||
});
|
||||
@ -232,14 +236,14 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
canSave() {
|
||||
if (!this.voucher.id) {
|
||||
return true;
|
||||
} else if (this.voucher.posted && this.auth.user.perms.indexOf('edit-posted-vouchers') !== -1) {
|
||||
return true;
|
||||
} else {
|
||||
return (
|
||||
this.voucher.user.id === this.auth.user.id ||
|
||||
this.auth.user.perms.indexOf("edit-other-user's-vouchers") !== -1
|
||||
);
|
||||
}
|
||||
if (this.voucher.posted && this.auth.user.perms.indexOf('edit-posted-vouchers') !== -1) {
|
||||
return true;
|
||||
}
|
||||
return (
|
||||
this.voucher.user.id === this.auth.user.id ||
|
||||
this.auth.user.perms.indexOf("edit-other-user's-vouchers") !== -1
|
||||
);
|
||||
}
|
||||
|
||||
save() {
|
||||
@ -274,7 +278,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.voucher.id).subscribe(
|
||||
(result) => {
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/issue'], { replaceUrl: true });
|
||||
},
|
||||
@ -300,14 +304,11 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
listenToBatchAutocompleteChange(): void {
|
||||
const control = this.form.get('addRow').get('batch');
|
||||
this.batches = control.valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
startWith('null'),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) =>
|
||||
x === null
|
||||
? observableOf([])
|
||||
: this.batchSer.autocomplete(moment(this.form.value.date).format('DD-MMM-YYYY'), x),
|
||||
this.batchSer.autocomplete(moment(this.form.value.date).format('DD-MMM-YYYY'), x),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -323,7 +324,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.issueGridSer.issueGrid(date).subscribe((x) => this.gridObservable.next(x));
|
||||
}
|
||||
|
||||
displayBatchName(batch?: Batch): string | undefined {
|
||||
displayFn(batch?: Batch): string | undefined {
|
||||
return batch ? batch.name : undefined;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@ -20,16 +25,13 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { HotkeyModule } from 'angular2-hotkeys';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
|
||||
import { IssueDialogComponent } from './issue-dialog.component';
|
||||
import { IssueRoutingModule } from './issue-routing.module';
|
||||
import { IssueComponent } from './issue.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { IssueDialogComponent } from './issue-dialog.component';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { HotkeyModule } from 'angular2-hotkeys';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
|
||||
Reference in New Issue
Block a user