Skip to content

Angular 4 Data Table Compile issue (/node_modules/angular-4-data-table/src/index.ts) #42

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e1051ae
Update for angular 4
Jul 7, 2017
1fec92e
Update for angular 4
Jul 7, 2017
0abd8be
pre compile
Aug 1, 2017
46a7e38
pre compile
Aug 1, 2017
746c72e
fix ng module
MIt9 Aug 1, 2017
74ce806
module id fix
Aug 2, 2017
d9c5268
module id fix
Aug 2, 2017
cbb5334
Update README.md
MIt9 Sep 22, 2017
8865df3
Update README.md
MIt9 Sep 22, 2017
f21c85b
Update README.md
MIt9 Sep 22, 2017
a5cf345
Fixed typos
Oct 9, 2017
da5cae4
Adding page numbers and making range, limit and input optional
Nov 9, 2017
bfa3d65
Update README.md
Nov 9, 2017
29f938a
seperating template binding into two elements
Nov 9, 2017
2a6edf5
using maxPage from component rather then dataTable
Nov 9, 2017
5329d7c
Pagination updated
khalid-folio3 Nov 13, 2017
4a8d913
Next prevuious dots
khalid-folio3 Nov 13, 2017
4fdc1fc
next previous
khalid-folio3 Nov 13, 2017
3442ce5
added classes hasNext,hasPrevious
khalid-folio3 Nov 13, 2017
fbc44bf
readme
khalid-folio3 Nov 13, 2017
76a5c85
Merge pull request #1 from khalid-folio3/master
faisal-iqbal Nov 20, 2017
bbff28c
reverting unnessecery README.md changes
Nov 23, 2017
df18de2
Merge pull request #2 from faisal-iqbal/master
MIt9 Nov 23, 2017
9beddb3
update module.id fix
MIt9 Nov 23, 2017
6d7dfed
update git ignore
MIt9 Nov 23, 2017
6edaae3
update dist
MIt9 Nov 27, 2017
bcef791
update dist
MIt9 Nov 27, 2017
c2c1216
update dist fix
MIt9 Nov 27, 2017
091ebf5
Added a new tbody tag where a message can be displayed if there is no…
mjenkins724 Dec 6, 2017
1be0b7b
Merge pull request #3 from mjenkins724/master
MIt9 Dec 15, 2017
8a5c188
update dist fix
MIt9 Dec 18, 2017
6b2b25a
update dist fix
MIt9 Dec 18, 2017
d1f1639
update document and dist fix
MIt9 Dec 18, 2017
d4014a0
add basic accessibility support.
brunano21 Dec 22, 2017
405503b
more accessibility.
brunano21 Dec 22, 2017
b23660c
Added `scope` attribute to `th` tags.
brunano21 Dec 22, 2017
b04a925
src/components/row.component.ts
jay-thanki Dec 23, 2017
e779614
Merge pull request #4 from brunano21/a11y
MIt9 Dec 23, 2017
23cb357
Merge pull request #1 from shakehar/patch-1
MIt9 Dec 23, 2017
42cd8da
Merge pull request #5 from jay-thanki/patch-1
MIt9 Dec 23, 2017
e16f509
aot compatible changes
jay-thanki Dec 28, 2017
3e8c2e6
Merge pull request #8 from jay-thanki/patch-2
MIt9 Jan 2, 2018
e7a1633
change rowDoubleClicked and rowClicked to public
MIt9 Jan 2, 2018
6204927
aot changes in table.component.ts
jay-thanki Jan 2, 2018
19d0149
Merge pull request #9 from jay-thanki/patch-3
MIt9 Jan 2, 2018
1904d20
change rowDoubleClicked and rowClicked to public
MIt9 Jan 2, 2018
0085bef
change module.id to module.id string
MIt9 Feb 21, 2018
63eb4c2
pagination fix style. removed dots.
MIt9 Mar 1, 2018
6fb8d36
pagination fix style
MIt9 Mar 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/dist
/tmp
/node_modules
/.idea
/typings
npm-debug.log
npm-debug.log
package-lock.json
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Angular 2 Data Table
## Angular 4 Data Table

A simple Angular 2 data table, with built-in solutions for features including:
This is fork of package [https://github.com/ggmod/angular-2-data-table] (https://github.com/ggmod/angular-2-data-table)

A simple Angular 4 data table, with built-in solutions for features including:

* pagination
* sorting
Expand All @@ -13,11 +15,24 @@ The component can be used not just with local data, but remote resources too: fo

The templates use bootstrap CSS class names, so the component requires a bootstrap .css file to be present in the application using it.

Check out the [demo](https://ggmod.github.io/angular-2-data-table-demo) and its [code](https://github.com/ggmod/angular-2-data-table-demo) for examples of how to use it.
Check out the [demo](https://ggmod.github.io/angular-2-data-table-demo) and its [code](https://github.com/MIt9/angular-4-data-table-demo) for examples of how to use it.

Demo for pagination with seperate page numbers will be added soon

## Installing:
`npm install angular-2-data-table --save`
`npm install angular-4-data-table --save`

## Production (Minification)
Some times this can cause problems.
To fix it use import like this

`import { DataTableModule } from 'angular-4-data-table';`

and for production build use

`ng build --prod --aot=false`

### Added numerical pagination support with 2 next and previous links

#### Licensing
MIT License
48 changes: 26 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
{
"name": "angular-2-data-table",
"version": "0.1.2",
"description": "An Angular 2 data table, with pagination, sorting, expandable rows etc.",
"name": "angular-4-data-table",
"version": "0.4.6",
"description": "An Angular 4 data table, with pagination, sorting, expandable rows etc.",
"keywords": [
"angular",
"angular2",
"Angular 2",
"angular4",
"Angular 4",
"ng2",
"datatable",
"data-table",
"data table",
"pagination"
],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "src/index.ts",
"typings": "src/index.ts",
"scripts": {
"build": "rm -rf dist/* && tsc",
"serve": "rm -rf dist/ && tsc -w",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
"url": "git://git@github.com/ggmod/angular-2-data-table.git"
"url": "git+https://github.com/MIt9/angular-4-data-table.git"
},
"peerDependencies": {
"@angular/core": "^2.0.0"
},
"author": "ggmod <ggmod64@gmail.com>",
"author": "Dmitrii Bilukha <siniidrozd@gmail.com> (http://donsamogon.com)",
"license": "MIT",
"devDependencies": {
"@angular/common": "^2.0.0",
"@angular/core": "^2.0.0",
"@angular/forms": "^2.0.0",
"rxjs": "^5.0.0-beta.12",
"typescript": "^2.0.2"
}
"devDependencies": {},
"dependencies": {
"@angular/core": "^4.0.0",
"@angular/common": "^4.0.1",
"@angular/forms": "^4.0.1",
"@angular/platform-browser": "^4.0.1",
"@types/node": "~6.0.60",
"rxjs": "^5.1.0",
"ts-node": "~2.0.0",
"typescript": "2.1.5",
"zone.js": "^0.8.12"
},
"false": {},
"bugs": {
"url": "https://github.com/MIt9/angular-4-data-table/issues"
},
"homepage": "https://github.com/MIt9/angular-4-data-table#readme"
}
2 changes: 1 addition & 1 deletion src/components/column.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Directive, Input, ContentChild, OnInit } from '@angular/core';
import { DataTableRow } from './row.component';
import { CellCallback } from './types';
import { CellCallback } from '../types/cell-callback.type';


@Directive({
Expand Down
1 change: 1 addition & 0 deletions src/components/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HEADER_STYLE } from "./header.style";


@Component({
moduleId: module.id +'',
selector: 'data-table-header',
template: HEADER_TEMPLATE,
styles: [HEADER_STYLE],
Expand Down
8 changes: 5 additions & 3 deletions src/components/header.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ export const HEADER_TEMPLATE = `
<h4 class="title" [textContent]="dataTable.headerTitle"></h4>
<div class="button-panel">
<button type="button" class="btn btn-default btn-sm refresh-button"
(click)="dataTable.reloadItems()">
(click)="dataTable.reloadItems()"
[attr.aria-label]="dataTable.translations.headerReload" [title]="dataTable.translations.headerReload">
<span class="glyphicon glyphicon-refresh"></span>
</button>
<button type="button" class="btn btn-default btn-sm column-selector-button" [class.active]="columnSelectorOpen"
(click)="columnSelectorOpen = !columnSelectorOpen; $event.stopPropagation()" >
(click)="columnSelectorOpen = !columnSelectorOpen; $event.stopPropagation()"
[attr.aria-label]="dataTable.translations.headerColumnSelector" [title]="dataTable.translations.headerColumnSelector">
<span class="glyphicon glyphicon-list"></span>
</button>
<div class="column-selector-wrapper" (click)="$event.stopPropagation()">
Expand Down Expand Up @@ -40,4 +42,4 @@ export const HEADER_TEMPLATE = `
</div>
</div>
</div>
`;
`;
48 changes: 40 additions & 8 deletions src/components/pagination.component.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { Component, Inject, forwardRef } from '@angular/core';
import { DataTable } from './table.component';
import { PAGINATION_TEMPLATE } from './pagination.template';
import { PAGINATION_STYLE } from "./pagination.style";
import {Component, Inject, forwardRef, Input} from '@angular/core';
import {DataTable} from './table.component';
import {PAGINATION_TEMPLATE} from './pagination.template';
import {PAGINATION_STYLE} from "./pagination.style";


@Component({
selector: 'data-table-pagination',
template: PAGINATION_TEMPLATE,
styles: [PAGINATION_STYLE]
moduleId: module.id +'',
selector: 'data-table-pagination',
template: PAGINATION_TEMPLATE,
styles: [PAGINATION_STYLE]
})
export class DataTablePagination {

constructor(@Inject(forwardRef(() => DataTable)) public dataTable: DataTable) {}
@Input() show_range = false;
@Input() show_limit = false;
@Input() show_input = false;
@Input() show_numbers = true;

constructor(@Inject(forwardRef(() => DataTable)) public dataTable: DataTable) {
}

pageBack() {
this.dataTable.offset -= Math.min(this.dataTable.limit, this.dataTable.offset);
Expand Down Expand Up @@ -48,4 +55,29 @@ export class DataTablePagination {
set page(value) {
this.dataTable.page = Number(<any>value);
}

createPageRange(number, page): any[] {
const displayedPage = 3;
let items: number[] = [];
if (number > 1) {
let maxPage = number;
let minPage = 1;
if (page === 1 && maxPage >= displayedPage) {
maxPage = 3;
} else if (page > 1 && maxPage > page + 1) {
minPage = page - 1;
maxPage = page + 1;
} else if (page > 2 && maxPage > page) {
minPage = page - 1;
maxPage = page + 1;
} else if (page > 2 && maxPage === page) {
minPage = page - 2;
maxPage = page;
}
for (let i = minPage; i <= maxPage; i++) {
items.push(i);
}
}
return items;
}
}
5 changes: 4 additions & 1 deletion src/components/pagination.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export const PAGINATION_STYLE = `
.pagination-box {
position: relative;
margin-top: -10px;
display: block;
height: 30px;
}
.pagination-range {
margin-top: 7px;
Expand All @@ -21,12 +23,13 @@ export const PAGINATION_STYLE = `
margin-right: 25px;
display: inline-table;
width: 150px;
float: left;
}
.pagination-pages {
display: inline-block;
}
.pagination-page {
width: 110px;
width: 102px;
display: inline-table;
}
.pagination-box button {
Expand Down
14 changes: 10 additions & 4 deletions src/components/pagination.template.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const PAGINATION_TEMPLATE = `
<div class="pagination-box">
<div class="pagination-range">
<div class="pagination-range" *ngIf="show_range">
{{dataTable.translations.paginationRange}}:
<span [textContent]="dataTable.offset + 1"></span>
-
Expand All @@ -9,18 +9,18 @@ export const PAGINATION_TEMPLATE = `
<span [textContent]="dataTable.itemCount"></span>
</div>
<div class="pagination-controllers">
<div class="pagination-limit">
<div class="pagination-limit" *ngIf="show_limit">
<div class="input-group">
<span class="input-group-addon">{{dataTable.translations.paginationLimit}}:</span>
<input #limitInput type="number" class="form-control" min="1" step="1"
[ngModel]="limit" (blur)="limit = limitInput.value"
(keyup.enter)="limit = limitInput.value" (keyup.esc)="limitInput.value = limit"/>
</div>
</div>
<div class=" pagination-pages">
<div class=" pagination-pages" *ngIf="maxPage > 1">
<button [disabled]="dataTable.offset <= 0" (click)="pageFirst()" class="btn btn-default pagination-firstpage">&laquo;</button>
<button [disabled]="dataTable.offset <= 0" (click)="pageBack()" class="btn btn-default pagination-prevpage">&lsaquo;</button>
<div class="pagination-page">
<div class="pagination-page" *ngIf="show_input">
<div class="input-group">
<input #pageInput type="number" class="form-control" min="1" step="1" max="{{maxPage}}"
[ngModel]="page" (blur)="page = pageInput.value"
Expand All @@ -31,6 +31,12 @@ export const PAGINATION_TEMPLATE = `
</div>
</div>
</div>
<div class="pagination-page" *ngIf="show_numbers">
<button *ngFor="let i of createPageRange(maxPage,page)"
[disabled]="i == page"
(click)="page = i"
class="btn btn-default">{{ i }}</button>
</div>
<button [disabled]="(dataTable.offset + dataTable.limit) >= dataTable.itemCount" (click)="pageForward()" class="btn btn-default pagination-nextpage">&rsaquo;</button>
<button [disabled]="(dataTable.offset + dataTable.limit) >= dataTable.itemCount" (click)="pageLast()" class="btn btn-default pagination-lastpage">&raquo;</button>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/row.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ROW_STYLE } from "./row.style";


@Component({
moduleId: module.id +'',
selector: '[dataTableRow]',
template: ROW_TEMPLATE,
styles: [ROW_STYLE]
Expand Down Expand Up @@ -56,5 +57,5 @@ export class DataTableRow implements OnDestroy {
this.selected = false;
}

private _this = this; // FIXME is there no template keyword for this in angular 2?
public _this = this; // FIXME is there no template keyword for this in angular 2?
}
10 changes: 6 additions & 4 deletions src/components/row.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ export const ROW_TEMPLATE = `
(dblclick)="dataTable.rowDoubleClicked(_this, $event)"
(click)="dataTable.rowClicked(_this, $event)"
>
<td [hide]="!dataTable.expandColumnVisible" (click)="expanded = !expanded; $event.stopPropagation()" class="row-expand-button">
<span class="glyphicon glyphicon-triangle-right" [hide]="expanded"></span>
<span class="glyphicon glyphicon-triangle-bottom" [hide]="!expanded"></span>
<td [hide]="!dataTable.expandColumnVisible">
<div tabindex="0" role="button" (click)="expanded = !expanded; $event.stopPropagation()" class="row-expand-button"
[attr.aria-expanded]="expanded" [title]="dataTable.translations.expandRow" [attr.aria-label]="dataTable.translations.expandRow">
<span class="glyphicon" [ngClass]="{'glyphicon-triangle-right': !expanded, 'glyphicon-triangle-bottom': expanded}" aria-hidden="true"></span>
</div>
</td>
<td [hide]="!dataTable.indexColumnVisible" class="index-column" [textContent]="displayIndex"></td>
<td [hide]="!dataTable.selectColumnVisible" class="select-column">
Expand All @@ -28,4 +30,4 @@ export const ROW_TEMPLATE = `
<div [ngTemplateOutlet]="dataTable.expandTemplate" [ngOutletContext]="{row: _this, item: item}"></div>
</td>
</tr>
`;
`;
Loading