From 7781401b415e60d7ddd8429aa1a06073b25af4cd Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Thu, 27 Feb 2025 17:42:43 +0100 Subject: [PATCH] Add not displayed info for feature in inline mode --- .../config-elements/hui-card-features-editor.ts | 17 ++++++++++++++++- .../config-elements/hui-tile-card-editor.ts | 4 ++++ src/translations/en.json | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/panels/lovelace/editor/config-elements/hui-card-features-editor.ts b/src/panels/lovelace/editor/config-elements/hui-card-features-editor.ts index 0a2c058ada..98062400ad 100644 --- a/src/panels/lovelace/editor/config-elements/hui-card-features-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-card-features-editor.ts @@ -203,6 +203,9 @@ export class HuiCardFeaturesEditor extends LitElement { @property({ attribute: false }) public featuresTypes?: FeatureType[]; + @property({ type: Number, attribute: "max-feature-count" }) + public maxFeaturesCount?: number; + @property() public label?: string; @@ -280,6 +283,10 @@ export class HuiCardFeaturesEditor extends LitElement { const type = featureConf.type; const supported = this._supportsFeatureType(type); const editable = this._isFeatureTypeEditable(type); + const hidden = + this.maxFeaturesCount !== undefined && + index >= this.maxFeaturesCount; + return html`
@@ -296,7 +303,15 @@ export class HuiCardFeaturesEditor extends LitElement { )} ` - : nothing} + : hidden + ? html` + + ${this.hass!.localize( + "ui.panel.lovelace.editor.features.not_displayed" + )} + + ` + : nothing}
${editable diff --git a/src/panels/lovelace/editor/config-elements/hui-tile-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-tile-card-editor.ts index a5e3c9e528..abe801d505 100644 --- a/src/panels/lovelace/editor/config-elements/hui-tile-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-tile-card-editor.ts @@ -300,6 +300,9 @@ export class HuiTileCardEditor const hasCompatibleFeatures = (stateObj && this._hasCompatibleFeatures(stateObj)) || false; + const maxFeaturesCount = + this._config.features_position === "inline" ? 1 : undefined; + return html` diff --git a/src/translations/en.json b/src/translations/en.json index 10f13797b1..5acf1b0637 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -7259,6 +7259,7 @@ "features": { "name": "Features", "not_compatible": "Not compatible", + "not_displayed": "Not displayed", "no_compatible_available": "No compatible features available for this entity", "add": "Add feature", "edit": "Edit feature",