Add not displayed info for feature in inline mode

This commit is contained in:
Paul Bottein 2025-02-27 17:42:43 +01:00
parent 3a1d371b0b
commit 7781401b41
No known key found for this signature in database
3 changed files with 21 additions and 1 deletions

View File

@ -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`
<div class="feature">
<div class="handle">
@ -296,7 +303,15 @@ export class HuiCardFeaturesEditor extends LitElement {
)}
</span>
`
: nothing}
: hidden
? html`
<span class="secondary">
${this.hass!.localize(
"ui.panel.lovelace.editor.features.not_displayed"
)}
</span>
`
: nothing}
</div>
</div>
${editable

View File

@ -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`
<ha-form
.hass=${this.hass}
@ -334,6 +337,7 @@ export class HuiTileCardEditor
.hass=${this.hass}
.stateObj=${stateObj}
.features=${this._config!.features ?? []}
.maxFeaturesCount=${maxFeaturesCount}
@features-changed=${this._featuresChanged}
@edit-detail-element=${this._editDetailElement}
></hui-card-features-editor>

View File

@ -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",