-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow cards and tile features to provide a schema to create the editor #16142
Conversation
src/panels/lovelace/editor/config-elements/hui-generic-editor.ts
Outdated
Show resolved
Hide resolved
src/panels/lovelace/editor/config-elements/hui-generic-editor.ts
Outdated
Show resolved
Hide resolved
src/panels/lovelace/editor/config-elements/hui-generic-editor.ts
Outdated
Show resolved
Hide resolved
src/panels/lovelace/types.ts
Outdated
getStubConfig?: ( | ||
hass: HomeAssistant, | ||
stateObj?: HassEntity | ||
) => LovelaceTileFeatureConfig; | ||
getConfigElement?: () => LovelaceTileFeatureEditor; | ||
getConfigSchema?: () => HaFormSchema[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getConfigSchema?: () => HaFormSchema[]; | |
getConfigSchema?: () => {schema: HaFormSchema[], computeLabel: (schema: HaFormSchema) => string}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer automatic key generation like : card.{card_name}.editor.fields.{field_name}.name
and let custom cards inject translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would injecting translations work? The card would register a function that we call with a language param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in customCards
window object.
e1dc7af
to
e24bacb
Compare
const computeLabel = (_schema: HaFormSchema, localize: LocalizeFunc) => | ||
localize(`ui.panel.lovelace.editor.card.entity.${_schema.name}`); | ||
|
||
return { schema, assertConfig, computeLabel }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not keep everything in the editor file?
return import(
"../editor/config-elements/hui-entity-card-editor"
);
)} (${this.hass!.localize( | ||
"ui.panel.lovelace.editor.card.config.optional" | ||
)})`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
77d19c7
to
9d6f3ad
Compare
@customElement("hui-generic-editor") | ||
export class HuiGenericEditor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we name this hui-form-editor
to make it more descriptive? And match getConfigForm
better?
Co-authored-by: Bram Kragten <[email protected]>
9d6f3ad
to
9ae389b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs dev documentation and maybe even a dev blog post?
At least documentation |
Any updates on the docs? Sadly I couldn't find anything in https://developers.home-assistant.io/docs/frontend/custom-ui/custom-card/#graphical-card-configuration about getConfigSchema. |
Proposed change
Adding easier editor support for custom cards and custom tile features. It only need a form schema to generate the editor.
Benefits:
Downsides :
Example (entity card)
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: