-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Show labels in ObjectSelector overview #51840
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
base: dev
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -95,7 +95,20 @@ export class HaObjectSelector extends LitElement { | |
| .filter(Boolean) | ||
| .join(" · "); | ||
|
|
||
| const overviewLabels = this.selector.object!.overview_labels || false; | ||
|
|
||
| const labelField = | ||
| preferredLabel || Object.keys(this.selector.object!.fields!)[0]; | ||
|
|
||
| const labelHeader = overviewLabels | ||
| ? `${this._computeLabel({ | ||
| name: labelField, | ||
| selector: fields[labelField]?.selector, | ||
| })}: ` | ||
|
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. The
Member
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 was really trying to avoid another field needed to be translated and instead just have a bool saying if it should display in the overview or not. I'd think this probably looks ok even to remove |
||
| : ""; | ||
|
|
||
| let description = ""; | ||
| let descriptionHeader = ""; | ||
|
|
||
| const descriptionField = this.selector.object!.description_field; | ||
| if (descriptionField && descriptionField in fields) { | ||
|
|
@@ -108,6 +121,12 @@ export class HaObjectSelector extends LitElement { | |
| descriptionSelector | ||
| ) | ||
| : ""; | ||
| descriptionHeader = overviewLabels | ||
| ? `${this._computeLabel({ | ||
| name: descriptionField, | ||
| selector: descriptionSelector, | ||
| })}: ` | ||
| : ""; | ||
| } | ||
|
|
||
| const reorderable = this.selector.object!.multiple || false; | ||
|
|
@@ -123,10 +142,10 @@ export class HaObjectSelector extends LitElement { | |
| ></ha-svg-icon> | ||
| ` | ||
| : nothing} | ||
| <div slot="headline" class="label">${label}</div> | ||
| <div slot="headline" class="label">${labelHeader}${label}</div> | ||
| ${description | ||
| ? html`<div slot="supporting-text" class="description"> | ||
| ${description} | ||
| ${descriptionHeader}${description} | ||
| </div>` | ||
| : nothing} | ||
| <ha-icon-button | ||
|
|
||
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.
The
!here is optimistic.fieldsmay be undefined according to the type