Add suggested name

This commit is contained in:
Paul Bottein 2024-03-28 13:33:18 +01:00
parent 31c6247a86
commit 960e0dd9e0
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View File

@ -34,8 +34,13 @@ class DialogCategoryDetail extends LitElement {
): Promise<void> { ): Promise<void> {
this._params = params; this._params = params;
this._error = undefined; this._error = undefined;
this._name = this._params.entry ? this._params.entry.name : ""; if (this._params.entry) {
this._icon = this._params.entry?.icon || null; this._name = this._params.entry.name || "";
this._icon = this._params.entry.icon || null;
} else {
this._name = this._params.suggestedName || "";
this._icon = null;
}
await this.updateComplete; await this.updateComplete;
} }

View File

@ -237,6 +237,7 @@ export class HaCategoryPicker extends SubscribeMixin(LitElement) {
showCategoryRegistryDetailDialog(this, { showCategoryRegistryDetailDialog(this, {
scope: this.scope!, scope: this.scope!,
suggestedName: newValue === ADD_NEW_SUGGESTION_ID ? this._suggestion : "",
createEntry: async (values) => { createEntry: async (values) => {
const category = await createCategoryRegistryEntry( const category = await createCategoryRegistryEntry(
this.hass, this.hass,