Add filtering and grouping to scenes and scripts (#20203)

* Add filtering and grouping to scenes and scripts

* hide labels when there are none

* Update ha-data-table.ts
This commit is contained in:
Bram Kragten
2024-03-27 16:24:49 +01:00
committed by GitHub
parent 68935d46ce
commit e08a0c44ba
4 changed files with 654 additions and 102 deletions

View File

@@ -533,15 +533,20 @@ export class HaDataTable extends LitElement {
}, {});
const groupedItems: DataTableRowData[] = [];
Object.entries(sorted).forEach(([groupName, rows]) => {
groupedItems.push({
append: true,
content: html`<div
class="mdc-data-table__cell group-header"
role="cell"
>
${groupName === UNDEFINED_GROUP_KEY ? "" : groupName || ""}
</div>`,
});
if (
groupName !== UNDEFINED_GROUP_KEY ||
Object.keys(sorted).length > 1
) {
groupedItems.push({
append: true,
content: html`<div
class="mdc-data-table__cell group-header"
role="cell"
>
${groupName === UNDEFINED_GROUP_KEY ? "" : groupName || ""}
</div>`,
});
}
groupedItems.push(...rows);
});