diff --git a/src/layouts/hass-tabs-subpage-data-table.ts b/src/layouts/hass-tabs-subpage-data-table.ts index 6910af6d77..0087725ff4 100644 --- a/src/layouts/hass-tabs-subpage-data-table.ts +++ b/src/layouts/hass-tabs-subpage-data-table.ts @@ -1,4 +1,5 @@ import "@material/mwc-button/mwc-button"; +import { mdiFilterVariant } from "@mdi/js"; import "@polymer/paper-tooltip/paper-tooltip"; import { css, @@ -10,7 +11,7 @@ import { query, TemplateResult, } from "lit-element"; -import { navigate } from "../common/navigate"; +import { fireEvent } from "../common/dom/fire_event"; import { computeRTLDirection } from "../common/util/compute_rtl"; import "../components/data-table/ha-data-table"; import type { @@ -22,6 +23,14 @@ import type { HomeAssistant, Route } from "../types"; import "./hass-tabs-subpage"; import type { PageNavigation } from "./hass-tabs-subpage"; +declare global { + // for fire event + interface HASSDomEvents { + "search-changed": { value: string }; + "clear-filter": undefined; + } +} + @customElement("hass-tabs-subpage-data-table") export class HaTabsSubpageDataTable extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; @@ -64,7 +73,7 @@ export class HaTabsSubpageDataTable extends LitElement { * Add an extra row at the bottom of the data table * @type {TemplateResult} */ - @property({ attribute: false }) public appendRow?; + @property({ attribute: false }) public appendRow?: TemplateResult; /** * Field with a unique id per entry in data. @@ -78,12 +87,26 @@ export class HaTabsSubpageDataTable extends LitElement { */ @property({ type: String }) public filter = ""; + @property() public searchLabel?: string; + /** * List of strings that show what the data is currently filtered by. * @type {Array} */ @property({ type: Array }) public activeFilters?; + /** + * Text to how how many items are hidden. + * @type {String} + */ + @property() public hiddenLabel?: string; + + /** + * How many items are hidden because of active filters. + * @type {Number} + */ + @property({ type: Number }) public numHidden = 0; + /** * What path to use when the back button is pressed. * @type {String} @@ -118,6 +141,47 @@ export class HaTabsSubpageDataTable extends LitElement { } protected render(): TemplateResult { + const hiddenLabel = this.numHidden + ? this.hiddenLabel || + this.hass.localize( + "ui.components.data-table.hidden", + "number", + this.numHidden + ) || + this.numHidden + : undefined; + + const filterInfo = this.activeFilters + ? html`${this.hass.localize("ui.components.data-table.filtering_by")} + ${this.activeFilters.join(", ")} + ${hiddenLabel ? `(${hiddenLabel})` : ""}` + : hiddenLabel; + + const headerToolbar = html` + ${filterInfo + ? html`
+ ${this.narrow + ? html`
+ + + ${filterInfo} + +
` + : filterInfo} + + ${this.hass.localize("ui.components.data-table.clear")} + +
` + : ""}`; + return html`
- - ${this.activeFilters - ? html`
-
- - - ${this.hass.localize( - "ui.panel.config.filtering.filtering_by" - )} - ${this.activeFilters.join(", ")} - -
- ${this.hass.localize( - "ui.panel.config.filtering.clear" - )} -
` - : ""} + ${headerToolbar}
@@ -184,29 +221,7 @@ export class HaTabsSubpageDataTable extends LitElement {
- - - ${this.activeFilters - ? html`
- ${this.hass.localize( - "ui.panel.config.filtering.filtering_by" - )} - ${this.activeFilters.join(", ")} - ${this.hass.localize( - "ui.panel.config.filtering.clear" - )} -
` - : ""} + ${headerToolbar}
@@ -220,10 +235,11 @@ export class HaTabsSubpageDataTable extends LitElement { private _handleSearchChange(ev: CustomEvent) { this.filter = ev.detail.value; + fireEvent(this, "search-changed", { value: this.filter }); } private _clearFilter() { - navigate(this, window.location.pathname); + fireEvent(this, "clear-filter"); } static get styles(): CSSResult { @@ -247,7 +263,6 @@ export class HaTabsSubpageDataTable extends LitElement { display: flex; align-items: center; color: var(--secondary-text-color); - padding: 0 16px; } search-input { position: relative; @@ -283,10 +298,6 @@ export class HaTabsSubpageDataTable extends LitElement { left: 0; content: ""; } - .search-toolbar .active-filters { - top: -8px; - right: -16px; - } `; } } diff --git a/src/layouts/hass-tabs-subpage.ts b/src/layouts/hass-tabs-subpage.ts index 01a32b45d7..180dfe26dd 100644 --- a/src/layouts/hass-tabs-subpage.ts +++ b/src/layouts/hass-tabs-subpage.ts @@ -155,7 +155,7 @@ class HassTabsSubpage extends LitElement { > `} ${this.narrow - ? html`
` + ? html`
` : ""} ${showTabs ? html` @@ -270,9 +270,7 @@ class HassTabsSubpage extends LitElement { .main-title { flex: 1; - overflow: hidden; - text-overflow: ellipsis; - max-height: 58px; + max-height: var(--header-height); line-height: 20px; } diff --git a/src/panels/config/devices/ha-config-devices-dashboard.ts b/src/panels/config/devices/ha-config-devices-dashboard.ts index 3f4f74dfc6..8963a9d571 100644 --- a/src/panels/config/devices/ha-config-devices-dashboard.ts +++ b/src/panels/config/devices/ha-config-devices-dashboard.ts @@ -12,7 +12,6 @@ import { property, TemplateResult, } from "lit-element"; -import { classMap } from "lit-html/directives/class-map"; import memoizeOne from "memoize-one"; import { HASSDomEvent } from "../../../common/dom/fire_event"; import { computeStateDomain } from "../../../common/entity/compute_state_domain"; @@ -357,110 +356,6 @@ export class HaConfigDeviceDashboard extends LitElement { this.hass.localize ); - const headerToolbar = html` - ${activeFilters - ? html`
- ${this.narrow - ? html`
- - - ${this.hass.localize( - "ui.panel.config.filtering.filtering_by" - )} - ${activeFilters.join(", ")} - ${this._numHiddenDevices - ? "(" + - this.hass.localize( - "ui.panel.config.devices.picker.filter.hidden_devices", - "number", - this._numHiddenDevices - ) + - ")" - : ""} - -
` - : `${this.hass.localize( - "ui.panel.config.filtering.filtering_by" - )} ${activeFilters.join(", ")} - ${ - this._numHiddenDevices - ? "(" + - this.hass.localize( - "ui.panel.config.devices.picker.filter.hidden_devices", - "number", - this._numHiddenDevices - ) + - ")" - : "" - } - `} - ${this.hass.localize( - "ui.panel.config.filtering.clear" - )} -
` - : ""} - ${this._numHiddenDevices && !activeFilters - ? html`
- ${this.narrow - ? html`
- - - ${this.hass.localize( - "ui.panel.config.devices.picker.filter.hidden_devices", - "number", - this._numHiddenDevices - )} - -
` - : `${this.hass.localize( - "ui.panel.config.devices.picker.filter.hidden_devices", - "number", - this._numHiddenDevices - )}`} - ${this.hass.localize( - "ui.panel.config.devices.picker.filter.show_all" - )} -
` - : ""} - - - - - - - ${this.hass!.localize( - "ui.panel.config.devices.picker.filter.show_disabled" - )} - - - `; - return html` ` : html``} -
- ${headerToolbar} -
+ + + + + + + ${this.hass!.localize( + "ui.panel.config.devices.picker.filter.show_disabled" + )} + +
`; } @@ -540,121 +464,22 @@ export class HaConfigDeviceDashboard extends LitElement { } private _clearFilter() { - navigate(this, window.location.pathname, true); - } - - private _showAll() { + if ( + this._activeFilters(this.entries, this._searchParms, this.hass.localize) + ) { + navigate(this, window.location.pathname, true); + } this._showDisabled = true; } static get styles(): CSSResult[] { return [ - haStyle, css` - hass-loading-screen { - --app-header-background-color: var(--sidebar-background-color); - --app-header-text-color: var(--sidebar-text-color); - } - a { - color: var(--primary-color); - } - h2 { - margin-top: 0; - font-family: var(--paper-font-headline_-_font-family); - -webkit-font-smoothing: var( - --paper-font-headline_-_-webkit-font-smoothing - ); - font-size: var(--paper-font-headline_-_font-size); - font-weight: var(--paper-font-headline_-_font-weight); - letter-spacing: var(--paper-font-headline_-_letter-spacing); - line-height: var(--paper-font-headline_-_line-height); - opacity: var(--dark-primary-opacity); - } - p { - font-family: var(--paper-font-subhead_-_font-family); - -webkit-font-smoothing: var( - --paper-font-subhead_-_-webkit-font-smoothing - ); - font-weight: var(--paper-font-subhead_-_font-weight); - line-height: var(--paper-font-subhead_-_line-height); - } - ha-data-table { - width: 100%; - --data-table-border-width: 0; - } - :host(:not([narrow])) ha-data-table { - height: calc(100vh - 1px - var(--header-height)); - display: block; - } ha-button-menu { - margin-right: 8px; - } - .table-header { - display: flex; - justify-content: space-between; - align-items: center; - border-bottom: 1px solid rgba(var(--rgb-primary-text-color), 0.12); - } - search-input { - margin-left: 16px; - flex-grow: 1; - position: relative; - top: 2px; - } - .search-toolbar search-input { - margin-left: 8px; - top: 1px; - } - .search-toolbar { - display: flex; - justify-content: space-between; - align-items: center; - color: var(--secondary-text-color); - } - .search-toolbar ha-button-menu { - position: static; - } - .selected-txt { - font-weight: bold; - padding-left: 16px; - } - .table-header .selected-txt { - margin-top: 20px; - } - .search-toolbar .selected-txt { - font-size: 16px; - } - .header-btns > mwc-button, - .header-btns > ha-icon-button { - margin: 8px; - } - .active-filters { - color: var(--primary-text-color); - position: relative; - display: flex; - align-items: center; - padding: 2px 2px 2px 8px; - margin-left: 4px; - font-size: 14px; - } - .active-filters ha-icon { - color: var(--primary-color); - } - .active-filters mwc-button { - margin-left: 8px; - } - .active-filters::before { - background-color: var(--primary-color); - opacity: 0.12; - border-radius: 4px; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - content: ""; + margin: 0 -8px 0 8px; } `, + haStyle, ]; } } diff --git a/src/panels/config/entities/ha-config-entities.ts b/src/panels/config/entities/ha-config-entities.ts index 356b38e2eb..be295a57a4 100644 --- a/src/panels/config/entities/ha-config-entities.ts +++ b/src/panels/config/entities/ha-config-entities.ts @@ -1,6 +1,12 @@ import "@material/mwc-list/mwc-list-item"; import type { RequestSelectedDetail } from "@material/mwc-list/mwc-list-item"; -import { mdiFilterVariant, mdiPlus } from "@mdi/js"; +import { + mdiCancel, + mdiDelete, + mdiFilterVariant, + mdiPlus, + mdiUndo, +} from "@mdi/js"; import "@polymer/paper-checkbox/paper-checkbox"; import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; import "@polymer/paper-item/paper-icon-item"; @@ -36,7 +42,7 @@ import type { SelectionChangedEvent, } from "../../../components/data-table/ha-data-table"; import "../../../components/ha-button-menu"; -import "../../../components/ha-icon"; +import "../../../components/ha-svg-icon"; import { AreaRegistryEntry, subscribeAreaRegistry, @@ -457,200 +463,6 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { ); const includeZHAFab = filteredDomains.includes("zha"); - const headerToolbar = 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.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.remove_selected.button" - )} - - `} -
- ` - : html` - ${activeFilters - ? html`
- ${this.narrow - ? html`
- - - ${this.hass.localize( - "ui.panel.config.filtering.filtering_by" - )} - ${activeFilters.join(", ")} - ${this._numHiddenEntities - ? "(" + - this.hass.localize( - "ui.panel.config.entities.picker.filter.hidden_entities", - "number", - this._numHiddenEntities - ) + - ")" - : ""} - -
` - : `${this.hass.localize( - "ui.panel.config.filtering.filtering_by" - )} ${activeFilters.join(", ")} - ${ - this._numHiddenEntities - ? "(" + - this.hass.localize( - "ui.panel.config.entities.picker.filter.hidden_entities", - "number", - this._numHiddenEntities - ) + - ")" - : "" - } - `} - ${this.hass.localize( - "ui.panel.config.filtering.clear" - )} -
` - : ""} - ${this._numHiddenEntities && !activeFilters - ? html`
- ${this.narrow - ? html`
- - - ${this.hass.localize( - "ui.panel.config.entities.picker.filter.hidden_entities", - "number", - this._numHiddenEntities - )} - -
` - : `${this.hass.localize( - "ui.panel.config.entities.picker.filter.hidden_entities", - "number", - this._numHiddenEntities - )}`} - ${this.hass.localize( - "ui.panel.config.entities.picker.filter.show_all" - )} -
` - : ""} - - - - - - - ${this.hass!.localize( - "ui.panel.config.entities.picker.filter.show_disabled" - )} - - - - ${this.hass!.localize( - "ui.panel.config.entities.picker.filter.show_unavailable" - )} - - - - ${this.hass!.localize( - "ui.panel.config.entities.picker.filter.show_readonly" - )} - - - `; return html` -
- ${headerToolbar} -
+ ${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.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.remove_selected.button" + )} + + `} +
+
` + : html` + + + + + + ${this.hass!.localize( + "ui.panel.config.entities.picker.filter.show_disabled" + )} + + + + ${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 { + .header-btns > mwc-icon-button { margin: 8px; } - .active-filters { - color: var(--primary-text-color); - position: relative; - display: flex; - align-items: center; - padding: 2px 2px 2px 8px; - margin-left: 4px; - font-size: 14px; - } - .active-filters ha-icon { - color: var(--primary-color); - } - .active-filters mwc-button { - margin-left: 8px; - } - .active-filters::before { - background-color: var(--primary-color); - opacity: 0.12; - border-radius: 4px; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - content: ""; + ha-button-menu { + margin: 0 -8px 0 8px; } `, ]; diff --git a/src/panels/config/integrations/ha-config-integrations.ts b/src/panels/config/integrations/ha-config-integrations.ts index 3f80df582e..fa3f301a00 100644 --- a/src/panels/config/integrations/ha-config-integrations.ts +++ b/src/panels/config/integrations/ha-config-integrations.ts @@ -348,11 +348,11 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) { "number", disabledConfigEntries.size )} - ${this.hass.localize( - "ui.panel.config.filtering.show" - )} + + ${this.hass.localize( + "ui.panel.config.integrations.disable.show" + )} + ` : ""} diff --git a/src/translations/en.json b/src/translations/en.json index 92651cccf7..8433cebfbf 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -459,7 +459,10 @@ }, "data-table": { "search": "Search", - "no-data": "No data" + "no-data": "No data", + "filtering_by": "Filtering by", + "hidden": "{number} hidden", + "clear": "Clear" }, "media-browser": { "pick": "Pick", @@ -848,11 +851,6 @@ "config": { "header": "Configure Home Assistant", "introduction": "In this view it is possible to configure your components and Home Assistant. Not everything is possible to configure from the UI yet, but we're working on it.", - "filtering": { - "filtering_by": "Filtering by", - "clear": "Clear", - "show": "Show" - }, "advanced_mode": { "hint_enable": "Missing config options? Enable advanced mode on", "link_profile_page": "your profile page" @@ -2071,7 +2069,8 @@ "disable": { "show_disabled": "Show disabled integrations", "hide_disabled": "Hide disabled integrations", - "disabled_integrations": "{number} disabled" + "disabled_integrations": "{number} disabled", + "show": "Show" }, "ignore": { "ignore": "Ignore", @@ -3852,4 +3851,4 @@ } } } -} \ No newline at end of file +}