-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Entities Card: Entity Row Editor #7134
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
Changes from 23 commits
e3f74c0
f76efcd
35b409b
5aac38b
433e129
ed9f848
7b5fc31
e6d4274
73d72c4
ddcb737
ec7d16e
9b364a1
69c5013
6c312ea
05a5bca
355ebc0
e6c4828
cbd2e9f
868fd3d
2895491
5c3f22a
45ff398
66ba2d7
d4b7fd9
5a28dfb
e6b19ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| // Parse array of entity objects from config | ||
| import { isValidEntityId } from "../../../common/entity/valid_entity_id"; | ||
| import { EntityConfig } from "../entity-rows/types"; | ||
| import { EntityConfig, LovelaceRowConfig } from "../entity-rows/types"; | ||
|
|
||
| export const processConfigEntities = <T extends EntityConfig>( | ||
| export const processConfigEntities = <T extends LovelaceRowConfig>( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not correct? We use this function for Glance etc? that is not extending
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be both then |
||
| entities: Array<T | string> | ||
| ): T[] => { | ||
| if (!entities || !Array.isArray(entities)) { | ||
|
|
@@ -24,7 +24,7 @@ export const processConfigEntities = <T extends EntityConfig>( | |
| if (typeof entityConf === "string") { | ||
| config = { entity: entityConf } as T; | ||
| } else if (typeof entityConf === "object" && !Array.isArray(entityConf)) { | ||
| if (!entityConf.entity) { | ||
| if (!("entity" in entityConf)) { | ||
| throw new Error( | ||
| `Entity object at position ${index} is missing entity field.` | ||
| ); | ||
|
|
@@ -34,9 +34,11 @@ export const processConfigEntities = <T extends EntityConfig>( | |
| throw new Error(`Invalid entity specified at position ${index}.`); | ||
| } | ||
|
|
||
| if (!isValidEntityId(config.entity)) { | ||
| if (!isValidEntityId((config as EntityConfig).entity!)) { | ||
| throw new Error( | ||
| `Invalid entity ID at position ${index}: ${config.entity}` | ||
| `Invalid entity ID at position ${index}: ${ | ||
| (config as EntityConfig).entity | ||
| }` | ||
|
Comment on lines
+39
to
+43
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not exactly sure what the best way to do this is. With the cast, it compains that entity doesn't exist in Type T. Even if I add |
||
| ); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,42 @@ | ||
| import { mdiHelpCircle } from "@mdi/js"; | ||
| import deepFreeze from "deep-freeze"; | ||
| import { | ||
| css, | ||
| CSSResultArray, | ||
| customElement, | ||
| html, | ||
| internalProperty, | ||
| LitElement, | ||
| property, | ||
| internalProperty, | ||
| PropertyValues, | ||
| query, | ||
| TemplateResult, | ||
| PropertyValues, | ||
| } from "lit-element"; | ||
| import { mdiHelpCircle } from "@mdi/js"; | ||
|
|
||
| import type { HASSDomEvent } from "../../../../common/dom/fire_event"; | ||
| import { fireEvent } from "../../../../common/dom/fire_event"; | ||
| import { haStyleDialog } from "../../../../resources/styles"; | ||
| import { showSaveSuccessToast } from "../../../../util/toast-saved-success"; | ||
| import { addCard, replaceCard } from "../config-util"; | ||
| import { getCardDocumentationURL } from "../get-card-documentation-url"; | ||
| import { computeRTLDirection } from "../../../../common/util/compute_rtl"; | ||
| import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; | ||
|
|
||
| import type { HomeAssistant } from "../../../../types"; | ||
| import type { GUIModeChangedEvent } from "../types"; | ||
| import type { ConfigChangedEvent, HuiCardEditor } from "./hui-card-editor"; | ||
| import type { EditCardDialogParams } from "./show-edit-card-dialog"; | ||
| import type { HassDialog } from "../../../../dialogs/make-dialog-manager"; | ||
| import type { HASSDomEvent } from "../../../../common/dom/fire_event"; | ||
| import "../../../../components/ha-circular-progress"; | ||
| import "../../../../components/ha-dialog"; | ||
| import "../../../../components/ha-header-bar"; | ||
| import type { | ||
| LovelaceCardConfig, | ||
| LovelaceViewConfig, | ||
| } from "../../../../data/lovelace"; | ||
|
|
||
| import "./hui-card-editor"; | ||
| import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; | ||
| import type { HassDialog } from "../../../../dialogs/make-dialog-manager"; | ||
| import { haStyleDialog } from "../../../../resources/styles"; | ||
| import type { HomeAssistant } from "../../../../types"; | ||
| import { showSaveSuccessToast } from "../../../../util/toast-saved-success"; | ||
| import { addCard, replaceCard } from "../config-util"; | ||
| import { getCardDocumentationURL } from "../get-card-documentation-url"; | ||
| import "../hui-element-editor"; | ||
| import type { | ||
| ConfigChangedEvent, | ||
| HuiElementEditor, | ||
| } from "../hui-element-editor"; | ||
| import type { GUIModeChangedEvent } from "../types"; | ||
| import "./hui-card-preview"; | ||
| import "../../../../components/ha-dialog"; | ||
| import "../../../../components/ha-header-bar"; | ||
| import "../../../../components/ha-circular-progress"; | ||
| import type { EditCardDialogParams } from "./show-edit-card-dialog"; | ||
|
|
||
| declare global { | ||
| // for fire event | ||
|
|
@@ -65,7 +65,7 @@ export class HuiDialogEditCard extends LitElement implements HassDialog { | |
|
|
||
| @internalProperty() private _guiModeAvailable? = true; | ||
|
|
||
| @query("hui-card-editor") private _cardEditorEl?: HuiCardEditor; | ||
| @query("hui-element-editor") private _cardEditorEl?: HuiElementEditor; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have |
||
|
|
||
| @internalProperty() private _GUImode = true; | ||
|
|
||
|
|
@@ -183,14 +183,14 @@ export class HuiDialogEditCard extends LitElement implements HassDialog { | |
| </div> | ||
| <div class="content"> | ||
| <div class="element-editor"> | ||
| <hui-card-editor | ||
| <hui-element-editor | ||
| .hass=${this.hass} | ||
| .lovelace=${this._params.lovelaceConfig} | ||
| .value=${this._cardConfig} | ||
| @config-changed=${this._handleConfigChanged} | ||
| @GUImode-changed=${this._handleGUIModeChanged} | ||
| @editor-save=${this._save} | ||
| ></hui-card-editor> | ||
| ></hui-element-editor> | ||
| </div> | ||
| <div class="element-preview"> | ||
| <hui-card-preview | ||
|
|
@@ -364,6 +364,8 @@ export class HuiDialogEditCard extends LitElement implements HassDialog { | |
| @media all and (min-width: 850px) { | ||
| ha-dialog { | ||
| --mdc-dialog-min-width: 845px; | ||
| --dialog-surface-top: 40px; | ||
| --mdc-dialog-max-height: calc(100% - 72px); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -402,6 +404,9 @@ export class HuiDialogEditCard extends LitElement implements HassDialog { | |
| ha-dialog { | ||
| --mdc-dialog-max-width: calc(100% - 32px); | ||
| --mdc-dialog-min-width: 1000px; | ||
| --dialog-surface-position: fixed; | ||
| --dialog-surface-top: 40px; | ||
| --mdc-dialog-max-height: calc(100% - 72px); | ||
|
zsarnett marked this conversation as resolved.
|
||
| } | ||
|
|
||
| .content { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.