From 396791b80518b308e45da93cbf60c9ab3858c422 Mon Sep 17 00:00:00 2001 From: Zack Barett Date: Wed, 30 Mar 2022 12:52:05 -0500 Subject: [PATCH] Fix for Mobile View of Entities Table (#12160) --- src/layouts/hass-tabs-subpage-data-table.ts | 34 +- .../config/entities/ha-config-entities.ts | 296 +++++++++--------- 2 files changed, 177 insertions(+), 153 deletions(-) diff --git a/src/layouts/hass-tabs-subpage-data-table.ts b/src/layouts/hass-tabs-subpage-data-table.ts index 1e44c0fafd..5085aba824 100644 --- a/src/layouts/hass-tabs-subpage-data-table.ts +++ b/src/layouts/hass-tabs-subpage-data-table.ts @@ -132,6 +132,12 @@ export class HaTabsSubpageDataTable extends LitElement { */ @property() public tabs!: PageNavigation[]; + /** + * Force hides the filter menu. + * @type {Boolean} + */ + @property({ type: Boolean }) public hideFilterMenu = false; + @query("ha-data-table", true) private _dataTable!: HaDataTable; public clearSelection() { @@ -195,16 +201,24 @@ export class HaTabsSubpageDataTable extends LitElement { .mainPage=${this.mainPage} .supervisor=${this.supervisor} > -
- ${this.narrow - ? html`
- ${this.numHidden || this.activeFilters - ? html`${this.numHidden || "!"}` - : ""} - -
` - : ""} -
+ ${!this.hideFilterMenu + ? html` +
+ ${this.narrow + ? html` +
+ ${this.numHidden || this.activeFilters + ? html`${this.numHidden || "!"}` + : ""} + +
+ ` + : ""} +
+ ` + : ""} ${this.narrow ? html`
diff --git a/src/panels/config/entities/ha-config-entities.ts b/src/panels/config/entities/ha-config-entities.ts index 4fe64de1a8..9cfb164d8f 100644 --- a/src/panels/config/entities/ha-config-entities.ts +++ b/src/panels/config/entities/ha-config-entities.ts @@ -29,9 +29,9 @@ import type { SelectionChangedEvent, } from "../../../components/data-table/ha-data-table"; import "../../../components/ha-button-menu"; +import "../../../components/ha-check-list-item"; import "../../../components/ha-icon-button"; import "../../../components/ha-svg-icon"; -import "../../../components/ha-check-list-item"; import { AreaRegistryEntry, subscribeAreaRegistry, @@ -507,6 +507,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { .data=${filteredEntities} .activeFilters=${activeFilters} .numHidden=${this._numHiddenEntities} + .hideFilterMenu=${this._selectedEntities.length > 0} .searchLabel=${this.hass.localize( "ui.panel.config.entities.picker.search" )} @@ -526,149 +527,155 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { .hasFab=${includeZHAFab} > ${this._selectedEntities.length - ? html`
-

- ${this.hass.localize( - "ui.panel.config.entities.picker.selected", - "number", - this._selectedEntities.length - )} -

-
- ${!this.narrow - ? html` - ${this.hass.localize( - "ui.panel.config.entities.picker.enable_selected.button" - )} - ${this.hass.localize( - "ui.panel.config.entities.picker.disable_selected.button" - )} - ${this.hass.localize( - "ui.panel.config.entities.picker.hide_selected.button" - )} - ${this.hass.localize( - "ui.panel.config.entities.picker.remove_selected.button" - )} - ` - : html` - - - ${this.hass.localize( - "ui.panel.config.entities.picker.enable_selected.button" - )} - - - - ${this.hass.localize( - "ui.panel.config.entities.picker.disable_selected.button" - )} - - - - ${this.hass.localize( - "ui.panel.config.entities.picker.hide_selected.button" - )} - - - - ${this.hass.localize( - "ui.panel.config.entities.picker.remove_selected.button" - )} - - `} + ? html` +
+

+ ${this.hass.localize( + "ui.panel.config.entities.picker.selected", + "number", + this._selectedEntities.length + )} +

+
+ ${!this.narrow + ? html` + ${this.hass.localize( + "ui.panel.config.entities.picker.enable_selected.button" + )} + ${this.hass.localize( + "ui.panel.config.entities.picker.disable_selected.button" + )} + ${this.hass.localize( + "ui.panel.config.entities.picker.hide_selected.button" + )} + ${this.hass.localize( + "ui.panel.config.entities.picker.remove_selected.button" + )} + ` + : html` + + + ${this.hass.localize( + "ui.panel.config.entities.picker.enable_selected.button" + )} + + + + ${this.hass.localize( + "ui.panel.config.entities.picker.disable_selected.button" + )} + + + + ${this.hass.localize( + "ui.panel.config.entities.picker.hide_selected.button" + )} + + + + ${this.hass.localize( + "ui.panel.config.entities.picker.remove_selected.button" + )} + + `} +
-
` - : html` - - ${this.narrow && activeFilters?.length - ? html`${this.hass.localize( - "ui.components.data-table.filtering_by" - )} - ${activeFilters.join(", ")} - Clear` - : ""} - - ${this.hass!.localize( - "ui.panel.config.entities.picker.filter.show_disabled" - )} - - - ${this.hass!.localize( - "ui.panel.config.entities.picker.filter.show_hidden" - )} - - - ${this.hass!.localize( - "ui.panel.config.entities.picker.filter.show_unavailable" - )} - - - ${this.hass!.localize( - "ui.panel.config.entities.picker.filter.show_readonly" - )} - - `} + ` + : html` + + + ${this.narrow && activeFilters?.length + ? html`${this.hass.localize( + "ui.components.data-table.filtering_by" + )} + ${activeFilters.join(", ")} + Clear` + : ""} + + ${this.hass!.localize( + "ui.panel.config.entities.picker.filter.show_disabled" + )} + + + ${this.hass!.localize( + "ui.panel.config.entities.picker.filter.show_hidden" + )} + + + ${this.hass!.localize( + "ui.panel.config.entities.picker.filter.show_unavailable" + )} + + + ${this.hass!.localize( + "ui.panel.config.entities.picker.filter.show_readonly" + )} + + + `} ${includeZHAFab ? html` mwc-button, .header-btns > ha-icon-button { margin: 8px;