Separate row entity elements for Lovelace#1461
Conversation
| import fireEvent from '../../../common/dom/fire_event.js'; | ||
|
|
||
| import stateCardType from '../../../common/entity/state_card_type.js'; | ||
| import '../entity-row-elements/hui-generic-entity-row-element.js'; |
There was a problem hiding this comment.
I think that the folder name can just be entity-row.
|
I think this is great. Our current entity rows are too coupled between display on left side and controls on right side. We should be able to extract all the controls on the right side and make the left configurable. It's just things like input_select that might need an override. Which is fine. |
|
It's also great as it allows to maybe just override the controls instead of the full entity row with a custom web component. |
|
Since you're making a generic row, consider use slot to fill in control |
| const element = createEntityRowElement(entity, this.hass); | ||
| if (entityId && !DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityId))) { | ||
| element.classList.add('state-card-dialog'); | ||
| element.addEventListener('click', () => this.fire('hass-more-info', { entityId })); |
There was a problem hiding this comment.
We should keep this here. We don't know where EntityRow will be used.
There was a problem hiding this comment.
Although, I do really like if we only attach click listener to the left part of the generic row. Interacting with controls should never open more info.
| } | ||
|
|
||
| element.stateObj = stateObj; | ||
| element.hass = hass; |
There was a problem hiding this comment.
Do we still need this or can we start removing hass from this file ? (as it should be)
| color: var(--secondary-text-color); | ||
| } | ||
| </style> | ||
| <template is="dom-if" if="[[_stateObj]]"> |
There was a problem hiding this comment.
If we hide everything when there is no stateObj, can we instead show a light yellow div saying "State X not found"?
| } | ||
|
|
||
| _computeStateObj(states, entityId) { | ||
| return states && entityId && entityId in states ? states[entityId] : null; |
There was a problem hiding this comment.
No need to check entityId, config is invalid and this component should not be instantiated with it?
| static get template() { | ||
| return html` | ||
| <style> | ||
| paper-button { |
There was a problem hiding this comment.
I don't see paper-button in this component
| hass="[[hass]]" | ||
| config="[[_config]]" | ||
| > | ||
| <paper-input no-label-float= |
| class HuiInputTextEntityRow extends PolymerElement { | ||
| static get template() { | ||
| return html` | ||
| <template is="dom-if" if="[[_stateObj]]"> |
There was a problem hiding this comment.
Really not a fan of these guards for stateObj :(
| margin: 0; | ||
| } | ||
| </style> | ||
| <template is="dom-if" if="[[_stateObj]]"> |
There was a problem hiding this comment.
Not needed, already is in hui-generic-entity-row.
| margin: 0; | ||
| } | ||
| </style> | ||
| <template is="dom-if" if="[[_stateObj]]"> |
There was a problem hiding this comment.
Already in hui-generic-entity-row
| hass="[[hass]]" | ||
| config="[[_config]]" | ||
| > | ||
| <div> |
There was a problem hiding this comment.
I need an element for my flexbox
| class HuiTextEntityRow extends PolymerElement { | ||
| static get template() { | ||
| return html` | ||
| <template is="dom-if" if="[[_stateObj]]"> |
There was a problem hiding this comment.
Done inside hui-generic-entity-row
| this._config = config; | ||
| } | ||
|
|
||
| getCardSize() { |
There was a problem hiding this comment.
are we trying to keep the same API between cards and entity rows?
There was a problem hiding this comment.
hups I thought we use it also here, removed it
| class HuiToggleEntityRow extends PolymerElement { | ||
| static get template() { | ||
| return html` | ||
| <template is="dom-if" if="[[_stateObj]]"> |
There was a problem hiding this comment.
Done inside hui-generic-entity-row
| <state-info | ||
| hass="[[hass]]" | ||
| state-obj="[[stateObj]]" | ||
| in-dialog="[[inDialog]]" |
There was a problem hiding this comment.
In retrospect, in-dialog is such a misnomer as attribute for state-info. It defines context instead of behavior (show-last-changed) while state info should not know anything about dialogs. Oh well, so we learn
|
This is already looking very good ! |
|
This merge removed the overrideName changes that was added on July 1. Was that on purpose, or an oversight? I'm attempting to create a state card in lovelace and want to pass along the name from the entity card configuration but I have no way to pass it into state-info since this property has been removed. See the bottom of the diff: |
|
No discussion in merged PRs. |
fix: home-assistant/ui-schema#97
fix: home-assistant/ui-schema#69