Moved to Angular 6.0
---- 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
This commit is contained in:
1 parent
b3cb01da02
commit
6be1dd5a3a
1380 files changed
+23914
-18722
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import {DataSource} from '@angular/cdk/collections';
|
||||
import {MatPaginator, MatSort} from '@angular/material';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {merge, Observable, of as observableOf} from 'rxjs';
|
||||
|
||||
|
||||
export class BalanceSheetDataSource extends DataSource<any> {
|
||||
|
||||
constructor(private paginator: MatPaginator, private sort: MatSort, public data: any[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<any[]> {
|
||||
const dataMutations = [
|
||||
observableOf(this.data),
|
||||
this.paginator.page,
|
||||
this.sort.sortChange
|
||||
];
|
||||
|
||||
// Set the paginators length
|
||||
this.paginator.length = this.data.length;
|
||||
|
||||
return merge(...dataMutations).pipe(map(() => {
|
||||
return this.getPagedData(this.getSortedData([...this.data]));
|
||||
}));
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
|
||||
private getPagedData(data: any[]) {
|
||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
||||
return data.splice(startIndex, this.paginator.pageSize);
|
||||
}
|
||||
|
||||
private getSortedData(data: any[]) {
|
||||
if (!this.sort.active || this.sort.direction === '') {
|
||||
return data;
|
||||
}
|
||||
|
||||
return data.sort((a, b) => {
|
||||
const isAsc = this.sort.direction === 'asc';
|
||||
switch (this.sort.active) {
|
||||
case 'name':
|
||||
return compare(a.name, b.name, isAsc);
|
||||
case 'id':
|
||||
return compare(+a.id, +b.id, isAsc);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
function compare(a, b, isAsc) {
|
||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {BalanceSheetResolver} from './balance-sheet-resolver.service';
|
||||
|
||||
describe('BalanceSheetResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [BalanceSheetResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([BalanceSheetResolver], (service: BalanceSheetResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {BalanceSheet} from './balance-sheet';
|
||||
import {BalanceSheetService} from './balance-sheet.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class BalanceSheetResolver implements Resolve<BalanceSheet> {
|
||||
|
||||
constructor(private ser: BalanceSheetService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BalanceSheet> {
|
||||
const date = route.paramMap.get('date');
|
||||
return this.ser.list(date);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import {BalanceSheetRoutingModule} from './balance-sheet-routing.module';
|
||||
|
||||
describe('BalanceSheetRoutingModule', () => {
|
||||
let balanceSheetRoutingModule: BalanceSheetRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
balanceSheetRoutingModule = new BalanceSheetRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(balanceSheetRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {BalanceSheetResolver} from './balance-sheet-resolver.service';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {BalanceSheetComponent} from './balance-sheet.component';
|
||||
|
||||
const balanceSheetRoutes: Routes = [
|
||||
{
|
||||
path: 'BalanceSheet',
|
||||
component: BalanceSheetComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Balance Sheet'
|
||||
},
|
||||
resolve: {
|
||||
info: BalanceSheetResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'BalanceSheet/:date',
|
||||
component: BalanceSheetComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Balance Sheet'
|
||||
},
|
||||
resolve: {
|
||||
info: BalanceSheetResolver
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(balanceSheetRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
BalanceSheetResolver
|
||||
]
|
||||
})
|
||||
export class BalanceSheetRoutingModule {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
.right {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Balance Sheet</mat-card-title>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start">
|
||||
<mat-form-field fxFlex>
|
||||
<input matInput [matDatepicker]="dateInput" (focus)="dateInput.open()" placeholder="Date"
|
||||
formControlName="date" autocomplete="off">
|
||||
<mat-datepicker-toggle matSuffix [for]="dateInput"></mat-datepicker-toggle>
|
||||
<mat-datepicker #dateInput></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" (click)="show()">Show</button>
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||
|
||||
<!-- Group Column -->
|
||||
<ng-container matColumnDef="group">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Group</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.group}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef>{{info.footer.group}}</mat-footer-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.name}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef>{{info.footer.name}}</mat-footer-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- SubAmount Column -->
|
||||
<ng-container matColumnDef="subAmount">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Amount</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.subAmount | currency:'INR' | clear}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef class="right">{{info.footer.subAmount | currency:'INR' | clear}}
|
||||
</mat-footer-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Total Column -->
|
||||
<ng-container matColumnDef="total">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Total</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.amount | currency:'INR' | clear}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef class="right">{{info.footer.amount | currency:'INR' | clear}}
|
||||
</mat-footer-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
<mat-footer-row *matFooterRowDef="displayedColumns"></mat-footer-row>
|
||||
|
||||
</mat-table>
|
||||
|
||||
<mat-paginator #paginator
|
||||
[length]="dataSource.data.length"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250, 300]">
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,25 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {BalanceSheetComponent} from './balance-sheet.component';
|
||||
|
||||
describe('BalanceSheetComponent', () => {
|
||||
let component: BalanceSheetComponent;
|
||||
let fixture: ComponentFixture<BalanceSheetComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [BalanceSheetComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BalanceSheetComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {MatPaginator, MatSort} from '@angular/material';
|
||||
import {BalanceSheetDataSource} from './balance-sheet-datasource';
|
||||
import {BalanceSheet} from './balance-sheet';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-balance-sheet',
|
||||
templateUrl: './balance-sheet.component.html',
|
||||
styleUrls: ['./balance-sheet.component.css']
|
||||
})
|
||||
export class BalanceSheetComponent implements OnInit {
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
dataSource: BalanceSheetDataSource;
|
||||
form: FormGroup;
|
||||
info: BalanceSheet;
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['group', 'name', 'subAmount', 'total'];
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router, private fb: FormBuilder) {
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
date: ''
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: BalanceSheet }) => {
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
date: moment(this.info.date, 'DD-MMM-YYYY').toDate()
|
||||
});
|
||||
});
|
||||
this.dataSource = new BalanceSheetDataSource(this.paginator, this.sort, this.info.body);
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['BalanceSheet' + info.date]);
|
||||
}
|
||||
|
||||
getInfo(): BalanceSheet {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
date: moment(formModel.date).format('DD-MMM-YYYY')
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import {BalanceSheetModule} from './balance-sheet.module';
|
||||
|
||||
describe('BalanceSheetModule', () => {
|
||||
let balanceSheetModule: BalanceSheetModule;
|
||||
|
||||
beforeEach(() => {
|
||||
balanceSheetModule = new BalanceSheetModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(balanceSheetModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,69 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {
|
||||
DateAdapter,
|
||||
MAT_DATE_FORMATS,
|
||||
MAT_DATE_LOCALE,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatDatepickerModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatNativeDateModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSortModule,
|
||||
MatTableModule
|
||||
} from '@angular/material';
|
||||
import {SharedModule} from '../shared/shared.module';
|
||||
import {CdkTableModule} from '@angular/cdk/table';
|
||||
import {BalanceSheetRoutingModule} from './balance-sheet-routing.module';
|
||||
import {BalanceSheetComponent} from './balance-sheet.component';
|
||||
import {MomentDateAdapter} from '@angular/material-moment-adapter';
|
||||
import {FlexLayoutModule, FlexModule} from '@angular/flex-layout';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
},
|
||||
display: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
monthYearLabel: 'MMM YYYY',
|
||||
dateA11yLabel: 'DD-MMM-YYYY',
|
||||
monthYearA11yLabel: 'MMM YYYY',
|
||||
},
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CdkTableModule,
|
||||
FlexModule,
|
||||
FlexLayoutModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatDatepickerModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatNativeDateModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSortModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
BalanceSheetRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
BalanceSheetComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
})
|
||||
export class BalanceSheetModule {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {BalanceSheetService} from './balance-sheet.service';
|
||||
|
||||
describe('BalanceSheetService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [BalanceSheetService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([BalanceSheetService], (service: BalanceSheetService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
import {BalanceSheet} from './balance-sheet';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/api/BalanceSheet';
|
||||
const serviceName = 'AccountService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class BalanceSheetService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
list(date: string): Observable<BalanceSheet> {
|
||||
const listUrl = (date === null) ? url : `${url}/${date}`;
|
||||
return <Observable<BalanceSheet>>this.http.get<BalanceSheet>(listUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export class BalanceSheet {
|
||||
date: string;
|
||||
body?: any[];
|
||||
footer?: any[];
|
||||
}
|
||||
Reference in new issue
Block a user