From f97c90dc236576052f4bbaf64f77cdbc82bd8ded Mon Sep 17 00:00:00 2001 From: sanderj Date: Wed, 14 Dec 2016 15:20:02 -0700 Subject: [PATCH 01/36] feat(row-expand-event) adds row expand change emitter and doesnt render expansion unless expanded --- src/components/row.component.ts | 6 ++++++ src/components/row.template.ts | 2 +- src/components/table.component.ts | 5 +++++ src/components/table.template.ts | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/row.component.ts b/src/components/row.component.ts index 96da1c8..264a3fc 100644 --- a/src/components/row.component.ts +++ b/src/components/row.component.ts @@ -23,6 +23,7 @@ export class DataTableRow implements OnDestroy { private _selected: boolean; @Output() selectedChange = new EventEmitter(); + @Output() expandRowChange = new EventEmitter(); get selected() { return this._selected; @@ -50,6 +51,11 @@ export class DataTableRow implements OnDestroy { return ''; } + expandRow() { + this.expanded = !this.expanded; + this.expandRowChange.emit(this.expanded); + } + constructor(@Inject(forwardRef(() => DataTable)) public dataTable: DataTable) {} ngOnDestroy() { diff --git a/src/components/row.template.ts b/src/components/row.template.ts index 7e881ea..c41ed48 100644 --- a/src/components/row.template.ts +++ b/src/components/row.template.ts @@ -23,7 +23,7 @@ export const ROW_TEMPLATE = `
- +
diff --git a/src/components/table.component.ts b/src/components/table.component.ts index e78cdf7..8865f65 100644 --- a/src/components/table.component.ts +++ b/src/components/table.component.ts @@ -213,6 +213,7 @@ export class DataTable implements DataTableParams, OnInit { @Output() rowDoubleClick = new EventEmitter(); @Output() headerClick = new EventEmitter(); @Output() cellClick = new EventEmitter(); + @Output() rowExpandChange = new EventEmitter(); private rowClicked(row: DataTableRow, event) { this.rowClick.emit({ row, event }); @@ -322,6 +323,10 @@ export class DataTable implements DataTableParams, OnInit { } } + onRowExpandChanged(row) { + this.rowExpandChange.emit(row); + } + // other: get substituteItems() { diff --git a/src/components/table.template.ts b/src/components/table.template.ts index 14cdd8c..4c68a29 100644 --- a/src/components/table.template.ts +++ b/src/components/table.template.ts @@ -30,7 +30,8 @@ export const TABLE_TEMPLATE = ` + dataTableRow #row [item]="item" [index]="index" (selectedChange)="onRowSelectChanged(row)" + (expandRowChange)="onRowExpandChanged(row)"> Date: Wed, 14 Dec 2016 15:58:39 -0700 Subject: [PATCH 02/36] fix debug issues found --- package.json | 2 +- src/components/row.component.ts | 6 ++++-- src/components/row.template.ts | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 570f02c..a409a2a 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,6 @@ "@angular/core": "^2.0.0", "@angular/forms": "^2.0.0", "rxjs": "^5.0.0-beta.12", - "typescript": "^2.0.2" + "typescript": "^2.1.4" } } diff --git a/src/components/row.component.ts b/src/components/row.component.ts index 264a3fc..b4c2b70 100644 --- a/src/components/row.component.ts +++ b/src/components/row.component.ts @@ -51,9 +51,11 @@ export class DataTableRow implements OnDestroy { return ''; } - expandRow() { + expandRow(event) { + console.log('expand row'); this.expanded = !this.expanded; - this.expandRowChange.emit(this.expanded); + event.stopPropagation(); + this.expandRowChange.emit(); } constructor(@Inject(forwardRef(() => DataTable)) public dataTable: DataTable) {} diff --git a/src/components/row.template.ts b/src/components/row.template.ts index c41ed48..b35956b 100644 --- a/src/components/row.template.ts +++ b/src/components/row.template.ts @@ -9,9 +9,9 @@ export const ROW_TEMPLATE = ` (dblclick)="dataTable.rowDoubleClicked(_this, $event)" (click)="dataTable.rowClicked(_this, $event)" > - - - + + From 0d65022ccf3ec105d411189fe72a47ca07072e2f Mon Sep 17 00:00:00 2001 From: sanderj Date: Wed, 14 Dec 2016 16:00:55 -0700 Subject: [PATCH 03/36] removed console log --- src/components/row.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/row.component.ts b/src/components/row.component.ts index b4c2b70..9551b0d 100644 --- a/src/components/row.component.ts +++ b/src/components/row.component.ts @@ -52,9 +52,8 @@ export class DataTableRow implements OnDestroy { } expandRow(event) { - console.log('expand row'); - this.expanded = !this.expanded; event.stopPropagation(); + this.expanded = !this.expanded; this.expandRowChange.emit(); } From ef7f48b1cf32272dcd720a20b2a0fd5f187d89ca Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Tue, 3 Jan 2017 15:31:01 -0700 Subject: [PATCH 04/36] fixed build with updated tsconfig renamed and versioned package for new NPM source. --- package.json | 6 +++--- tsconfig.json | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index a409a2a..e308fee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "angular-2-data-table", - "version": "0.1.2", + "name": "angular-datatable", + "version": "2.0.0", "description": "An Angular 2 data table, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", @@ -21,7 +21,7 @@ }, "repository": { "type": "git", - "url": "git://git@github.com/ggmod/angular-2-data-table.git" + "url": "git://git@github.com/briebugconsulting/ng-data-table.git" }, "peerDependencies": { "@angular/core": "^2.0.0" diff --git a/tsconfig.json b/tsconfig.json index afa16d1..cf05df2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,19 @@ { - "compileOnSave": false, "compilerOptions": { "declaration": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, + "lib": ["es6", "dom"], "mapRoot": "/", - "module": "commonjs", + "module": "es6", "moduleResolution": "node", - "noEmitOnError": true, - "noImplicitAny": false, "outDir": "dist/", "rootDir": "src/", "sourceMap": true, "target": "es5", - "inlineSources": true + "typeRoots": [ + "../node_modules/@types" + ] }, "exclude": [ "dist", From 529ab9f7847e8c746e401a6fc0d52c33f140999c Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Tue, 3 Jan 2017 15:37:11 -0700 Subject: [PATCH 05/36] updated readme --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 370776d..4535a0c 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,8 @@ 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. - ## Installing: -`npm install angular-2-data-table --save` +`npm install angular-datatable --save` #### Licensing From a067e22225209c78919a81d740d43c02780b3fb7 Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Tue, 3 Jan 2017 15:40:40 -0700 Subject: [PATCH 06/36] 2.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e308fee..7b2ed3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.0.0", + "version": "2.0.1", "description": "An Angular 2 data table, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From e4f04c438013e775279563360e0db7a6ac01eb6e Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Tue, 3 Jan 2017 16:27:49 -0700 Subject: [PATCH 07/36] turned back typescript to handle NgModule issue. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b2ed3d..297d036 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,6 @@ "@angular/core": "^2.0.0", "@angular/forms": "^2.0.0", "rxjs": "^5.0.0-beta.12", - "typescript": "^2.1.4" + "typescript": "~2.0.10" } } From 770dc364a9ee36e1a6de0b0571580125fd4e125f Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Tue, 3 Jan 2017 16:28:26 -0700 Subject: [PATCH 08/36] 2.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 297d036..08eadf5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.0.1", + "version": "2.0.2", "description": "An Angular 2 data table, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From e8ca0eb8c1c94c08981b78ecdfbe30c8f891b7fd Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Tue, 3 Jan 2017 16:34:19 -0700 Subject: [PATCH 09/36] returned to typescript ^2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08eadf5..2699aab 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,6 @@ "@angular/core": "^2.0.0", "@angular/forms": "^2.0.0", "rxjs": "^5.0.0-beta.12", - "typescript": "~2.0.10" + "typescript": "^2.0.0" } } From 3fdcb3e03ec97628de74ccb9e53bbfa35ae79624 Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Tue, 3 Jan 2017 16:36:25 -0700 Subject: [PATCH 10/36] 2.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2699aab..fb05a09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.0.2", + "version": "2.0.3", "description": "An Angular 2 data table, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From bf1618cc1c99d48f4102ffc4225260e009270c9f Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Wed, 4 Jan 2017 10:07:54 -0700 Subject: [PATCH 11/36] ignoring jsons and IDE settings. --- .gitignore | 3 ++- .npmignore | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2d45d27..ec314d5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /node_modules /.idea /typings -npm-debug.log \ No newline at end of file +npm-debug.log +/.vscode \ No newline at end of file diff --git a/.npmignore b/.npmignore index 43abdac..897b94d 100644 --- a/.npmignore +++ b/.npmignore @@ -2,4 +2,8 @@ /tmp /node_modules /.idea -/typings \ No newline at end of file +/typings +npm-debug.log +tsconfig.json +typings.json +/.vscode \ No newline at end of file From 0afa8f047534c47b6bcc395c45310a1d8ce4487f Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Wed, 4 Jan 2017 10:10:34 -0700 Subject: [PATCH 12/36] 2.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb05a09..5c77fe6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.0.3", + "version": "2.0.4", "description": "An Angular 2 data table, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From 0dff46776f99cf824af2b579d532dd1756efdb9f Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Wed, 4 Jan 2017 10:18:35 -0700 Subject: [PATCH 13/36] ignore npmignore --- .npmignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index 897b94d..2ed39f1 100644 --- a/.npmignore +++ b/.npmignore @@ -6,4 +6,5 @@ npm-debug.log tsconfig.json typings.json -/.vscode \ No newline at end of file +/.vscode +/.npmignore \ No newline at end of file From 7268516f7cf5a947c8d2bb82278534a4c4ea22fa Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Thu, 5 Jan 2017 15:59:23 -0700 Subject: [PATCH 14/36] Icons and bootstrap4 Modified icons from glyphicon to font awesome and checked appearance with bootstrap 4 --- src/components/header.template.ts | 4 ++-- src/components/row.template.ts | 4 ++-- src/components/table.template.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/header.template.ts b/src/components/header.template.ts index b299a86..b2d9423 100644 --- a/src/components/header.template.ts +++ b/src/components/header.template.ts @@ -4,11 +4,11 @@ export const HEADER_TEMPLATE = `
diff --git a/src/components/row.template.ts b/src/components/row.template.ts index b35956b..e7b049f 100644 --- a/src/components/row.template.ts +++ b/src/components/row.template.ts @@ -10,8 +10,8 @@ export const ROW_TEMPLATE = ` (click)="dataTable.rowClicked(_this, $event)" > - + diff --git a/src/components/table.template.ts b/src/components/table.template.ts index 4c68a29..a32828c 100644 --- a/src/components/table.template.ts +++ b/src/components/table.template.ts @@ -19,10 +19,10 @@ export const TABLE_TEMPLATE = ` - + - - + + From 6e2e5a087236cdde0129b234bf84b5abdcf68b37 Mon Sep 17 00:00:00 2001 From: Brian Seim Date: Thu, 5 Jan 2017 16:08:38 -0700 Subject: [PATCH 15/36] cleaned up old project references. --- README.md | 4 +++- package.json | 6 +++--- typings.json | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4535a0c..fa65577 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ A simple Angular 2 data table, with built-in solutions for features including: The component can be used not just with local data, but remote resources too: for example if the sorting and paging happen in the database. -The templates use bootstrap CSS class names, so the component requires a bootstrap .css file to be present in the application using it. +The templates use bootstrap 4 CSS class names, so the component requires a bootstrap .css file to be present in the application using it. + +The templates use Font Awesome CSS class names, so the component requires Font Awesome to be present in the application using it. ## Installing: `npm install angular-datatable --save` diff --git a/package.json b/package.json index 5c77fe6..200d0f2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-datatable", "version": "2.0.4", - "description": "An Angular 2 data table, with pagination, sorting, expandable rows etc.", + "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", "angular2", @@ -21,12 +21,12 @@ }, "repository": { "type": "git", - "url": "git://git@github.com/briebugconsulting/ng-data-table.git" + "url": "git://git@github.com/briebugconsulting/angular-datatable.git" }, "peerDependencies": { "@angular/core": "^2.0.0" }, - "author": "ggmod ", + "author": "BrieBug Developers ", "license": "MIT", "devDependencies": { "@angular/common": "^2.0.0", diff --git a/typings.json b/typings.json index b0bb089..f670590 100644 --- a/typings.json +++ b/typings.json @@ -1,5 +1,5 @@ { - "name": "angular-2-data-table", + "name": "angular-datatable", "dependencies": {}, "globalDevDependencies": { "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504" From 08afcd2c5704e46d45e2d93167d4dab8e163be9e Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 6 Jan 2017 06:32:29 -0700 Subject: [PATCH 16/36] build(circle-ci): adds circle-ci yml file for build process --- circle.yml | 22 ++++++++++++++++++++++ package.json | 12 +++++++++++- tsconfig.json | 6 ++---- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 circle.yml diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..300dcd6 --- /dev/null +++ b/circle.yml @@ -0,0 +1,22 @@ +## Customize the test machine +machine: + timezone: + America/Denver # Set the timezone + node: + version: 6.2.2 + +## Customize dependencies +dependencies: + pre: + - npm install -g typescript typings + +## customize test commands +test: + override: + - npm run build + +deployment: + production: + branch: master + commands: + - npm publish diff --git a/package.json b/package.json index 5c77fe6..dd45d19 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,17 @@ "@angular/common": "^2.0.0", "@angular/core": "^2.0.0", "@angular/forms": "^2.0.0", + "cz-conventional-changelog": "1.2.0", "rxjs": "^5.0.0-beta.12", - "typescript": "^2.0.0" + "typescript": "^2.0.0", + "validate-commit-msg": "2.8.2" + }, + "config": { + "ghooks": { + "commit-msg": "validate-commit-msg" + }, + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } } } diff --git a/tsconfig.json b/tsconfig.json index cf05df2..3e401fd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es6", "dom"], - "mapRoot": "/", "module": "es6", "moduleResolution": "node", "outDir": "dist/", @@ -13,11 +12,10 @@ "target": "es5", "typeRoots": [ "../node_modules/@types" - ] + ] }, "exclude": [ "dist", - "node_modules", - "index.ts" + "node_modules" ] } From 55124bc81b5ca862086a8ae0c7706205aa9718be Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Tue, 10 Jan 2017 12:21:35 -0700 Subject: [PATCH 17/36] 2.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0272cea..ea67d0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.0.4", + "version": "2.1.0", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From ed190a29007762ce16143b6d006bc662cfaa9916 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Tue, 10 Jan 2017 12:22:24 -0700 Subject: [PATCH 18/36] 2.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea67d0f..de87de9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.1.0", + "version": "2.1.1", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From de642f4fb838b2bf2c4b5063f3136db788f26668 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 13 Jan 2017 08:30:43 -0700 Subject: [PATCH 19/36] fix(update angular deps to latest): --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index de87de9..2e01d23 100644 --- a/package.json +++ b/package.json @@ -24,17 +24,17 @@ "url": "git://git@github.com/briebugconsulting/angular-datatable.git" }, "peerDependencies": { - "@angular/core": "^2.0.0" + "@angular/core": "^2.3.1" }, "author": "BrieBug Developers ", "license": "MIT", "devDependencies": { - "@angular/common": "^2.0.0", - "@angular/core": "^2.0.0", - "@angular/forms": "^2.0.0", + "@angular/common": "^2.3.1", + "@angular/core": "^2.3.1", + "@angular/forms": "^2.3.1", "cz-conventional-changelog": "1.2.0", - "rxjs": "^5.0.0-beta.12", - "typescript": "^2.0.0", + "rxjs": "^5.0.1", + "typescript": "~2.0.3", "validate-commit-msg": "2.8.2" }, "config": { From 4241b2cd4812b2938cff5abe77d38c15866f1752 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 13 Jan 2017 08:30:58 -0700 Subject: [PATCH 20/36] 2.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e01d23..54cf4cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.1.1", + "version": "2.1.2", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From 210cf800ae220e5569a2afebe70365ce9acd52aa Mon Sep 17 00:00:00 2001 From: Cilufg_local Date: Thu, 26 Jan 2017 07:37:38 -0700 Subject: [PATCH 21/36] change expanded row icon to real fa icon --- src/components/row.template.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/row.template.ts b/src/components/row.template.ts index e7b049f..e231ce6 100644 --- a/src/components/row.template.ts +++ b/src/components/row.template.ts @@ -10,7 +10,7 @@ export const ROW_TEMPLATE = ` (click)="dataTable.rowClicked(_this, $event)" > - From 74824ba75da4f068ee2c6e0e70e5985c0dfedafc Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 27 Jan 2017 05:20:14 -0700 Subject: [PATCH 22/36] feat(build): add npmrc for npm publish to have credentials --- .npmrc | 2 ++ src/index.ts | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..90a8d7b --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +user = briebug +password = $npm_password \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index ac90400..303ebcd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,31 +1,32 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; -import { DataTable} from './components/table.component'; -import { DataTableColumn } from './components/column.component'; -import { DataTableRow } from './components/row.component'; -import { DataTablePagination } from './components/pagination.component'; -import { DataTableHeader } from './components/header.component'; +import {DataTable} from './components/table.component'; +import {DataTableColumn} from './components/column.component'; +import {DataTableRow} from './components/row.component'; +import {DataTablePagination} from './components/pagination.component'; +import {DataTableHeader} from './components/header.component'; -import { PixelConverter } from './utils/px'; -import { Hide } from './utils/hide'; -import { MinPipe } from './utils/min'; +import {PixelConverter} from './utils/px'; +import {Hide} from './utils/hide'; +import {MinPipe} from './utils/min'; export * from './components/types'; export * from './tools/data-table-resource'; -export { DataTable, DataTableColumn, DataTableRow, DataTablePagination, DataTableHeader }; -export const DATA_TABLE_DIRECTIVES = [ DataTable, DataTableColumn ]; +export {DataTable, DataTableColumn, DataTableRow, DataTablePagination, DataTableHeader}; +export const DATA_TABLE_DIRECTIVES = [DataTable, DataTableColumn]; @NgModule({ - imports: [ CommonModule, FormsModule ], + imports: [CommonModule, FormsModule], declarations: [ DataTable, DataTableColumn, DataTableRow, DataTablePagination, DataTableHeader, PixelConverter, Hide, MinPipe ], - exports: [ DataTable, DataTableColumn ] + exports: [DataTable, DataTableColumn] }) -export class DataTableModule { } \ No newline at end of file +export class DataTableModule { +} \ No newline at end of file From 132e7a1a9901473a51da49bf80c091a8524d3bd1 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 27 Jan 2017 05:34:17 -0700 Subject: [PATCH 23/36] feat(build): add npmrc for npm publish to have credentials --- .npmrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.npmrc b/.npmrc index 90a8d7b..7fffe18 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,3 @@ -user = briebug -password = $npm_password \ No newline at end of file +username = briebug +password = ${npm_password} +email = developers@briebug.com \ No newline at end of file From 13982772cdba4c5d7320b58bcb1c13cec562b8a0 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 27 Jan 2017 05:43:18 -0700 Subject: [PATCH 24/36] feat(build): change login to npm method to use echo and pipe then publish --- .npmrc | 3 --- circle.yml | 3 ++- package.json | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 .npmrc diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 7fffe18..0000000 --- a/.npmrc +++ /dev/null @@ -1,3 +0,0 @@ -username = briebug -password = ${npm_password} -email = developers@briebug.com \ No newline at end of file diff --git a/circle.yml b/circle.yml index 300dcd6..146bb1c 100644 --- a/circle.yml +++ b/circle.yml @@ -19,4 +19,5 @@ deployment: production: branch: master commands: - - npm publish + - echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login + - npm run publish2npm diff --git a/package.json b/package.json index 54cf4cd..5e4c242 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "scripts": { "build": "rm -rf dist/* && tsc", "serve": "rm -rf dist/ && tsc -w", - "prepublish": "npm run build" + "prepublish": "npm run build", + "publish2npm": "publish" }, "repository": { "type": "git", From 000c5f45812a8e15f6dd3408970ab1f5245d025e Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 27 Jan 2017 05:46:34 -0700 Subject: [PATCH 25/36] feat(build): change login to npm method to use echo and pipe then publish --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e4c242..b30d74e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build": "rm -rf dist/* && tsc", "serve": "rm -rf dist/ && tsc -w", "prepublish": "npm run build", - "publish2npm": "publish" + "publish2npm": "npm publish" }, "repository": { "type": "git", From 52741af84513cecfa3ada362cb56183166cfb143 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 27 Jan 2017 05:50:54 -0700 Subject: [PATCH 26/36] feat(publish): add publish dep to handle pushing code up --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b30d74e..a2a51fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.1.2", + "version": "2.1.3", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", @@ -18,7 +18,7 @@ "build": "rm -rf dist/* && tsc", "serve": "rm -rf dist/ && tsc -w", "prepublish": "npm run build", - "publish2npm": "npm publish" + "publish2npm": "publish" }, "repository": { "type": "git", @@ -34,6 +34,7 @@ "@angular/core": "^2.3.1", "@angular/forms": "^2.3.1", "cz-conventional-changelog": "1.2.0", + "publish": "^0.6.0", "rxjs": "^5.0.1", "typescript": "~2.0.3", "validate-commit-msg": "2.8.2" From b76266d5a9f1e9f226471014d3e35534d607fc1c Mon Sep 17 00:00:00 2001 From: Alexei Mitskevich Date: Wed, 1 Feb 2017 11:10:57 -0700 Subject: [PATCH 27/36] feat(grid-download): download button with event --- package.json | 2 +- src/components/header.template.ts | 4 ++++ src/components/table.component.ts | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 54cf4cd..312eff7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.1.2", + "version": "2.1.3", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", diff --git a/src/components/header.template.ts b/src/components/header.template.ts index b2d9423..76194fe 100644 --- a/src/components/header.template.ts +++ b/src/components/header.template.ts @@ -10,6 +10,10 @@ export const HEADER_TEMPLATE = ` (click)="columnSelectorOpen = !columnSelectorOpen; $event.stopPropagation()" > +
diff --git a/src/components/table.component.ts b/src/components/table.component.ts index 8865f65..2c2b616 100644 --- a/src/components/table.component.ts +++ b/src/components/table.component.ts @@ -56,6 +56,7 @@ export class DataTable implements DataTableParams, OnInit { @Input() selectOnRowClick = false; @Input() autoReload = true; @Input() showReloading = false; + @Input() showDownloadButton = false; // UI state without input: @@ -207,6 +208,13 @@ export class DataTable implements DataTableParams, OnInit { }); } + // Download + @Output() download = new EventEmitter(); + + downloadItems(){ + this.download.emit(this._getRemoteParameters()); + } + // event handlers: @Output() rowClick = new EventEmitter(); From 8df50c3aaa78473e394b6b129052b1e6449582ac Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Thu, 2 Feb 2017 15:02:26 -0700 Subject: [PATCH 28/36] build(version): update version to 2.1.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a2a51fa..56fbcbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.1.3", + "version": "2.1.5", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From b8e4aa89b37cbbce46d8a541b8bc217b3db52584 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 23 Feb 2017 11:08:28 -0700 Subject: [PATCH 29/36] feat(sort): add custom sorting functionality * feat(sort): Added custom sorting functionality * feat(readme): Updated readme with custom sort documentation * fix(version): Restored version to 2.1.5 to match master --- README.md | 9 +++++++++ package.json | 2 +- src/components/column.component.ts | 7 ++++--- src/components/table.component.ts | 28 +++++++++++++++++++++------- src/components/types.ts | 4 +++- src/tools/data-table-resource.ts | 20 ++++++++++++-------- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index fa65577..1d40a1c 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,15 @@ The templates use Font Awesome CSS class names, so the component requires Font A ## Installing: `npm install angular-datatable --save` +## Usage: + +### Custom Sorting + +To make use of custom sort functionality, one must add a `[customSort]` binding to the data-table (if necessary for the default sort) or to the data-column (if necessary to sort that column). One must still specify the `[sortBy]` binding and specify the primary property of the bound data set that is being sorted, as this is fundamental to maintaining sort order (ASC or DESC). + +The `[customSort]` binding must bind to a function that implements the function signature defined by `DataTableSortCallback`. This function is the same as any standard JS Array.sort() callback, and in fact is actually passed to array.sort() when sorting occurs. + +If custom sort is not required, then only the `[sortBy]` binding is necessary. #### Licensing MIT License diff --git a/package.json b/package.json index 54cf4cd..5adbdca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.1.2", + "version": "2.1.5", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", diff --git a/src/components/column.component.ts b/src/components/column.component.ts index 0abb1af..0160c7d 100644 --- a/src/components/column.component.ts +++ b/src/components/column.component.ts @@ -1,10 +1,10 @@ import { Directive, Input, ContentChild, OnInit } from '@angular/core'; import { DataTableRow } from './row.component'; -import { CellCallback } from './types'; +import { CellCallback, DataTableSortCallback } from './types'; @Directive({ - selector: 'data-table-column' + selector: 'data-table-column' }) export class DataTableColumn implements OnInit { @@ -15,6 +15,7 @@ export class DataTableColumn implements OnInit { @Input() property: string; @Input() styleClass: string; @Input() cellColors: CellCallback; + @Input() customSort?: DataTableSortCallback; // init and state: @Input() width: number | string; @@ -50,4 +51,4 @@ export class DataTableColumn implements OnInit { }; } } -} +} \ No newline at end of file diff --git a/src/components/table.component.ts b/src/components/table.component.ts index 8865f65..b80c2fc 100644 --- a/src/components/table.component.ts +++ b/src/components/table.component.ts @@ -4,7 +4,7 @@ import { } from '@angular/core'; import { DataTableColumn } from './column.component'; import { DataTableRow } from './row.component'; -import { DataTableParams } from './types'; +import {DataTableParams, DataTableSortCallback} from './types'; import { RowCallback } from './types'; import { DataTableTranslations, defaultTranslations } from './types'; import { drag } from '../utils/drag'; @@ -14,9 +14,9 @@ import { TABLE_STYLE } from "./table.style"; @Component({ - selector: 'data-table', - template: TABLE_TEMPLATE, - styles: [TABLE_STYLE] + selector: 'data-table', + template: TABLE_TEMPLATE, + styles: [TABLE_STYLE] }) export class DataTable implements DataTableParams, OnInit { @@ -67,6 +67,7 @@ export class DataTable implements DataTableParams, OnInit { private _sortBy: string; private _sortAsc = true; + private _customSort: DataTableSortCallback = null; private _offset = 0; private _limit = 10; @@ -91,6 +92,16 @@ export class DataTable implements DataTableParams, OnInit { this._triggerReload(); } + @Input() + get customSort() { + return this._customSort; + } + + set customSort(value) { + this._customSort = value; + this._triggerReload(); + } + @Input() get offset() { return this._offset; @@ -128,9 +139,10 @@ export class DataTable implements DataTableParams, OnInit { // setting multiple observable properties simultaneously - sort(sortBy: string, asc: boolean) { + sort(sortBy: string, asc: boolean, customSort: DataTableSortCallback = null) { this.sortBy = sortBy; this.sortAsc = asc; + this.customSort = customSort; } // init @@ -189,6 +201,7 @@ export class DataTable implements DataTableParams, OnInit { _updateDisplayParams() { this._displayParams = { sortBy: this.sortBy, + customSort: this.customSort, sortAsc: this.sortAsc, offset: this.offset, limit: this.limit @@ -242,6 +255,7 @@ export class DataTable implements DataTableParams, OnInit { if (this.sortBy) { params.sortBy = this.sortBy; + params.customSort = this.customSort; params.sortAsc = this.sortAsc; } if (this.pagination) { @@ -254,7 +268,7 @@ export class DataTable implements DataTableParams, OnInit { private sortColumn(column: DataTableColumn) { if (column.sortable) { let ascending = this.sortBy === column.property ? !this.sortAsc : true; - this.sort(column.property, ascending); + this.sort(column.property, ascending, column.customSort); } } @@ -363,4 +377,4 @@ export class DataTable implements DataTableParams, OnInit { } return true; } -} +} \ No newline at end of file diff --git a/src/components/types.ts b/src/components/types.ts index 30769ec..68a8314 100644 --- a/src/components/types.ts +++ b/src/components/types.ts @@ -8,6 +8,7 @@ export type CellCallback = (item: any, row: DataTableRow, column: DataTableColum // export type HeaderCallback = (column: DataTableColumn) => string; +export type DataTableSortCallback = (a: any, b: any) => number; export interface DataTableTranslations { indexColumn: string; @@ -30,5 +31,6 @@ export interface DataTableParams { offset?: number; limit?: number; sortBy?: string; + customSort?: DataTableSortCallback; sortAsc?: boolean; -} +} \ No newline at end of file diff --git a/src/tools/data-table-resource.ts b/src/tools/data-table-resource.ts index 31a2768..222796d 100644 --- a/src/tools/data-table-resource.ts +++ b/src/tools/data-table-resource.ts @@ -15,13 +15,17 @@ export class DataTableResource { } if (params.sortBy) { - result.sort((a, b) => { - if (typeof a[params.sortBy] === 'string') { - return a[params.sortBy].localeCompare(b[params.sortBy]); - } else { - return a[params.sortBy] - b[params.sortBy]; - } - }); + if (!params.customSort) { + result.sort((a, b) => { + if (typeof a[params.sortBy] === 'string') { + return a[params.sortBy].localeCompare(b[params.sortBy]); + } else { + return a[params.sortBy] - b[params.sortBy]; + } + }); + } else { + result.sort(params.customSort); + } if (params.sortAsc === false) { result.reverse(); } @@ -45,4 +49,4 @@ export class DataTableResource { }); } -} +} \ No newline at end of file From b83abdf38e3929a0cc10ceda86f182a905fdb672 Mon Sep 17 00:00:00 2001 From: Jon Rista Date: Thu, 23 Feb 2017 11:47:41 -0700 Subject: [PATCH 30/36] feat(versioning): Added versioning documentation and bumped version to 2.2.0 for custom sort functionality --- VERSIONING.md | 19 +++++++++++++++++++ package.json | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 VERSIONING.md diff --git a/VERSIONING.md b/VERSIONING.md new file mode 100644 index 0000000..a9a389f --- /dev/null +++ b/VERSIONING.md @@ -0,0 +1,19 @@ +# Versioning Angular-DataTable + +Version maintenance is a critical aspect of maintaining a public NPM package. New versions must be carefully managed to ensure they properly publish. Moreso, proper linting and testing must be performed on each version before publishing to ensure a bad version is never published to the public NPM repository. + +Please follow this procedure to version angular-datatable before publishing: + +## Versioning Procedure + +On your development branch: + +1. Verify that you have the latest changes from development by rebasing or merging into your branch. +2. Run linting to ensure the code conforms to necessary style rules. +3. Run unit tests to ensure the code properly functions. +4. Bump the version number in package.json: + - Use revisions for small updates that fix bugs that do not otherwise change the functionality + - Use minor versions for small updates to functionality, if changes to not break backwards compatibility + - Use major versions for large updates to functionality, particularly if they involve breaking changes to backwards compatibility +5. PR your changes with the updated version into the develop branch +6. Request a repository owner to merge the changes into master, which will automatically invoke a publish to the public NPM repo \ No newline at end of file diff --git a/package.json b/package.json index 5adbdca..0fc1bc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.1.5", + "version": "2.2.0", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "keywords": [ "angular", From 433dd9204d94e902b1bc135e108c2fb8e2595a69 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Fri, 17 Mar 2017 07:14:08 -0600 Subject: [PATCH 31/36] fix(module): fix build process to produce a compatible module --- .gitignore | 7 +++++- package.json | 28 +++++++++++++-------- rollup.config.js | 19 ++++++++++++++ src/components/column.component.ts | 6 ++--- src/components/row.component.ts | 2 +- src/components/table.component.ts | 19 +++++++------- src/data-table.module.ts | 36 +++++++++++++++++++++++++++ src/index.ts | 40 +++++++----------------------- src/tools/data-table-resource.ts | 8 +++--- src/utils/hide.ts | 2 +- tsconfig.json | 37 ++++++++++++++++++--------- 11 files changed, 130 insertions(+), 74 deletions(-) create mode 100644 rollup.config.js create mode 100644 src/data-table.module.ts diff --git a/.gitignore b/.gitignore index ec314d5..11797e0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,9 @@ /.idea /typings npm-debug.log -/.vscode \ No newline at end of file +/.vscode +/src/**/*.js +/src/**/*.js.map +/src/**/*.json +/src/**/*.ngfactory.ts +/aot \ No newline at end of file diff --git a/package.json b/package.json index 0fc1bc4..a3e0670 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,11 @@ "data table", "pagination" ], - "main": "dist/index.js", - "typings": "dist/index.d.ts", "scripts": { - "build": "rm -rf dist/* && tsc", - "serve": "rm -rf dist/ && tsc -w", - "prepublish": "npm run build" + "transpile": "ngc", + "package": "rollup -c", + "minify": "uglifyjs dist/bundles/datatable.umd.js --screw-ie8 --compress --mangle --comments --output dist/bundles/datatable.umd.min.js", + "build": "npm run transpile && npm run package && npm run minify" }, "repository": { "type": "git", @@ -29,13 +28,20 @@ "author": "BrieBug Developers ", "license": "MIT", "devDependencies": { - "@angular/common": "^2.3.1", - "@angular/core": "^2.3.1", - "@angular/forms": "^2.3.1", + "@angular/common": "^2.4.0", + "@angular/compiler": "^2.4.9", + "@angular/compiler-cli": "^2.4.9", + "@angular/core": "^2.4.0", + "@angular/forms": "^2.4.0", + "@angular/platform-browser": "^2.4.0", + "@angular/platform-server": "^2.4.0", "cz-conventional-changelog": "1.2.0", - "rxjs": "^5.0.1", - "typescript": "~2.0.3", - "validate-commit-msg": "2.8.2" + "rollup": "^0.41.6", + "rxjs": "^5.1.0", + "typescript": "^2.0.10", + "uglify-js": "^2.8.12", + "validate-commit-msg": "2.8.2", + "zone.js": "^0.7.2" }, "config": { "ghooks": { diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..9ecd514 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,19 @@ +export default { + entry: 'dist/src/index.js', + dest: 'dist/bundles/datatable.umd.js', + sourceMap: false, + format: 'umd', + moduleName: 'ng.datatable', + globals: { + '@angular/core': 'ng.core', + '@angular/common': 'ng.common', + '@angular/forms': 'ng.forms', + 'rxjs/Observable': 'Rx', + 'rxjs/ReplaySubject': 'Rx', + 'rxjs/add/operator/map': 'Rx.Observable.prototype', + 'rxjs/add/operator/mergeMap': 'Rx.Observable.prototype', + 'rxjs/add/observable/fromEvent': 'Rx.Observable', + 'rxjs/add/observable/of': 'Rx.Observable' + }, + external: ['@angular/core', '@angular/common', '@angular/forms'] +} \ No newline at end of file diff --git a/src/components/column.component.ts b/src/components/column.component.ts index 0160c7d..aac4bcb 100644 --- a/src/components/column.component.ts +++ b/src/components/column.component.ts @@ -15,14 +15,14 @@ export class DataTableColumn implements OnInit { @Input() property: string; @Input() styleClass: string; @Input() cellColors: CellCallback; - @Input() customSort?: DataTableSortCallback; + @Input() customSort: DataTableSortCallback; // init and state: @Input() width: number | string; @Input() visible = true; - @ContentChild('dataTableCell') cellTemplate; - @ContentChild('dataTableHeader') headerTemplate; + @ContentChild('dataTableCell') cellTemplate: any; + @ContentChild('dataTableHeader') headerTemplate: any; getCellColor(row: DataTableRow, index: number) { if (this.cellColors !== undefined) { diff --git a/src/components/row.component.ts b/src/components/row.component.ts index 9551b0d..77668b7 100644 --- a/src/components/row.component.ts +++ b/src/components/row.component.ts @@ -51,7 +51,7 @@ export class DataTableRow implements OnDestroy { return ''; } - expandRow(event) { + expandRow(event: Event) { event.stopPropagation(); this.expanded = !this.expanded; this.expandRowChange.emit(); diff --git a/src/components/table.component.ts b/src/components/table.component.ts index b80c2fc..534d05f 100644 --- a/src/components/table.component.ts +++ b/src/components/table.component.ts @@ -67,7 +67,7 @@ export class DataTable implements DataTableParams, OnInit { private _sortBy: string; private _sortAsc = true; - private _customSort: DataTableSortCallback = null; + private _customSort: DataTableSortCallback; private _offset = 0; private _limit = 10; @@ -139,7 +139,7 @@ export class DataTable implements DataTableParams, OnInit { // setting multiple observable properties simultaneously - sort(sortBy: string, asc: boolean, customSort: DataTableSortCallback = null) { + sort(sortBy: string, asc: boolean, customSort: DataTableSortCallback) { this.sortBy = sortBy; this.sortAsc = asc; this.customSort = customSort; @@ -164,9 +164,9 @@ export class DataTable implements DataTableParams, OnInit { } private _initDefaultClickEvents() { - this.headerClick.subscribe(tableEvent => this.sortColumn(tableEvent.column)); + this.headerClick.subscribe((tableEvent: any) => this.sortColumn(tableEvent.column)); if (this.selectOnRowClick) { - this.rowClick.subscribe(tableEvent => tableEvent.row.selected = !tableEvent.row.selected); + this.rowClick.subscribe((tableEvent: any) => tableEvent.row.selected = !tableEvent.row.selected); } } @@ -208,7 +208,7 @@ export class DataTable implements DataTableParams, OnInit { }; } - _scheduledReload = null; + _scheduledReload: any = null; // for avoiding cascading reloads if multiple params are set at once: _triggerReload() { @@ -228,11 +228,11 @@ export class DataTable implements DataTableParams, OnInit { @Output() cellClick = new EventEmitter(); @Output() rowExpandChange = new EventEmitter(); - private rowClicked(row: DataTableRow, event) { + private rowClicked(row: DataTableRow, event: Event) { this.rowClick.emit({ row, event }); } - private rowDoubleClicked(row: DataTableRow, event) { + private rowDoubleClicked(row: DataTableRow, event: Event) { this.rowDoubleClick.emit({ row, event }); } @@ -310,7 +310,6 @@ export class DataTable implements DataTableParams, OnInit { } onRowSelectChanged(row: DataTableRow) { - // maintain the selectedRow(s) view if (this.multiSelect) { let index = this.selectedRows.indexOf(row); @@ -323,7 +322,7 @@ export class DataTable implements DataTableParams, OnInit { if (row.selected) { this.selectedRow = row; } else if (this.selectedRow === row) { - this.selectedRow = undefined; + this.selectedRow = row; } } @@ -337,7 +336,7 @@ export class DataTable implements DataTableParams, OnInit { } } - onRowExpandChanged(row) { + onRowExpandChanged(row: DataTableRow) { this.rowExpandChange.emit(row); } diff --git a/src/data-table.module.ts b/src/data-table.module.ts new file mode 100644 index 0000000..1c21d18 --- /dev/null +++ b/src/data-table.module.ts @@ -0,0 +1,36 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; + +import {DataTable} from './components/table.component'; +import {DataTableColumn} from './components/column.component'; +import {DataTableRow} from './components/row.component'; +import {DataTablePagination} from './components/pagination.component'; +import {DataTableHeader} from './components/header.component'; + +import {PixelConverter} from './utils/px'; +import {Hide} from './utils/hide'; +import {MinPipe} from './utils/min'; + +@NgModule({ + imports: [ + CommonModule, + FormsModule + ], + declarations: [ + DataTable, + DataTableColumn, + DataTableRow, + DataTablePagination, + DataTableHeader, + PixelConverter, + Hide, + MinPipe + ], + exports: [ + DataTable, + DataTableColumn + ] +}) +export class DataTableModule { +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index ac90400..63eae74 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,31 +1,9 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import { DataTable} from './components/table.component'; -import { DataTableColumn } from './components/column.component'; -import { DataTableRow } from './components/row.component'; -import { DataTablePagination } from './components/pagination.component'; -import { DataTableHeader } from './components/header.component'; - -import { PixelConverter } from './utils/px'; -import { Hide } from './utils/hide'; -import { MinPipe } from './utils/min'; - -export * from './components/types'; -export * from './tools/data-table-resource'; - -export { DataTable, DataTableColumn, DataTableRow, DataTablePagination, DataTableHeader }; -export const DATA_TABLE_DIRECTIVES = [ DataTable, DataTableColumn ]; - - -@NgModule({ - imports: [ CommonModule, FormsModule ], - declarations: [ - DataTable, DataTableColumn, - DataTableRow, DataTablePagination, DataTableHeader, - PixelConverter, Hide, MinPipe - ], - exports: [ DataTable, DataTableColumn ] -}) -export class DataTableModule { } \ No newline at end of file +export {DataTable} from './components/table.component'; +export {DataTableColumn} from './components/column.component'; +export {DataTableRow} from './components/row.component'; +export {DataTablePagination} from './components/pagination.component'; +export {DataTableHeader} from './components/header.component'; + +export {DataTableModule} from './data-table.module'; +export {DataTableParams, DataTableSortCallback, DataTableTranslations, defaultTranslations} from './components/types'; +export {DataTableResource} from './tools/data-table-resource'; diff --git a/src/tools/data-table-resource.ts b/src/tools/data-table-resource.ts index 222796d..fff2e84 100644 --- a/src/tools/data-table-resource.ts +++ b/src/tools/data-table-resource.ts @@ -16,11 +16,11 @@ export class DataTableResource { if (params.sortBy) { if (!params.customSort) { - result.sort((a, b) => { - if (typeof a[params.sortBy] === 'string') { - return a[params.sortBy].localeCompare(b[params.sortBy]); + result.sort((a: any, b: any) => { + if (typeof a[ params.sortBy] === 'string') { + return a[ params.sortBy].localeCompare(b[ params.sortBy]); } else { - return a[params.sortBy] - b[params.sortBy]; + return a[ params.sortBy] - b[ params.sortBy]; } }); } else { diff --git a/src/utils/hide.ts b/src/utils/hide.ts index 0c98ec8..caa01f1 100644 --- a/src/utils/hide.ts +++ b/src/utils/hide.ts @@ -8,7 +8,7 @@ function isBlank(obj: any): boolean { @Directive({ selector: '[hide]', inputs: ['hide'] }) export class Hide { - private _prevCondition: boolean = null; + private _prevCondition: boolean = false; private _displayStyle: string; constructor(private _elementRef: ElementRef, private _renderer: Renderer) { } diff --git a/tsconfig.json b/tsconfig.json index 3e401fd..90e6204 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,21 +1,34 @@ { "compilerOptions": { + "baseUrl": "src", "declaration": true, - "emitDecoratorMetadata": true, + "stripInternal": true, "experimentalDecorators": true, - "lib": ["es6", "dom"], - "module": "es6", + "strictNullChecks": true, + "noImplicitAny": true, + "module": "es2015", "moduleResolution": "node", - "outDir": "dist/", - "rootDir": "src/", + "paths": { + "@angular/core": ["node_modules/@angular/core"], + "@angular/common": ["node_modules/@angular/common"], + "@angular/forms": ["node_modules/@angular/forms"], + "rxjs/*": ["node_modules/rxjs/*"] + }, + "rootDir": ".", + "outDir": "dist", "sourceMap": true, + "inlineSources": true, "target": "es5", - "typeRoots": [ - "../node_modules/@types" + "skipLibCheck": true, + "lib": [ + "es2016", + "dom" ] }, - "exclude": [ - "dist", - "node_modules" - ] -} + "files": [ + "src/index.ts" + ], + "angularCompilerOptions": { + "strictMetadataEmit": true + } +} \ No newline at end of file From 777ba0edd662c9c0e40575c82ac48a923f8ddb41 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Mon, 20 Mar 2017 14:47:17 -0600 Subject: [PATCH 32/36] fix(npm): update build process to build umd component --- circle.yml | 1 + package.json | 3 ++- src/data-table.module.ts | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index 146bb1c..a88a568 100644 --- a/circle.yml +++ b/circle.yml @@ -20,4 +20,5 @@ deployment: branch: master commands: - echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login + - cd dist - npm run publish2npm diff --git a/package.json b/package.json index a3e0670..5d93c65 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "transpile": "ngc", "package": "rollup -c", "minify": "uglifyjs dist/bundles/datatable.umd.js --screw-ie8 --compress --mangle --comments --output dist/bundles/datatable.umd.min.js", - "build": "npm run transpile && npm run package && npm run minify" + "build": "npm run transpile && npm run package && npm run minify", + "publish2npm": "publish" }, "repository": { "type": "git", diff --git a/src/data-table.module.ts b/src/data-table.module.ts index 1c21d18..bcfa164 100644 --- a/src/data-table.module.ts +++ b/src/data-table.module.ts @@ -29,7 +29,13 @@ import {MinPipe} from './utils/min'; ], exports: [ DataTable, - DataTableColumn + DataTableColumn, + DataTableRow, + DataTablePagination, + DataTableHeader, + PixelConverter, + Hide, + MinPipe ] }) export class DataTableModule { From 276fa90ec1f1bdf67b95d247dace27e73fa39523 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Mon, 20 Mar 2017 14:53:35 -0600 Subject: [PATCH 33/36] refactor(npm): add dist/package.json to git --- .gitignore | 3 ++- dist/package.json | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 dist/package.json diff --git a/.gitignore b/.gitignore index 11797e0..4e0b28d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -/dist +!*/dist/package.json +/dist/**/ /tmp /node_modules /.idea diff --git a/dist/package.json b/dist/package.json new file mode 100644 index 0000000..1f5d620 --- /dev/null +++ b/dist/package.json @@ -0,0 +1,37 @@ +{ + "name": "angular-datatable", + "version": "2.2.0", + "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", + "main": "bundles/datatable.umd.js", + "module": "src/index.js", + "typings": "src/index.d.ts", + "keywords": [ + "angular", + "angular2", + "Angular 2", + "ng2", + "ngx", + "datatable", + "data-table", + "data table", + "pagination" + ], + "author": "BrieBug Developers ", + "license": "MIT", + "repository": { + "type": "git", + "url": "git://git@github.com/briebug/angular-datatable.git" + }, + "homepage": "https://github.com/briebug/angular-datatable", + "bugs": { + "url": "https://github.com/briebug/angular-datatable/issues" + }, + "peerDependencies": { + "@angular/core": "^2.4.0", + "@angular/common": "^2.4.0", + "@angular/forms": "^2.4.0", + "reflect-metadata": "^0.1.8", + "rxjs": "^5.0.1", + "zone.js": "^0.7.2" + } +} \ No newline at end of file From 3b847a91d9d5c9d266fa74c8d06a2957b4223619 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Wed, 22 Mar 2017 09:29:56 -0600 Subject: [PATCH 34/36] refactor(module): modify build method to produce an angular 2.4 compatible module --- .gitignore | 9 +++---- .npmignore | 11 +------- circle.yml | 2 +- dist/package.json | 4 +-- index.ts | 6 +++++ package.json | 45 +++++++++++++++++-------------- rollup.config.js | 15 +++-------- src/components/table.component.ts | 32 +++++++++++----------- src/index.ts | 10 +------ tsconfig.json | 9 +++---- typings.json | 7 ----- 11 files changed, 63 insertions(+), 87 deletions(-) create mode 100644 index.ts delete mode 100644 typings.json diff --git a/.gitignore b/.gitignore index 4e0b28d..93a5ab4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,12 @@ -!*/dist/package.json -/dist/**/ +!dist/package.json +dist/* /tmp /node_modules /.idea /typings npm-debug.log /.vscode -/src/**/*.js -/src/**/*.js.map -/src/**/*.json +/src/**/*.js* /src/**/*.ngfactory.ts +**/*.ngsummary.json /aot \ No newline at end of file diff --git a/.npmignore b/.npmignore index 2ed39f1..e831038 100644 --- a/.npmignore +++ b/.npmignore @@ -1,10 +1 @@ - -/tmp -/node_modules -/.idea -/typings -npm-debug.log -tsconfig.json -typings.json -/.vscode -/.npmignore \ No newline at end of file +src \ No newline at end of file diff --git a/circle.yml b/circle.yml index a88a568..ab1ca8b 100644 --- a/circle.yml +++ b/circle.yml @@ -3,7 +3,7 @@ machine: timezone: America/Denver # Set the timezone node: - version: 6.2.2 + version: 6.9.4 ## Customize dependencies dependencies: diff --git a/dist/package.json b/dist/package.json index 1f5d620..3b0dead 100644 --- a/dist/package.json +++ b/dist/package.json @@ -3,8 +3,8 @@ "version": "2.2.0", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "main": "bundles/datatable.umd.js", - "module": "src/index.js", - "typings": "src/index.d.ts", + "module": "index.js", + "typings": "index.d.ts", "keywords": [ "angular", "angular2", diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..e0192f9 --- /dev/null +++ b/index.ts @@ -0,0 +1,6 @@ +/** + * @module + * @description + * Entry point for all public APIs of the Angular Module + */ +export * from './src/index'; diff --git a/package.json b/package.json index 5d93c65..f35bf53 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,9 @@ { "name": "angular-datatable", - "version": "2.2.0", + "version": "2.2.1", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", + "main": "dist/bundles/angular-datatable.umd.js", + "module": "dist/index.js", "keywords": [ "angular", "angular2", @@ -13,37 +15,40 @@ "pagination" ], "scripts": { - "transpile": "ngc", - "package": "rollup -c", - "minify": "uglifyjs dist/bundles/datatable.umd.js --screw-ie8 --compress --mangle --comments --output dist/bundles/datatable.umd.min.js", - "build": "npm run transpile && npm run package && npm run minify", - "publish2npm": "publish" + "cleanup": "rimraf dist/bundles dist/src dist/index.d.ts dist/index.metadata.json dist/index.js dist/index.js.map dist/LICENSE dist/README.md", + "bundling": "rollup -c", + "minify": "uglifyjs dist/bundles/angular-datatable.umd.js --screw-ie8 --compress --mangle --comments --output dist/bundles/angular-datatable.umd.min.js", + "copy": "copyfiles LICENSE README.md dist", + "build": "npm run cleanup && ngc && npm run bundling && npm run minify && npm run copy", + "build-only": "npm run cleanup && ngc", + "publish-to-npm": "cd dist && npm publish", + "link": "cd dist && npm link && cd .." }, "repository": { "type": "git", "url": "git://git@github.com/briebugconsulting/angular-datatable.git" }, - "peerDependencies": { - "@angular/core": "^2.3.1" - }, "author": "BrieBug Developers ", "license": "MIT", - "devDependencies": { + "dependencies": { "@angular/common": "^2.4.0", - "@angular/compiler": "^2.4.9", - "@angular/compiler-cli": "^2.4.9", "@angular/core": "^2.4.0", "@angular/forms": "^2.4.0", - "@angular/platform-browser": "^2.4.0", - "@angular/platform-server": "^2.4.0", - "cz-conventional-changelog": "1.2.0", - "rollup": "^0.41.6", - "rxjs": "^5.1.0", - "typescript": "^2.0.10", - "uglify-js": "^2.8.12", - "validate-commit-msg": "2.8.2", + "reflect-metadata": "^0.1.8", + "rxjs": "^5.0.3", "zone.js": "^0.7.2" }, + "devDependencies": { + "@angular/compiler": "^2.4.0", + "@angular/compiler-cli": "^2.4.0", + "copyfiles": "^1.2.0", + "cz-conventional-changelog": "1.2.0", + "rimraf": "^2.6.1", + "rollup": "^0.37.0", + "typescript": "~2.0.10", + "uglify-js": "^2.7.5", + "validate-commit-msg": "2.8.2" + }, "config": { "ghooks": { "commit-msg": "validate-commit-msg" diff --git a/rollup.config.js b/rollup.config.js index 9ecd514..114ebe6 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,19 +1,12 @@ export default { - entry: 'dist/src/index.js', - dest: 'dist/bundles/datatable.umd.js', + entry: 'dist/index.js', + dest: 'dist/bundles/angular-datatable.umd.js', sourceMap: false, format: 'umd', moduleName: 'ng.datatable', globals: { '@angular/core': 'ng.core', '@angular/common': 'ng.common', - '@angular/forms': 'ng.forms', - 'rxjs/Observable': 'Rx', - 'rxjs/ReplaySubject': 'Rx', - 'rxjs/add/operator/map': 'Rx.Observable.prototype', - 'rxjs/add/operator/mergeMap': 'Rx.Observable.prototype', - 'rxjs/add/observable/fromEvent': 'Rx.Observable', - 'rxjs/add/observable/of': 'Rx.Observable' - }, - external: ['@angular/core', '@angular/common', '@angular/forms'] + '@angular/forms': 'ng.forms' + } } \ No newline at end of file diff --git a/src/components/table.component.ts b/src/components/table.component.ts index 355b31e..3f7f00c 100644 --- a/src/components/table.component.ts +++ b/src/components/table.component.ts @@ -2,16 +2,15 @@ import { Component, Input, Output, EventEmitter, ContentChildren, QueryList, TemplateRef, ContentChild, ViewChildren, OnInit } from '@angular/core'; -import { DataTableColumn } from './column.component'; -import { DataTableRow } from './row.component'; -import {DataTableParams, DataTableSortCallback} from './types'; -import { RowCallback } from './types'; -import { DataTableTranslations, defaultTranslations } from './types'; -import { drag } from '../utils/drag'; -import { TABLE_TEMPLATE } from './table.template'; -import { TABLE_STYLE } from "./table.style"; - +import {DataTableColumn} from './column.component'; +import {DataTableRow} from './row.component'; +import {DataTableParams, DataTableSortCallback} from './types'; +import {RowCallback} from './types'; +import {DataTableTranslations, defaultTranslations} from './types'; +import {drag} from '../utils/drag'; +import {TABLE_TEMPLATE} from './table.template'; +import {TABLE_STYLE} from "./table.style"; @Component({ selector: 'data-table', @@ -224,7 +223,7 @@ export class DataTable implements DataTableParams, OnInit { // Download @Output() download = new EventEmitter(); - downloadItems(){ + downloadItems() { this.download.emit(this._getRemoteParameters()); } @@ -237,23 +236,23 @@ export class DataTable implements DataTableParams, OnInit { @Output() rowExpandChange = new EventEmitter(); private rowClicked(row: DataTableRow, event: Event) { - this.rowClick.emit({ row, event }); + this.rowClick.emit({row, event}); } private rowDoubleClicked(row: DataTableRow, event: Event) { - this.rowDoubleClick.emit({ row, event }); + this.rowDoubleClick.emit({row, event}); } private headerClicked(column: DataTableColumn, event: MouseEvent) { if (!this._resizeInProgress) { - this.headerClick.emit({ column, event }); + this.headerClick.emit({column, event}); } else { this._resizeInProgress = false; // this is because I can't prevent click from mousup of the drag end } } private cellClicked(column: DataTableColumn, row: DataTableRow, event: MouseEvent) { - this.cellClick.emit({ row, column, event }); + this.cellClick.emit({row, column, event}); } // functions: @@ -351,7 +350,7 @@ export class DataTable implements DataTableParams, OnInit { // other: get substituteItems() { - return Array.from({ length: this.displayParams.limit - this.items.length }); + return Array.from({length: this.displayParams.limit - this.items.length}); } // column resizing: @@ -377,8 +376,7 @@ export class DataTable implements DataTableParams, OnInit { Without the limits, resizing can make the next column disappear completely, and even increase the table width. The current implementation suffers from the fact, that offsetWidth sometimes contains out-of-date values. */ - if ((dx < 0 && (columnElement.offsetWidth + dx) <= this.resizeLimit) || - !columnElement.nextElementSibling || // resizing doesn't make sense for the last visible column + if ((dx < 0 && (columnElement.offsetWidth + dx) <= this.resizeLimit) || !columnElement.nextElementSibling || // resizing doesn't make sense for the last visible column (dx >= 0 && (( columnElement.nextElementSibling).offsetWidth + dx) <= this.resizeLimit)) { return false; } diff --git a/src/index.ts b/src/index.ts index 63eae74..c9e504e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1 @@ -export {DataTable} from './components/table.component'; -export {DataTableColumn} from './components/column.component'; -export {DataTableRow} from './components/row.component'; -export {DataTablePagination} from './components/pagination.component'; -export {DataTableHeader} from './components/header.component'; - -export {DataTableModule} from './data-table.module'; -export {DataTableParams, DataTableSortCallback, DataTableTranslations, defaultTranslations} from './components/types'; -export {DataTableResource} from './tools/data-table-resource'; +export {DataTableModule} from './data-table.module'; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 90e6204..5db88eb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,18 +1,17 @@ { "compilerOptions": { - "baseUrl": "src", + "baseUrl": ".", "declaration": true, "stripInternal": true, "experimentalDecorators": true, - "strictNullChecks": true, + "strictNullChecks": false, "noImplicitAny": true, "module": "es2015", "moduleResolution": "node", "paths": { "@angular/core": ["node_modules/@angular/core"], "@angular/common": ["node_modules/@angular/common"], - "@angular/forms": ["node_modules/@angular/forms"], - "rxjs/*": ["node_modules/rxjs/*"] + "@angular/forms": ["node_modules/@angular/forms"] }, "rootDir": ".", "outDir": "dist", @@ -26,7 +25,7 @@ ] }, "files": [ - "src/index.ts" + "index.ts" ], "angularCompilerOptions": { "strictMetadataEmit": true diff --git a/typings.json b/typings.json deleted file mode 100644 index f670590..0000000 --- a/typings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "angular-datatable", - "dependencies": {}, - "globalDevDependencies": { - "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504" - } -} From a82955f459a7fd7c1035a1d2c37b010cebab558a Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Wed, 22 Mar 2017 09:41:31 -0600 Subject: [PATCH 35/36] merge develop --- circle.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index ab1ca8b..097975c 100644 --- a/circle.yml +++ b/circle.yml @@ -20,5 +20,4 @@ deployment: branch: master commands: - echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login - - cd dist - - npm run publish2npm + - npm run publish-to-npm From 7216e669d472a583f1b7fd364406d37867816191 Mon Sep 17 00:00:00 2001 From: Jesse Sanders Date: Wed, 22 Mar 2017 09:44:32 -0600 Subject: [PATCH 36/36] fix(build): set version to 2.2.1 --- dist/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/package.json b/dist/package.json index 3b0dead..1b3b39b 100644 --- a/dist/package.json +++ b/dist/package.json @@ -1,6 +1,6 @@ { "name": "angular-datatable", - "version": "2.2.0", + "version": "2.2.1", "description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.", "main": "bundles/datatable.umd.js", "module": "index.js",