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:
tanshu committed 2018-06-09 17:05:11 +05:30
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';
import {CostCentre} from '../cost-centre';
export class CostCentreListDataSource extends DataSource<CostCentre> {
constructor(private paginator: MatPaginator, private sort: MatSort, public data: CostCentre[]) {
super();
}
connect(): Observable<CostCentre[]> {
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: CostCentre[]) {
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
return data.splice(startIndex, this.paginator.pageSize);
}
private getSortedData(data: CostCentre[]) {
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,35 @@
<mat-card>
<mat-card-title-group>
<mat-card-title>Cost Centers</mat-card-title>
<a mat-button [routerLink]="['/CostCentre']">
<mat-icon>add_box</mat-icon>
Add
</a>
</mat-card-title-group>
<mat-card-content>
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
<!-- Name Column -->
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
<mat-cell *matCellDef="let row"><a [routerLink]="['/CostCentre', row.id]">{{row.name}}</a></mat-cell>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="isFixture">
<mat-header-cell *matHeaderCellDef mat-sort-header>Is Fixture?</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.isFixture}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
<mat-paginator #paginator
[length]="dataSource.data.length"
[pageIndex]="0"
[pageSize]="50"
[pageSizeOptions]="[25, 50, 100, 250]">
</mat-paginator>
</mat-card-content>
</mat-card>
@@ -0,0 +1,23 @@
import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
import {CostCentreListComponent} from './cost-centre-list.component';
describe('CostCentreListComponent', () => {
let component: CostCentreListComponent;
let fixture: ComponentFixture<CostCentreListComponent>;
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
declarations: [CostCentreListComponent]
})
.compileComponents();
fixture = TestBed.createComponent(CostCentreListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should compile', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,30 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import {MatPaginator, MatSort} from '@angular/material';
import {CostCentreListDataSource} from './cost-centre-list-datasource';
import {CostCentre} from '../cost-centre';
import {ActivatedRoute} from '@angular/router';
@Component({
selector: 'app-cost-centre-list',
templateUrl: './cost-centre-list.component.html',
styleUrls: ['./cost-centre-list.component.css']
})
export class CostCentreListComponent implements OnInit {
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
dataSource: CostCentreListDataSource;
list: CostCentre[];
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'isFixture'];
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
this.route.data
.subscribe((data: { list: CostCentre[] }) => {
this.list = data.list;
});
this.dataSource = new CostCentreListDataSource(this.paginator, this.sort, this.list);
}
}