Skip to content

Commit

Permalink
Fix ng lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkoppa committed Jul 31, 2018
1 parent a2ce4bd commit 485ed96
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/app/app.component.html
@@ -1,3 +1,3 @@
<!--The content below is only a placeholder and can be replaced.-->
<att-table></att-table>
<app-table></app-table>

12 changes: 6 additions & 6 deletions src/app/table/table.component.spec.ts
Expand Up @@ -9,16 +9,16 @@ import { WindowWrapper } from '../utilties/window-wrapper';
import { TableService } from './table.service';
import { DataShape } from './table.models';

let tableServiceMock: TableService = <TableService>{
const tableServiceMock: TableService = <TableService>{
getSampleData: () => from([]),
submitSampleRow: (data: DataShape) => Promise.resolve({})
}
let cdrMock: ChangeDetectorRef = <ChangeDetectorRef>{
};
const cdrMock: ChangeDetectorRef = <ChangeDetectorRef>{
detectChanges: () => {}
}
let windowMock: WindowWrapper = <WindowWrapper>{
};
const windowMock: WindowWrapper = <WindowWrapper>{
scrollX: 0
}
};

describe('TableComponent', () => {
let component: TableComponent;
Expand Down
22 changes: 11 additions & 11 deletions src/app/table/table.component.ts
Expand Up @@ -19,7 +19,7 @@ import {


@Component({
selector: 'att-table',
selector: 'app-table',
templateUrl: './table.component.html'
})
export class TableComponent implements OnInit {
Expand All @@ -34,25 +34,25 @@ export class TableComponent implements OnInit {
public displayedData: OriginalDataShape[] = [];
public dataHeadersMap: {}[] = [];

public currentPage: number = 1;
public currentPage = 1;

private displayedRows: number = 25;
private lastScrollX: number = 0;
private displayedRows = 25;
private lastScrollX = 0;


public get totalPages(): number { return Math.ceil(this.data.length / this.displayedRows); }
public get backVisible(): boolean { return this.notAllRowsDisplayed() && this.currentPage !== 1 }
public get nextVisible(): boolean { return this.notAllRowsDisplayed() && this.currentPage < this.totalPages }
public get startVisible(): boolean { return this.backVisible && this.currentPage > 2 }
public get lastVisible(): boolean { return this.nextVisible && this.totalPages - this.currentPage >= 2 }
public get backVisible(): boolean { return this.notAllRowsDisplayed() && this.currentPage !== 1; }
public get nextVisible(): boolean { return this.notAllRowsDisplayed() && this.currentPage < this.totalPages; }
public get startVisible(): boolean { return this.backVisible && this.currentPage > 2; }
public get lastVisible(): boolean { return this.nextVisible && this.totalPages - this.currentPage >= 2; }

constructor(
private tableService: TableService,
private cdr: ChangeDetectorRef,
private window: WindowWrapper // DI
) {
this.dataHeadersMap = Object.keys(OriginalDataToHeadersMap)
.map(prop => { return { value: prop, display: OriginalDataToHeadersMap[prop] } });
.map(prop => ({ value: prop, display: OriginalDataToHeadersMap[prop] }));
console.log(this.dataHeadersMap);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ export class TableComponent implements OnInit {
this.displayHeader.nativeElement.style.left = `${-this.window.scrollX}px`;
this.lastScrollX = this.window.scrollX;
}
}
};
}

private calculateHeaderWidths(): void {
Expand All @@ -101,7 +101,7 @@ export class TableComponent implements OnInit {
}

private notAllRowsDisplayed(): boolean {
return this.data > this.displayedData
return this.data > this.displayedData;
}

private setPage(page: number) {
Expand Down
46 changes: 23 additions & 23 deletions src/app/table/table.models.ts
Expand Up @@ -3,30 +3,30 @@ export interface DataShape {
}

export type DataToHeadersMap<S extends DataShape> = {
[P in keyof S]: string
}
[P in keyof S]: string;
};

export interface OriginalDataShape extends DataShape {
name: string,
phone: string,
email: string,
company: string,
date_entry: string,
org: string,
address_1: string,
city: string,
zip: string,
geo: string,
pan: string,
pin: string,
id: number,
status: string,
fee: string,
guid: string,
date_exit: string,
date_first: string,
date_recent: string,
url: string
name: string;
phone: string;
email: string;
company: string;
date_entry: string;
org: string;
address_1: string;
city: string;
zip: string;
geo: string;
pan: string;
pin: string;
id: number;
status: string;
fee: string;
guid: string;
date_exit: string;
date_first: string;
date_recent: string;
url: string;
}

export const OriginalDataToHeadersMap: DataToHeadersMap<OriginalDataShape> = {
Expand All @@ -50,4 +50,4 @@ export const OriginalDataToHeadersMap: DataToHeadersMap<OriginalDataShape> = {
date_first: 'First Date',
date_recent: 'Recent Date',
url: 'URL'
}
};
2 changes: 1 addition & 1 deletion src/app/table/table.module.ts
Expand Up @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';

import { TableComponent } from './table.component';
import { TableService } from './table.service'
import { TableService } from './table.service';

@NgModule({
imports: [
Expand Down

0 comments on commit 485ed96

Please sign in to comment.