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

fix(aot): make data-table template access only public variables (closes #471) #472

Merged
merged 2 commits into from
Apr 3, 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
20 changes: 10 additions & 10 deletions src/platform/core/data-table/data-table.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="mat-table-container" title>
<table td-data-table
[class.mat-selectable]="_selectable">
<th td-data-table-column class="mat-checkbox-column" *ngIf="_selectable">
[class.mat-selectable]="isSelectable">
<th td-data-table-column class="mat-checkbox-column" *ngIf="isSelectable">
<md-checkbox
#checkBoxAll
*ngIf="_multiple"
*ngIf="isMultiple"
[disabled]="!hasData"
[checked]="areAllSelected() && hasData"
(click)="selectAll(!checkBoxAll.checked)">
Expand All @@ -14,17 +14,17 @@
*ngFor="let column of columns"
[name]="column.name"
[numeric]="column.numeric"
[active]="(column.sortable || _sortable) && column === _sortBy"
[sortable]="column.sortable || _sortable"
[sortOrder]="_sortOrder"
[active]="(column.sortable || isSortable) && column === sortByColumn"
[sortable]="column.sortable || isSortable"
[sortOrder]="sortOrderEnum"
(sortChange)="handleSort(column)">
<span [mdTooltip]="column.tooltip">{{column.label}}</span>
</th>
<tr td-data-table-row
[class.mat-selected]="_selectable && isRowSelected(row)"
*ngFor="let row of _data"
(click)="_selectable && select(row, !isRowSelected(row), $event)">
<td td-data-table-cell class="mat-checkbox-cell" *ngIf="_selectable">
[class.mat-selected]="isSelectable && isRowSelected(row)"
*ngFor="let row of data"
(click)="isSelectable && select(row, !isRowSelected(row), $event)">
<td td-data-table-cell class="mat-checkbox-cell" *ngIf="isSelectable">
<md-pseudo-checkbox
[state]="isRowSelected(row) ? 'checked' : 'unchecked'">
</md-pseudo-checkbox>
Expand Down
24 changes: 21 additions & 3 deletions src/platform/core/data-table/data-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ export class TdDataTableComponent implements ControlValueAccessor, AfterContentI
* Sets the data to be rendered as rows.
*/
@Input('data')
set data(data: Object[]) {
set data(data: any[]) {
this._data = data;
this.refresh();
}
get data(): any[] {
return this._data;
}

/**
* columns?: ITdDataTableColumn[]
Expand Down Expand Up @@ -134,8 +137,11 @@ export class TdDataTableComponent implements ControlValueAccessor, AfterContentI
* Defaults to 'false'
*/
@Input('selectable')
set selectable(_selectable: string | boolean) {
this._selectable = _selectable !== '' ? (_selectable === 'true' || _selectable === true) : true;
set selectable(selectable: string | boolean) {
this._selectable = selectable !== '' ? (selectable === 'true' || selectable === true) : true;
}
get isSelectable(): boolean {
return this._selectable;
}

/**
Expand All @@ -147,6 +153,9 @@ export class TdDataTableComponent implements ControlValueAccessor, AfterContentI
set multiple(multiple: string | boolean) {
this._multiple = multiple !== '' ? (multiple === 'true' || multiple === true) : true;
}
get isMultiple(): boolean {
return this._multiple;
}

/**
* sortable?: boolean
Expand All @@ -157,6 +166,9 @@ export class TdDataTableComponent implements ControlValueAccessor, AfterContentI
set sortable(sortable: string | boolean) {
this._sortable = sortable !== '' ? (sortable === 'true' || sortable === true) : true;
}
get isSortable(): boolean {
return this._sortable;
}

/**
* sortBy?: string
Expand All @@ -174,6 +186,9 @@ export class TdDataTableComponent implements ControlValueAccessor, AfterContentI

this._sortBy = column;
}
get sortByColumn(): ITdDataTableColumn {
return this._sortBy;
}

/**
* sortOrder?: ['ASC' | 'DESC'] or TdDataTableSortingOrder
Expand All @@ -190,6 +205,9 @@ export class TdDataTableComponent implements ControlValueAccessor, AfterContentI
this._sortOrder = sortOrder === 'ASC' ?
TdDataTableSortingOrder.Ascending : TdDataTableSortingOrder.Descending;
}
get sortOrderEnum(): TdDataTableSortingOrder {
return this._sortOrder;
}

get hasData(): boolean {
return this._data && this._data.length > 0;
Expand Down