Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add expandRow EventEmitter to allow more dynamic expanded row data loads #6

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f97c90d
feat(row-expand-event) adds row expand change emitter and doesnt rend…
Dec 14, 2016
d291421
fix debug issues found
Dec 14, 2016
0d65022
removed console log
Dec 14, 2016
ef7f48b
fixed build with updated tsconfig
brianseim Jan 3, 2017
529ab9f
updated readme
brianseim Jan 3, 2017
a067e22
2.0.1
brianseim Jan 3, 2017
e4f04c4
turned back typescript to handle NgModule issue.
brianseim Jan 3, 2017
770dc36
2.0.2
brianseim Jan 3, 2017
e8ca0eb
returned to typescript ^2.0.0
brianseim Jan 3, 2017
3fdcb3e
2.0.3
brianseim Jan 3, 2017
bf1618c
ignoring jsons and IDE settings.
brianseim Jan 4, 2017
0afa8f0
2.0.4
brianseim Jan 4, 2017
0dff467
ignore npmignore
brianseim Jan 4, 2017
7268516
Icons and bootstrap4
brianseim Jan 5, 2017
6e2e5a0
cleaned up old project references.
brianseim Jan 5, 2017
948e9db
Merge pull request #1 from briebugconsulting/briandev
jessesanders Jan 5, 2017
08afcd2
build(circle-ci): adds circle-ci yml file for build process
jessesanders Jan 6, 2017
2689e76
Merge branch 'develop' of github.com:briebugconsulting/angular-datata…
jessesanders Jan 6, 2017
55124bc
2.1.0
jessesanders Jan 10, 2017
ed190a2
2.1.1
jessesanders Jan 10, 2017
53fa2c4
Merge pull request #2 from briebugconsulting/develop
jessesanders Jan 10, 2017
de642f4
fix(update angular deps to latest):
jessesanders Jan 13, 2017
4241b2c
2.1.2
jessesanders Jan 13, 2017
4578b1d
Merge branch 'develop'
jessesanders Jan 13, 2017
210cf80
change expanded row icon to real fa icon
Jan 26, 2017
4780f8e
Merge pull request #4 from briebugconsulting/font-awesome
jessesanders Jan 27, 2017
1ed4f04
Merge pull request #5 from briebugconsulting/develop
jessesanders Jan 27, 2017
74824ba
feat(build): add npmrc for npm publish to have credentials
jessesanders Jan 27, 2017
132e7a1
feat(build): add npmrc for npm publish to have credentials
jessesanders Jan 27, 2017
1398277
feat(build): change login to npm method to use echo and pipe then pub…
jessesanders Jan 27, 2017
000c5f4
feat(build): change login to npm method to use echo and pipe then pub…
jessesanders Jan 27, 2017
52741af
feat(publish): add publish dep to handle pushing code up
jessesanders Jan 27, 2017
b76266d
feat(grid-download): download button with event
amitskevich Feb 1, 2017
4193653
Merge pull request #6 from briebugconsulting/grid-download
jessesanders Feb 1, 2017
8df50c3
build(version): update version to 2.1.5
jessesanders Feb 2, 2017
b8e4aa8
feat(sort): add custom sorting functionality
jrista Feb 23, 2017
d9550de
Merge pull request #8 from briebugconsulting/develop
jessesanders Feb 23, 2017
b83abdf
feat(versioning): Added versioning documentation and bumped version t…
Feb 23, 2017
0bb15c7
Merge pull request #9 from briebugconsulting/version-updates
jessesanders Feb 23, 2017
eab579d
Merge pull request #10 from briebugconsulting/develop
jessesanders Feb 23, 2017
433dd92
fix(module): fix build process to produce a compatible module
jessesanders Mar 17, 2017
0676943
Merge branch 'develop' into module-upgrade
jessesanders Mar 17, 2017
777ba0e
fix(npm): update build process to build umd component
jessesanders Mar 20, 2017
276fa90
refactor(npm): add dist/package.json to git
jessesanders Mar 20, 2017
09f828d
Merge pull request #11 from briebug/master
jessesanders Mar 20, 2017
3b847a9
refactor(module): modify build method to produce an angular 2.4 compa…
jessesanders Mar 22, 2017
639c5b5
Merge pull request #12 from briebug/module-upgrade
jessesanders Mar 22, 2017
77649af
Merge pull request #13 from briebug/develop
jessesanders Mar 22, 2017
a82955f
merge develop
jessesanders Mar 22, 2017
7216e66
fix(build): set version to 2.2.1
jessesanders Mar 22, 2017
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
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/dist
!dist/package.json
dist/*
/tmp
/node_modules
/.idea
/typings
npm-debug.log
npm-debug.log
/.vscode
/src/**/*.js*
/src/**/*.ngfactory.ts
**/*.ngsummary.json
/aot
6 changes: 1 addition & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@

/tmp
/node_modules
/.idea
/typings
src
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ 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.

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.
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-2-data-table --save`
`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
19 changes: 19 additions & 0 deletions VERSIONING.md
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Customize the test machine
machine:
timezone:
America/Denver # Set the timezone
node:
version: 6.9.4

## Customize dependencies
dependencies:
pre:
- npm install -g typescript typings

## customize test commands
test:
override:
- npm run build

deployment:
production:
branch: master
commands:
- echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login
- npm run publish-to-npm
37 changes: 37 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "angular-datatable",
"version": "2.2.1",
"description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.",
"main": "bundles/datatable.umd.js",
"module": "index.js",
"typings": "index.d.ts",
"keywords": [
"angular",
"angular2",
"Angular 2",
"ng2",
"ngx",
"datatable",
"data-table",
"data table",
"pagination"
],
"author": "BrieBug Developers <developers@briebug.com>",
"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"
}
}
6 changes: 6 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @module
* @description
* Entry point for all public APIs of the Angular Module
*/
export * from './src/index';
58 changes: 40 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "angular-2-data-table",
"version": "0.1.2",
"description": "An Angular 2 data table, with pagination, sorting, expandable rows etc.",
"name": "angular-datatable",
"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",
Expand All @@ -12,27 +14,47 @@
"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"
"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/ggmod/angular-2-data-table.git"
"url": "git://git@github.com/briebugconsulting/angular-datatable.git"
},
"peerDependencies": {
"@angular/core": "^2.0.0"
},
"author": "ggmod <ggmod64@gmail.com>",
"author": "BrieBug Developers <developers@briebug.com>",
"license": "MIT",
"dependencies": {
"@angular/common": "^2.4.0",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"reflect-metadata": "^0.1.8",
"rxjs": "^5.0.3",
"zone.js": "^0.7.2"
},
"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"
"@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"
},
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
12 changes: 12 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
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'
}
}
11 changes: 6 additions & 5 deletions src/components/column.component.ts
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -15,13 +15,14 @@ export class DataTableColumn implements OnInit {
@Input() property: string;
@Input() styleClass: string;
@Input() cellColors: CellCallback;
@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) {
Expand Down Expand Up @@ -50,4 +51,4 @@ export class DataTableColumn implements OnInit {
};
}
}
}
}
8 changes: 6 additions & 2 deletions src/components/header.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ export const HEADER_TEMPLATE = `
<div class="button-panel">
<button type="button" class="btn btn-default btn-sm refresh-button"
(click)="dataTable.reloadItems()">
<span class="glyphicon glyphicon-refresh"></span>
<i class="fa fa-refresh fa-lg"></i>
</button>
<button type="button" class="btn btn-default btn-sm column-selector-button" [class.active]="columnSelectorOpen"
(click)="columnSelectorOpen = !columnSelectorOpen; $event.stopPropagation()" >
<span class="glyphicon glyphicon-list"></span>
<i class="fa fa-list fa-lg"></i>
</button>
<button *ngIf="dataTable.showDownloadButton" type="button" class="btn btn-default btn-sm download-button"
(click)="dataTable.downloadItems()">
<i class="fa fa-download fa-lg"></i>
</button>
<div class="column-selector-wrapper" (click)="$event.stopPropagation()">
<div *ngIf="columnSelectorOpen" class="column-selector-box panel panel-default">
Expand Down
7 changes: 7 additions & 0 deletions src/components/row.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +51,12 @@ export class DataTableRow implements OnDestroy {
return '';
}

expandRow(event: Event) {
event.stopPropagation();
this.expanded = !this.expanded;
this.expandRowChange.emit();
}

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

ngOnDestroy() {
Expand Down
8 changes: 4 additions & 4 deletions src/components/row.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ 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" (click)="expandRow($event)" class="row-expand-button">
<i [ngClass]="{'fa-caret-right': !expanded, 'fa-caret-down': expanded}"
class="fa fa-lg"></i>
</td>
<td [hide]="!dataTable.indexColumnVisible" class="index-column" [textContent]="displayIndex"></td>
<td [hide]="!dataTable.selectColumnVisible" class="select-column">
Expand All @@ -23,7 +23,7 @@ export const ROW_TEMPLATE = `
<div *ngIf="column.cellTemplate" [ngTemplateOutlet]="column.cellTemplate" [ngOutletContext]="{column: column, row: _this, item: item}"></div>
</td>
</tr>
<tr *ngIf="dataTable.expandableRows" [hide]="!expanded" class="row-expansion">
<tr *ngIf="dataTable.expandableRows && expanded" class="row-expansion">
<td [attr.colspan]="dataTable.columnCount">
<div [ngTemplateOutlet]="dataTable.expandTemplate" [ngOutletContext]="{row: _this, item: item}"></div>
</td>
Expand Down
Loading