From bf8cd7392ac74475decd7fb97ffcfc465f0b2c90 Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Wed, 23 Aug 2017 10:35:52 -0700 Subject: [PATCH 1/3] compat(sort): add mat compatible sort event --- src/demo-app/table/person-data-source.ts | 2 +- src/lib/sort/sort-header.ts | 2 +- src/lib/sort/sort.spec.ts | 10 +++++----- src/lib/sort/sort.ts | 7 +++++-- src/material-examples/table-http/table-http-example.ts | 4 ++-- .../table-overview/table-overview-example.ts | 2 +- .../table-sorting/table-sorting-example.ts | 2 +- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/demo-app/table/person-data-source.ts b/src/demo-app/table/person-data-source.ts index 9837486dcdae..6bf96511be1d 100644 --- a/src/demo-app/table/person-data-source.ts +++ b/src/demo-app/table/person-data-source.ts @@ -15,7 +15,7 @@ export class PersonDataSource extends DataSource { connect(): Observable { const displayDataChanges = [ this._paginator.page, - this._sort.mdSortChange, + this._sort.sortChange, this._peopleDatabase.dataChange ]; return Observable.merge(...displayDataChanges).map(() => { diff --git a/src/lib/sort/sort-header.ts b/src/lib/sort/sort-header.ts index 8daa517e51e2..260306efdb26 100644 --- a/src/lib/sort/sort-header.ts +++ b/src/lib/sort/sort-header.ts @@ -76,7 +76,7 @@ export class MdSortHeader implements MdSortable { throw getMdSortHeaderNotContainedWithinMdSortError(); } - this._rerenderSubscription = merge(_sort.mdSortChange, _intl.changes).subscribe(() => { + this._rerenderSubscription = merge(_sort.sortChange, _intl.changes).subscribe(() => { changeDetectorRef.markForCheck(); }); } diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index de24529d3b3f..f801997e58e0 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -14,7 +14,7 @@ import {wrappedErrorMessage, dispatchMouseEvent} from '@angular/cdk/testing'; import {map} from '../core/rxjs/index'; import {MdTableModule} from '../table/index'; -describe('MdSort', () => { +fdescribe('MdSort', () => { let fixture: ComponentFixture; let component: SimpleMdSortApp; @@ -199,10 +199,10 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture -
A
-
B
-
D
-
E
+
A
+
B
+
D
+
E
` }) diff --git a/src/lib/sort/sort.ts b/src/lib/sort/sort.ts index ec30d607b24e..218b77dc921e 100644 --- a/src/lib/sort/sort.ts +++ b/src/lib/sort/sort.ts @@ -72,7 +72,10 @@ export class MdSort { set _matSortDisableClear(v) { this.disableClear = v; } /** Event emitted when the user changes either the active sort or sort direction. */ - @Output() mdSortChange = new EventEmitter(); + @Output('mdSortChange') sortChange = new EventEmitter(); + + @Output('matSortChange') + get _matSortChange(): EventEmitter { return this.sortChange; } /** * Register function to be used by the contained MdSortables. Adds the MdSortable to the @@ -106,7 +109,7 @@ export class MdSort { this.direction = this.getNextSortDirection(sortable); } - this.mdSortChange.next({active: this.active, direction: this.direction}); + this.sortChange.next({active: this.active, direction: this.direction}); } /** Returns the next sort direction of the active sortable, checking for potential overrides. */ diff --git a/src/material-examples/table-http/table-http-example.ts b/src/material-examples/table-http/table-http-example.ts index 34389b71561e..2e5d95cb155a 100644 --- a/src/material-examples/table-http/table-http-example.ts +++ b/src/material-examples/table-http/table-http-example.ts @@ -83,12 +83,12 @@ export class ExampleDataSource extends DataSource { /** Connect function called by the table to retrieve one stream containing the data to render. */ connect(): Observable { const displayDataChanges = [ - this.sort.mdSortChange, + this.sort.sortChange, this.paginator.page ]; // If the user changes the sort order, reset back to the first page. - this.sort.mdSortChange.subscribe(() => this.paginator.pageIndex = 0); + this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0); return Observable.merge(...displayDataChanges) .startWith(null) diff --git a/src/material-examples/table-overview/table-overview-example.ts b/src/material-examples/table-overview/table-overview-example.ts index b564dd30488d..2fd7d0883e47 100644 --- a/src/material-examples/table-overview/table-overview-example.ts +++ b/src/material-examples/table-overview/table-overview-example.ts @@ -140,7 +140,7 @@ export class ExampleDataSource extends DataSource { // Listen for any changes in the base data, sorting, filtering, or pagination const displayDataChanges = [ this._exampleDatabase.dataChange, - this._sort.mdSortChange, + this._sort.sortChange, this._filterChange, this._paginator.page, ]; diff --git a/src/material-examples/table-sorting/table-sorting-example.ts b/src/material-examples/table-sorting/table-sorting-example.ts index 1cbcc4c6f683..36df176410c0 100644 --- a/src/material-examples/table-sorting/table-sorting-example.ts +++ b/src/material-examples/table-sorting/table-sorting-example.ts @@ -90,7 +90,7 @@ export class ExampleDataSource extends DataSource { connect(): Observable { const displayDataChanges = [ this._exampleDatabase.dataChange, - this._sort.mdSortChange, + this._sort.sortChange, ]; return Observable.merge(...displayDataChanges).map(() => { From de5490ed95296823285ac258532bc8e307452158 Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Wed, 23 Aug 2017 10:39:12 -0700 Subject: [PATCH 2/3] remove fdescribe --- src/lib/sort/sort.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index f801997e58e0..28993e163e25 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -14,7 +14,7 @@ import {wrappedErrorMessage, dispatchMouseEvent} from '@angular/cdk/testing'; import {map} from '../core/rxjs/index'; import {MdTableModule} from '../table/index'; -fdescribe('MdSort', () => { +describe('MdSort', () => { let fixture: ComponentFixture; let component: SimpleMdSortApp; From 7de9b31c412e8ef0aad9a87ddfad90699c44370b Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Wed, 23 Aug 2017 11:38:24 -0700 Subject: [PATCH 3/3] make readonly --- src/lib/sort/sort.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/sort/sort.ts b/src/lib/sort/sort.ts index 218b77dc921e..c0151361bfe3 100644 --- a/src/lib/sort/sort.ts +++ b/src/lib/sort/sort.ts @@ -72,7 +72,7 @@ export class MdSort { set _matSortDisableClear(v) { this.disableClear = v; } /** Event emitted when the user changes either the active sort or sort direction. */ - @Output('mdSortChange') sortChange = new EventEmitter(); + @Output('mdSortChange') readonly sortChange = new EventEmitter(); @Output('matSortChange') get _matSortChange(): EventEmitter { return this.sortChange; }