Add link to the community forums to find more blueprints (#7947)

* Add link to the community forums to find more blueprints

* Apply suggestions from code review

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Bram Kragten
2020-12-12 20:38:10 +01:00
committed by GitHub
parent 5d4121a9b4
commit 8a42e65c6a
7 changed files with 81 additions and 21 deletions

View File

@@ -98,6 +98,12 @@ export class HaDataTable extends LitElement {
@property({ type: Boolean }) public hasFab = false;
/**
* Add an extra rows at the bottom of the datatabel
* @type {TemplateResult}
*/
@property({ attribute: false }) public appendRow?;
@property({ type: Boolean, attribute: "auto-height" })
public autoHeight = false;
@@ -126,6 +132,8 @@ export class HaDataTable extends LitElement {
@query("slot[name='header']") private _header!: HTMLSlotElement;
private _items: DataTableRowData[] = [];
private _checkableRowsCount?: number;
private _checkedRows: string[] = [];
@@ -318,10 +326,13 @@ export class HaDataTable extends LitElement {
@scroll=${this._saveScrollPos}
>
${scroll({
items: !this.hasFab
? this._filteredData
: [...this._filteredData, ...[{ empty: true }]],
items: this._items,
renderItem: (row: DataTableRowData, index) => {
if (row.append) {
return html`
<div class="mdc-data-table__row">${row.content}</div>
`;
}
if (row.empty) {
return html` <div class="mdc-data-table__row"></div> `;
}
@@ -447,6 +458,20 @@ export class HaDataTable extends LitElement {
if (this.curRequest !== curRequest) {
return;
}
if (this.appendRow || this.hasFab) {
this._items = [...data];
if (this.appendRow) {
this._items.push({ append: true, content: this.appendRow });
}
if (this.hasFab) {
this._items.push({ empty: true });
}
} else {
this._items = data;
}
this._filteredData = data;
}