Codereview fixes.
This commit is contained in:
@@ -1252,7 +1252,6 @@ The following will convert this entity into a submenu:
|
|||||||
[...]
|
[...]
|
||||||
elements:
|
elements:
|
||||||
- type: custom:frigate-card-menu-submenu-select
|
- type: custom:frigate-card-menu-submenu-select
|
||||||
icon: mdi:lamps
|
|
||||||
entity: input_select.kitchen_scene
|
entity: input_select.kitchen_scene
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1268,11 +1267,10 @@ elements:
|
|||||||
scene.kitchen_cooking_scene:
|
scene.kitchen_cooking_scene:
|
||||||
icon: mdi:chef-hat
|
icon: mdi:chef-hat
|
||||||
title: Cooking time!
|
title: Cooking time!
|
||||||
scene.kitchen_dining_scene:
|
scene.kitchen_tv_scene:
|
||||||
icon: mdi:television
|
icon: mdi:television
|
||||||
title: TV!
|
title: TV!
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### Overriding card behavior
|
### Overriding card behavior
|
||||||
|
|||||||
@@ -131,6 +131,11 @@ export class FrigateCardSubmenuSelect extends LitElement {
|
|||||||
|
|
||||||
protected _generatedSubmenu?: MenuSubmenu;
|
protected _generatedSubmenu?: MenuSubmenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to determine if the update should proceed.
|
||||||
|
* @param changedProps
|
||||||
|
* @returns `true` if the update should proceed, `false` otherwise.
|
||||||
|
*/
|
||||||
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||||
// No need to update the submenu unless the select entity has changed.
|
// No need to update the submenu unless the select entity has changed.
|
||||||
const oldHass = changedProps.get('hass') as HomeAssistant | undefined;
|
const oldHass = changedProps.get('hass') as HomeAssistant | undefined;
|
||||||
@@ -142,6 +147,9 @@ export class FrigateCardSubmenuSelect extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the render function will be called.
|
||||||
|
*/
|
||||||
protected willUpdate(): void {
|
protected willUpdate(): void {
|
||||||
if (!this.submenuSelect || !this.hass) {
|
if (!this.submenuSelect || !this.hass) {
|
||||||
return;
|
return;
|
||||||
@@ -167,9 +175,11 @@ export class FrigateCardSubmenuSelect extends LitElement {
|
|||||||
|
|
||||||
type: 'custom:frigate-card-menu-submenu',
|
type: 'custom:frigate-card-menu-submenu',
|
||||||
items: [],
|
items: [],
|
||||||
}
|
};
|
||||||
|
|
||||||
// Remove the options parameter which is unused/unsupported in submenu.
|
// For cleanliness remove the options parameter which is unused by the
|
||||||
|
// submenu rendering itself (above). It is only in this method to populate
|
||||||
|
// the items correctly (below).
|
||||||
delete submenu['options'];
|
delete submenu['options'];
|
||||||
|
|
||||||
for (const option of options) {
|
for (const option of options) {
|
||||||
|
|||||||
@@ -444,8 +444,6 @@ export type MenuSubmenu = z.infer<typeof menuSubmenuSchema>;
|
|||||||
|
|
||||||
const menuSubmenuSelectSchema = menuBaseSchema.merge(stateIconSchema).extend({
|
const menuSubmenuSelectSchema = menuBaseSchema.merge(stateIconSchema).extend({
|
||||||
type: z.literal('custom:frigate-card-menu-submenu-select'),
|
type: z.literal('custom:frigate-card-menu-submenu-select'),
|
||||||
// Please ensure additions to this type are filtered out appropriately in
|
|
||||||
// `submenu.ts` when this is converted to a MenuSubmenu.
|
|
||||||
options: z.record(menuSubmenuItemSchema).optional(),
|
options: z.record(menuSubmenuItemSchema).optional(),
|
||||||
});
|
});
|
||||||
export type MenuSubmenuSelect = z.infer<typeof menuSubmenuSelectSchema>;
|
export type MenuSubmenuSelect = z.infer<typeof menuSubmenuSelectSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user