mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Add support for setting label description (#20421)
* Add support for setting label description
This commit is contained in:
parent
16de57342e
commit
fb8312110b
@ -161,12 +161,14 @@ const LABELS: LabelRegistryEntry[] = [
|
|||||||
name: "Energy",
|
name: "Energy",
|
||||||
icon: null,
|
icon: null,
|
||||||
color: "yellow",
|
color: "yellow",
|
||||||
|
description: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label_id: "entertainment",
|
label_id: "entertainment",
|
||||||
name: "Entertainment",
|
name: "Entertainment",
|
||||||
icon: "mdi:popcorn",
|
icon: "mdi:popcorn",
|
||||||
color: "blue",
|
color: "blue",
|
||||||
|
description: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -302,6 +302,7 @@ export class HaLabelPicker extends SubscribeMixin(LitElement) {
|
|||||||
name: this.hass.localize("ui.components.label-picker.no_match"),
|
name: this.hass.localize("ui.components.label-picker.no_match"),
|
||||||
icon: null,
|
icon: null,
|
||||||
color: null,
|
color: null,
|
||||||
|
description: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -315,6 +316,7 @@ export class HaLabelPicker extends SubscribeMixin(LitElement) {
|
|||||||
name: this.hass.localize("ui.components.label-picker.add_new"),
|
name: this.hass.localize("ui.components.label-picker.add_new"),
|
||||||
icon: "mdi:plus",
|
icon: "mdi:plus",
|
||||||
color: null,
|
color: null,
|
||||||
|
description: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,14 @@ export interface LabelRegistryEntry {
|
|||||||
name: string;
|
name: string;
|
||||||
icon: string | null;
|
icon: string | null;
|
||||||
color: string | null;
|
color: string | null;
|
||||||
|
description: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LabelRegistryEntryMutableParams {
|
export interface LabelRegistryEntryMutableParams {
|
||||||
name: string;
|
name: string;
|
||||||
icon?: string | null;
|
icon?: string | null;
|
||||||
color?: string | null;
|
color?: string | null;
|
||||||
|
description?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchLabelRegistry = (conn: Connection) =>
|
export const fetchLabelRegistry = (conn: Connection) =>
|
||||||
|
@ -7,6 +7,7 @@ import { createCloseHeading } from "../../../components/ha-dialog";
|
|||||||
import "../../../components/ha-formfield";
|
import "../../../components/ha-formfield";
|
||||||
import "../../../components/ha-switch";
|
import "../../../components/ha-switch";
|
||||||
import "../../../components/ha-textfield";
|
import "../../../components/ha-textfield";
|
||||||
|
import "../../../components/ha-textarea";
|
||||||
import "../../../components/ha-icon-picker";
|
import "../../../components/ha-icon-picker";
|
||||||
import "../../../components/ha-color-picker";
|
import "../../../components/ha-color-picker";
|
||||||
import { HassDialog } from "../../../dialogs/make-dialog-manager";
|
import { HassDialog } from "../../../dialogs/make-dialog-manager";
|
||||||
@ -31,6 +32,8 @@ class DialogLabelDetail
|
|||||||
|
|
||||||
@state() private _color!: string;
|
@state() private _color!: string;
|
||||||
|
|
||||||
|
@state() private _description!: string;
|
||||||
|
|
||||||
@state() private _error?: string;
|
@state() private _error?: string;
|
||||||
|
|
||||||
@state() private _params?: LabelDetailDialogParams;
|
@state() private _params?: LabelDetailDialogParams;
|
||||||
@ -44,10 +47,12 @@ class DialogLabelDetail
|
|||||||
this._name = this._params.entry.name || "";
|
this._name = this._params.entry.name || "";
|
||||||
this._icon = this._params.entry.icon || "";
|
this._icon = this._params.entry.icon || "";
|
||||||
this._color = this._params.entry.color || "";
|
this._color = this._params.entry.color || "";
|
||||||
|
this._description = this._params.entry.description || "";
|
||||||
} else {
|
} else {
|
||||||
this._name = this._params.suggestedName || "";
|
this._name = this._params.suggestedName || "";
|
||||||
this._icon = "";
|
this._icon = "";
|
||||||
this._color = "";
|
this._color = "";
|
||||||
|
this._description = "";
|
||||||
}
|
}
|
||||||
document.body.addEventListener("keydown", this._handleKeyPress);
|
document.body.addEventListener("keydown", this._handleKeyPress);
|
||||||
}
|
}
|
||||||
@ -118,6 +123,14 @@ class DialogLabelDetail
|
|||||||
"ui.panel.config.labels.detail.color"
|
"ui.panel.config.labels.detail.color"
|
||||||
)}
|
)}
|
||||||
></ha-color-picker>
|
></ha-color-picker>
|
||||||
|
<ha-textarea
|
||||||
|
.value=${this._description}
|
||||||
|
.configValue=${"description"}
|
||||||
|
@input=${this._input}
|
||||||
|
.label=${this.hass!.localize(
|
||||||
|
"ui.panel.config.labels.detail.description"
|
||||||
|
)}
|
||||||
|
></ha-textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${this._params.entry && this._params.removeEntry
|
${this._params.entry && this._params.removeEntry
|
||||||
@ -169,6 +182,7 @@ class DialogLabelDetail
|
|||||||
name: this._name.trim(),
|
name: this._name.trim(),
|
||||||
icon: this._icon.trim() || null,
|
icon: this._icon.trim() || null,
|
||||||
color: this._color.trim() || null,
|
color: this._color.trim() || null,
|
||||||
|
description: this._description.trim() || null,
|
||||||
};
|
};
|
||||||
if (this._params!.entry) {
|
if (this._params!.entry) {
|
||||||
newValue = await this._params!.updateEntry!(values);
|
newValue = await this._params!.updateEntry!(values);
|
||||||
@ -202,12 +216,14 @@ class DialogLabelDetail
|
|||||||
a {
|
a {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
ha-textarea,
|
||||||
ha-textfield,
|
ha-textfield,
|
||||||
ha-icon-picker,
|
ha-icon-picker,
|
||||||
ha-color-picker {
|
ha-color-picker {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
ha-color-picker {
|
ha-color-picker,
|
||||||
|
ha-textarea {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
@ -79,6 +79,12 @@ export class HaConfigLabels extends LitElement {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
grows: true,
|
grows: true,
|
||||||
|
template: (label) => html`
|
||||||
|
<div>${label.name}</div>
|
||||||
|
${label.description
|
||||||
|
? html`<div class="secondary">${label.description}</div>`
|
||||||
|
: nothing}
|
||||||
|
`,
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
title: "",
|
title: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user