-
Notifications
You must be signed in to change notification settings - Fork 81
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: checkbox for inversion of visibility value #512
feat: checkbox for inversion of visibility value #512
Conversation
@input=" | ||
(ev: Event) => | ||
setVisibleValue( | ||
component.id, | ||
component.visible, | ||
(ev.target as HTMLInputElement).checked, | ||
) | ||
" |
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.
There is a shorter syntax
@input=" | |
(ev: Event) => | |
setVisibleValue( | |
component.id, | |
component.visible, | |
(ev.target as HTMLInputElement).checked, | |
) | |
" | |
@input="setVisibleValue(component.id, component.visible, $event.target.checked)" |
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.
src/writer/core_ui.py
Outdated
@@ -44,6 +44,7 @@ class Component(BaseModel): | |||
parentId: Optional[str] = None | |||
handlers: Optional[Dict[str, str]] = None | |||
visible: Optional[Union[bool, str]] = None | |||
visibleReversed: Optional[Union[bool]] = None |
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.
It's just a bool, no ?
visibleReversed: Optional[Union[bool]] = None | |
visibleReversed: Optional[bool] = None |
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.
Let's do this without modifying the root of the component.
Avoid having visible
and visibleReversed
at top level. They're closely related and should form one entity. Reversed it's also not relevant for undefined
, true
or false
.
We can do
visible: {
"reversed": true,
"expr": "active"
}
So the TS type would be something like...
boolean | { "reversed": boolean, "expr": string }
I was hesitant to make it a single entity. I gave it up. Certainly the 2 attributes live together but they do not have any particular management rule like I would therefore prefer to keep them at the same level as the other parameters of a component because they have the same level of importance. The interest in nested unnecessarily complicates the data structure. I would rather rename them:
Would that be enough? |
I'd prefer not, since Another option can be to include support for |
9a5a2d7
to
72ab762
Compare
keep the custom value when developer switch visibility. In the visibility part, I had a behavior that frustrated me a lot. When I switch the visibility to Would it be possible to treat it this way?
usage of expression evaluation only if we implement dedicated builder block everywhere. I would advocate to use the expression evaluation only if we create a dedicated builder block we would apply everywhere we manage condition as for the field |
Makes sense and this looks good, happy to move forward with it. Let's make sure to make it backwards compatible (I'm guessing should be an easy fix via {
visible: {
expression: True | False | "custom"
binding: str
reversed: bool
}
} |
""" | ||
|
||
|
||
def fix_components(components: dict) -> dict: |
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.
@ramedina86 Since the implementation of pydantic, the structure of the ui.json file has been evaluated on the backend side. I had to implement the fix processing when loading the file before it was integrated into pydantic.
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.
That's a good point...
f8363dc
to
dea3c63
Compare
Hey, what's the status of this? |
* feat: implement reverse option
* feat: implement visible entity
dea3c63
to
e9f0ecc
Compare
I think it's ready to merge |
implement #354
This PR implement the reverse option that allow a developer to reverse the visibility logic. It also implements binding persistence when the user returns to
Yes