Skip to content

Commit

Permalink
feature(data-table): new data-table component (#92)
Browse files Browse the repository at this point in the history
* feature(data-table): new data-table component

* update(data-table): removed unused search pipe

* update(data-table): removed functions used in ngIfs

* chore(data-table): addressed all tslint warnings

* fix(data-table): removed search pipe imports

* update(scss): use core @angular/material theming

- and move all styles into component to reduce complexity & match code styles of material2

* update(markup): use covalent layout & match material spec

- use spec for title, search and footer pagination

* update(data-table): removed no longer used NO_PAGINATION constant

* update(data-table): removed superfluous TdDataTableContainerComponent

* fix(data-table): focus on search field wasn’t working

* update(data-table): clears search when the filter area is closed

* update(data-table): added sorting

* update(data-table): made only the internal SPAN clickable for sorting

* chore(data-table): fixed warning for empty SCSS rule

* update(data-table): attribute to set sorting order

* chore(data-table): fixed icon for sorting column indicator

* update(data-table): improved styling for sorting column indicator

* update(data-table): added formatting support and improved sorting look and feel

* usage of hostbinding instead of host to follow covalent standards

* update(data-table): made arrow up/down for sorting simpler and added animation

* depend on materialmodule instead of covalentcore

* changes string[] to string

*  meh.. returned to host since its less verbose and doesnt override classes in elements

* follow checkboxes more to spec with color and size

* usage [class.] to be more inline with covalent and cleaner html + added md-select/md-row-select

* removed space so they dont appear as file changes lol

* hide sort icons and block click event if _sorting is false

* prevented click event prop when selecting row to avoid mismatch when clicking on checkbox

* returned sorting to label and added it to sort icons + prevent selection if _rowSelection is false

* moved data-table in sidenav and overview

* added optional tooltip to headers

* show asc icon when hovering over unselected columns since `asc` is always done when first selecting it

* abstracted 'sortByColumnName' code and checked column name in 'sortBy' setter instead

* removed _sortOrderName and abstracted code into sortOrder setter

* update(data-table): condensed examples into one with multiple toggles

* feature(data-table): allow enabling/disabling pagination

* feature(data-table): added pagination switches to example

* feature(data-table): default page size to 10 rows

* feature(data-table): improved data type for sortOrder and data

* docs(data-table): added documentation

Documented all the parameters and added usage example

* chore(data-table): removed extra semi-colon

* chore(data-table): fixed all tslint errors and warnings

* chore(data-table): fixed codelyzer tslint errors

* docs(data-table): fixed README.md and small doc corrections

* chore(data-table): addressed small code review feedback

Removed md-ripple and renamed data sorting event interface

* chore(data-table): fixed README attribute descriptions

* directive fixed so class is not overrided

* chore(data-table): fixed tslint error
  • Loading branch information
fcoury authored and emoralesb05 committed Oct 14, 2016
1 parent f151d59 commit 2bc5234
Show file tree
Hide file tree
Showing 23 changed files with 1,465 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@
"@angular/core": "^2.0.0",
"@angular/forms": "^2.0.0",
"@angular/http": "^2.0.0",
"@angular/material": "2.0.0-alpha.9-3",
"@angular/platform-browser": "^2.0.0",
"@angular/platform-browser-dynamic": "^2.0.0",
"@angular/platform-server": "^2.0.0",
"@angular/router": "^3.0.0",
"@angular/material": "2.0.0-alpha.9-3",
"@types/lodash": "^4.14.36",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"highlight.js": "9.6.0",
"lodash": "^4.16.3",
"rxjs": "5.0.0-beta.12",
"showdown": "1.4.2",
"zone.js": "0.6.21"
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CovalentHttpModule } from '../platform/http';
import { CovalentMarkdownModule } from '../platform/markdown';
import { CovalentJsonFormatterModule } from '../platform/json-formatter';
import { CovalentChipsModule } from '../platform/chips';
import { CovalentDataTableModule } from '../platform/data-table';

@NgModule({
declarations: [
Expand All @@ -35,6 +36,7 @@ import { CovalentChipsModule } from '../platform/chips';
CovalentMarkdownModule.forRoot(),
CovalentJsonFormatterModule.forRoot(),
CovalentChipsModule.forRoot(),
CovalentDataTableModule.forRoot(),
appRoutes,
], // modules needed to run this module
providers: [
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/components/components.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export class ComponentsComponent {
icon: 'open_in_browser',
route: 'dialogs',
title: 'Simple Dialogs',
}, {
description: 'Data Table',
icon: 'grid_on',
route: 'data-table',
title: 'Data Table',
}, {
description: 'Highlighting your code snippets',
icon: 'code',
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/components/components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ import { ChipsDemoComponent } from './chips/chips.component';
import { DialogsDemoComponent } from './dialogs/dialogs.component';
import { DirectivesComponent } from './directives/directives.component';
import { PipesComponent } from './pipes/pipes.component';
import { DataTableDemoComponent } from './data-table/data-table.component';

import { CovalentCoreModule } from '../../../platform/core';
import { CovalentFileModule } from '../../../platform/file-upload';
import { CovalentHighlightModule } from '../../../platform/highlight';
import { CovalentMarkdownModule } from '../../../platform/markdown';
import { CovalentJsonFormatterModule } from '../../../platform/json-formatter';
import { CovalentChipsModule } from '../../../platform/chips';
import { CovalentDataTableModule } from '../../../platform/data-table';

@NgModule({
declarations: [
Expand All @@ -42,6 +44,7 @@ import { CovalentChipsModule } from '../../../platform/chips';
DialogsDemoComponent,
DirectivesComponent,
PipesComponent,
DataTableDemoComponent,
],
imports: [
CovalentCoreModule.forRoot(),
Expand All @@ -50,6 +53,7 @@ import { CovalentChipsModule } from '../../../platform/chips';
CovalentMarkdownModule.forRoot(),
CovalentJsonFormatterModule.forRoot(),
CovalentChipsModule.forRoot(),
CovalentDataTableModule.forRoot(),
componentsRoutes,
],
})
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/components/components.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ChipsDemoComponent } from './chips/chips.component';
import { DialogsDemoComponent } from './dialogs/dialogs.component';
import { DirectivesComponent } from './directives/directives.component';
import { PipesComponent } from './pipes/pipes.component';
import { DataTableDemoComponent } from './data-table/data-table.component';

const routes: Routes = [{
children: [{
Expand Down Expand Up @@ -59,6 +60,9 @@ const routes: Routes = [{
}, {
component: PipesComponent,
path: 'pipes',
}, {
component: DataTableDemoComponent,
path: 'data-table',
},
],
component: ComponentsComponent,
Expand Down
135 changes: 135 additions & 0 deletions src/app/components/components/data-table/data-table.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<md-card>
<md-card-title>Data Table</md-card-title>
<md-card-subtitle>Data driven table layout with search, sorting and pagination</md-card-subtitle>
<md-divider></md-divider>
<md-card-content>
<p>Basic Demo</p>

<td-data-table
[data]="data"
[columns]="columns"
[pagination]="pagination"
[pageSize]="pageSize"
[rowSelection]="rowSelection"
[multiple]="multiple"
[sorting]="sorting"
[sortBy]="sortBy"
[sortOrder]="sortOrder"
search="true"
title="Search and pagination enabled"
(sortChanged)="sortChanged($event)">
</td-data-table>

</md-card-content>
<md-divider></md-divider>
<md-card-actions>
<button md-button color="primary" (click)="toggleSorting()">
Toggle Sorting
({{sorting ? 'ON' : 'OFF'}})
</button>

<button md-button color="primary" (click)="toggleSortBy()" [disabled]="!sorting">
Toggle SortBy
({{sortBy}})
</button>

<button md-button color="primary" (click)="toggleSortOrder()" [disabled]="!sorting">
Toggle SortOrder
({{sortOrder}})
</button>

<button md-button color="primary" (click)="toggleRowSelection()">
Toggle RowSelection
({{rowSelection ? 'ON' : 'OFF'}})
</button>

<button md-button color="primary" (click)="toggleRowSelectionMultiple()" [disabled]="!rowSelection">
Toggle RowSelectionMultiple
({{multiple ? 'ON' : 'OFF'}})
</button>

<button md-button color="primary" (click)="toggleTooltips()">
Toggle Tooltip
({{areTooltipsOn() ? 'ON' : 'OFF'}})
</button>

<button md-button color="primary" (click)="togglePagination()">
Toggle Pagination
({{pagination ? 'ON' : 'OFF'}})
</button>

<button md-button color="primary" (click)="togglePageSize()" [disabled]="!pagination">
Change Page Size
({{pageSize}})
</button>
</md-card-actions>
</md-card>
<md-card>
<md-card-title>TdDataTableComponent</md-card-title>
<md-card-subtitle>How to use this component</md-card-subtitle>
<md-divider></md-divider>
<md-card-content>
<h2><code><![CDATA[<td-data-table>]]></code></h2>
<p>Use <code><![CDATA[<td-data-table>]]></code> element to generate a table.</p>
<p>Pass an array of javascript objects with the information to be displayed on the table to the [data] attribute.</p>
<h3>Properties:</h3>
<p>The <code><![CDATA[<td-data-table>]]></code> component has {{dataTableAttrs.length}} properties:</p>
<md-list>
<template let-attr let-last="attr" ngFor [ngForOf]="dataTableAttrs">
<a md-list-item layout-align="row">
<h3 md-line> {{attr.name}}: <span>{{attr.type}}</span></h3>
<p md-line> {{attr.description}} </p>
</a>
<md-divider *ngIf="!last"></md-divider>
</template>
</md-list>
<h3>Example:</h3>
<p>HTML:</p>
<td-highlight lang="html">
<![CDATA[
<td-data-table
[data]="data"
[columns]="columns"
sortBy="age"
sortOrder="DESC"
pagination="true"
pageSize="5"
search="true">
</td-data-table>
]]>
</td-highlight>
<p>Typescript:</p>
<td-highlight lang="typescript">
<![CDATA[
...
})
export class Demo {
private data: any[] = [
{ sku: '1452-2', item: 'Pork Chops', price: 32.11 },
{ sku: '1421-0', item: 'Prime Rib', price: 41.15 },
];
private columns: any[] = [
{ name: 'sku', label: 'SKU #', tooltip: 'Stock Keeping Unit' },
{ name: 'item', label: 'Item name' },
{ name: 'price', label 'Price (US$)', numeric: true, format: v => v.toFixed(2) },
];
}
]]>
</td-highlight>
<h3>Setup:</h3>
<p>Import the [CovalentDataTableModule] using the <code>forRoot()</code> method in your NgModule:</p>
<td-highlight lang="typescript">
<![CDATA[
import { CovalentDataTableModule } from '@covalent/data-table';
@NgModule({
imports: [
CovalentDataTableModule.forRoot(),
...
],
...
})
export class MyModule {}
]]>
</td-highlight>
</md-card-content>
</md-card>
Empty file.
Loading

0 comments on commit 2bc5234

Please sign in to comment.