diff --git a/.gitignore b/.gitignore index 4ddac39..4e2212e 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,8 @@ ng2-table.js.map ng2-table.d.ts /logs + +factories + +/**/*.metadata.json +/**/*.ngfactory.ts diff --git a/.npmignore b/.npmignore index 79ecd36..f966810 100644 --- a/.npmignore +++ b/.npmignore @@ -22,3 +22,4 @@ webpack.config.js /components/**/*.ts !/components/**/*.d.ts +factories diff --git a/README.md b/README.md index a18b3a9..56d094d 100644 --- a/README.md +++ b/README.md @@ -47,22 +47,30 @@ Follow me [![twitter](https://img.shields.io/twitter/follow/valorkin.svg?style=s - `filtering` (`?any`) - switch on the filtering plugin - `filterString` (`string`) - the default value for filter - `columnName` (`string`) - the property name in raw data + - `className` (`string|Array`) - additional CSS classes that should be added to a - `rows` (`?Array`) - only list of the rows which should be displayed - `columns` (`?Array`) - config for columns (+ sorting settings if it's needed) - `title` (`string`) - the title of column header - `name` (`string`) - the property name in data - `sort` (`?string|boolean`) - config for columns (+ sorting settings if it's needed), sorting is switched on by default for each column + - `className` (`string|Array`) - additional CSS classes that should be added to a column header + - `filtering` (`?any`) - switch on the filtering plugin + - `filterString` (`string`) - the default value for filter + - `columnName` (`string`) - the property name in raw data ### Outputs (Events) -- `table-changed` - onclick event handler +- `tableChanged`: data change event handler +- `cellClicked`: onclick event handler ### Filter The responsibility of the filtering issue falls on user. You should choose on which columns the filter would be applied. You could add any number of different filters. Filter string - it's a string for matching values in raw data. Column name refers to the property name in raw data. The rest logic you could organize by yourself (the order of filters, data formats, etc). Even you could use filter for list of data columns. +You can also set up `filtering` param for columns, in this case filter box will appear in first row of the table. + ### Sorting Data sorting could be in 3 modes: asc, desc and without sorting data (as it comes from backend or somewhere else). If you want to switch off the sorting for some of the columns then you should set it forcibly in columns config (set property sort to false value for each column you want) diff --git a/components/table/ng-table-sorting.directive.ts b/components/table/ng-table-sorting.directive.ts index 8274a49..63d52ca 100644 --- a/components/table/ng-table-sorting.directive.ts +++ b/components/table/ng-table-sorting.directive.ts @@ -15,7 +15,7 @@ export class NgTableSortingDirective { this.ngTableSorting = value; } - @HostListener('click', ['$event', '$target']) + @HostListener('click', ['$event']) public onToggleSort(event:any):void { if (event) { event.preventDefault(); diff --git a/package.json b/package.json index d41afb4..25fe8ca 100644 --- a/package.json +++ b/package.json @@ -4,25 +4,25 @@ "description": "Simple angular2 table components with sorting, filtering...", "scripts": { "flow.compile": "npm run flow.compile:common && npm run flow.compile:system ", - "flow.compile:common": "./node_modules/.bin/tsc", - "flow.compile:system": "./.config/bundle-system.js", - "flow.copy:src": "./node_modules/.bin/cpy ng2-table.ts \"components/*.ts\" ts --parents", - "flow.clean": "./node_modules/.bin/del bundles coverage demo-build \"components/**/*.+(js|d.ts|js.map)\" dist \"ng2-table.+(js|d.ts|js.map)\"", - "flow.deploy:gh-pages": "npm run flow.build:prod && ./node_modules/.bin/gh-pages -d demo-build", - "flow.eslint": "./node_modules/.bin/eslint --ignore-path .gitignore --ext js --fix . .config", - "flow.tslint": "./node_modules/.bin/gulp lint", + "flow.compile:common": "ngc -p tsconfig.publish.json", + "flow.compile:system": "node ./.config/bundle-system.js", + "flow.copy:src": "cpy ng2-table.ts \"components/*.ts\" ts --parents", + "flow.clean": "del-cli bundles coverage demo-build \"components/**/*.+(js|d.ts|js.map|metadata.json)\" dist \"ng2-table.+(js|d.ts|js.map|metadata.json)\" factories", + "flow.deploy:gh-pages": "npm run flow.build:prod && gh-pages -d demo-build", + "flow.eslint": "eslint --ignore-path .gitignore --ext js --fix . .config", + "flow.tslint": "gulp lint", "flow.lint": "npm run flow.eslint && npm run flow.tslint", - "flow.changelog": "./node_modules/.bin/conventional-changelog -i CHANGELOG.md -s -p angular -v", - "flow.github-release": "./node_modules/.bin/conventional-github-releaser -p angular", - "flow.build:prod": "NODE_ENV=production ./node_modules/.bin/webpack --progress --color", - "flow.build:dev": "./node_modules/.bin/webpack --progress --color", - "flow.serve:dev": "./node_modules/.bin/webpack-dev-server --hot --inline --colors --display-error-details --display-cached", - "flow.serve:prod": "NODE_ENV=production ./node_modules/.bin/webpack-dev-server --hot --inline --colors --display-error-details --display-cached", + "flow.changelog": "conventional-changelog -i CHANGELOG.md -s -p angular -v", + "flow.github-release": "conventional-github-releaser -p angular", + "flow.build:prod": "NODE_ENV=production webpack --progress --color", + "flow.build:dev": "webpack --progress --color", + "flow.serve:dev": "webpack-dev-server --hot --inline --colors --display-error-details --display-cached", + "flow.serve:prod": "NODE_ENV=production webpack-dev-server --hot --inline --colors --display-error-details --display-cached", "prepublish": "npm run flow.clean && npm run flow.compile", "postpublish": "npm run flow.deploy:gh-pages", "start": "npm run flow.serve:dev", "pretest": "npm run flow.lint", - "test": "NODE_ENV=test ./node_modules/.bin/karma start", + "test": "NODE_ENV=test karma start", "preversion": "npm test", "version": "npm run flow.changelog && git add -A", "postversion": "git push origin development && git push --tags" @@ -56,10 +56,12 @@ "devDependencies": { "@angular/common": "2.0.1", "@angular/compiler": "2.0.1", + "@angular/compiler-cli": "0.6.3", "@angular/core": "2.0.1", "@angular/forms": "2.0.1", "@angular/platform-browser": "2.0.1", "@angular/platform-browser-dynamic": "2.0.1", + "@angular/platform-server": "2.0.1", "@types/jasmine": "2.2.34", "@types/node": "6.0.42", "@types/webpack": "1.12.34", @@ -80,7 +82,7 @@ "gulp-tslint": "6.1.2", "lite-server": "2.2.2", "marked": "0.3.6", - "ng2-bootstrap": "1.1.5", + "ng2-bootstrap": "1.1.8", "ng2-webpack-config": "0.0.5", "pre-commit": "1.1.3", "prismjs": "1.5.1", diff --git a/tsconfig.publish.json b/tsconfig.publish.json new file mode 100644 index 0000000..d58473a --- /dev/null +++ b/tsconfig.publish.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": false, + "noEmitHelpers": false, + "noImplicitAny": true, + "declaration": true, + "skipLibCheck": true, + "stripInternal": true, + "lib": ["dom", "es6"], + "types": [ + "jasmine", + "node", + "webpack" + ] + }, + "exclude": [ + "node_modules" + ], + "files": [ + "./demo/custom-typings.d.ts", + "./ng2-table.ts" + ], + "angularCompilerOptions": { + "genDir": "factories" + } +}