-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat: add show_legend_state #1173
base: dev
Are you sure you want to change the base?
Conversation
In the previous PR, it was advised to add state__value & state__uom classes to the render. |
totally agree, missed that myself. |
@akloeckner What is not covered (and MAY BE will be fixed in other PRs):
without keeping parts in separate elements. May be they should be placed both in
|
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.
Thanks for sorting most things out already! And sorry for re-opening some of the topics. :-)
I agree with your general assessment:
- Let's keep the UOM order for later. I also understand from your conversation that the usual classes generated a strange look. So, it is more than just adding known classes and spans and should thus be treated with more thought in another PR.
- Same for the whitespace. If the state and UOM parts become separate tags with flexible order, it will be up to the user anyways to add or remove whitespace.
I haven't actually downloaded, compiled and tested the changes yet. I'll approve the workflow run, so maybe you can check it out, @ildar170975? You'll have to wait for the code to successfully compile...
src/main.js
Outdated
let legend = this.computeName(index); | ||
const state = this.getEntityState(index); | ||
|
||
const show_legend_state = this.config.entities[index].show_legend_state ?? false; |
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.
Personally, I liked the destructuring syntax for retrieving the show_legend_state
option. This syntax also seems to be usually used in the existing codebase, whenever some property of this.config
is simply assigned to a shortcut. So, I suggest to either revert to this syntax or directly go:
if(this.config.entities[index].show_legend_state)
There is also a way to assign a default value, if the property is not set:
const { show_legend_state = false } = this.config.entities[index];
(Also, we do not support ??
in the babel
configuration yet, see the linting error.)
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've rolled back to the deconstructor + default value
let legend = this.computeName(index); | ||
const state = this.getEntityState(index); | ||
|
||
const show_legend_state = this.config.entities[index].show_legend_state ?? false; | ||
const { show_legend_state = false } = this.config.entities[index]; |
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.
We have already discussed this earlier:
the show_legend_state
is an option inside config.entities
.
What is a purpose of assigning a bool value to an OBJECT?
Why not assigning it to this.config.entities[index].show_legend_state
instead?
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.
See @akloeckner review that I have unresolved.
Personally, both are fine for me.
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, I have seen it, please @akloeckner take a look at my remark (I am not as fluent in JS).
Iterating on #1082 as I can't push into his repo