Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Module upgrade #12

Merged
merged 5 commits into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/dist
!dist/package.json
dist/*
/tmp
/node_modules
/.idea
/typings
npm-debug.log
/.vscode
/.vscode
/src/**/*.js*
/src/**/*.ngfactory.ts
**/*.ngsummary.json
/aot
11 changes: 1 addition & 10 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@

/tmp
/node_modules
/.idea
/typings
npm-debug.log
tsconfig.json
typings.json
/.vscode
/.npmignore
src
3 changes: 2 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ machine:
timezone:
America/Denver # Set the timezone
node:
version: 6.2.2
version: 6.9.4

## Customize dependencies
dependencies:
Expand All @@ -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
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.0",
"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';
42 changes: 26 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -12,31 +14,39 @@
"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",
"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 <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.3.1",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/compiler": "^2.4.0",
"@angular/compiler-cli": "^2.4.0",
"copyfiles": "^1.2.0",
"cz-conventional-changelog": "1.2.0",
"publish": "^0.6.0",
"rxjs": "^5.0.1",
"typescript": "~2.0.3",
"rimraf": "^2.6.1",
"rollup": "^0.37.0",
"typescript": "~2.0.10",
"uglify-js": "^2.7.5",
"validate-commit-msg": "2.8.2"
},
"config": {
Expand Down
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'
}
}
6 changes: 3 additions & 3 deletions src/components/column.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/row.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class DataTableRow implements OnDestroy {
return '';
}

expandRow(event) {
expandRow(event: Event) {
event.stopPropagation();
this.expanded = !this.expanded;
this.expandRowChange.emit();
Expand Down
51 changes: 24 additions & 27 deletions src/components/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -68,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;
Expand Down Expand Up @@ -140,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;
Expand All @@ -165,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);
}
}

Expand Down Expand Up @@ -209,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() {
Expand All @@ -224,7 +223,7 @@ export class DataTable implements DataTableParams, OnInit {
// Download
@Output() download = new EventEmitter();

downloadItems(){
downloadItems() {
this.download.emit(this._getRemoteParameters());
}

Expand All @@ -236,24 +235,24 @@ export class DataTable implements DataTableParams, OnInit {
@Output() cellClick = new EventEmitter();
@Output() rowExpandChange = new EventEmitter();

private rowClicked(row: DataTableRow, event) {
this.rowClick.emit({ row, event });
private rowClicked(row: DataTableRow, event: Event) {
this.rowClick.emit({row, event});
}

private rowDoubleClicked(row: DataTableRow, event) {
this.rowDoubleClick.emit({ row, event });
private rowDoubleClicked(row: DataTableRow, event: 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:
Expand Down Expand Up @@ -318,7 +317,6 @@ export class DataTable implements DataTableParams, OnInit {
}

onRowSelectChanged(row: DataTableRow) {

// maintain the selectedRow(s) view
if (this.multiSelect) {
let index = this.selectedRows.indexOf(row);
Expand All @@ -331,7 +329,7 @@ export class DataTable implements DataTableParams, OnInit {
if (row.selected) {
this.selectedRow = row;
} else if (this.selectedRow === row) {
this.selectedRow = undefined;
this.selectedRow = row;
}
}

Expand All @@ -345,14 +343,14 @@ export class DataTable implements DataTableParams, OnInit {
}
}

onRowExpandChanged(row) {
onRowExpandChanged(row: DataTableRow) {
this.rowExpandChange.emit(row);
}

// 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:
Expand All @@ -378,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 && ((<HTMLElement> columnElement.nextElementSibling).offsetWidth + dx) <= this.resizeLimit)) {
return false;
}
Expand Down
42 changes: 42 additions & 0 deletions src/data-table.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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,
DataTableRow,
DataTablePagination,
DataTableHeader,
PixelConverter,
Hide,
MinPipe
]
})
export class DataTableModule {
}
Loading