writer / writer-framework

No-code in the front, Python in the back. An open-source framework for creating data apps.
https://dev.writer.com/framework/introduction
Apache License 2.0
1.32k stars 76 forks source link

feat: capture the component that trigger an event in context #368

Closed FabienArcellier closed 6 months ago

FabienArcellier commented 7 months ago

On a click or an event, a developer can consult the identifier at the origin of the event from the context. This allows it to adapt the behavior of its event handler or to retrieve the parent to add interface components.

def increment(state, context):
    print(context['target'])
def increment(state, ui, context):
   container = ui.parent(context['target'])
    with ui.find(container):
      pass
def increment(state, ui, context):
   container = ui.parent(context['target'], level=3) # third parent
    with ui.find(container):
      pass

definition of done

ramedina86 commented 6 months ago

Really nice feature.

Only thing that I'd change is the quotes, would love to see consistency in the use of double quotes, across docs and code. In terms of code. Where are we in terms of enforcing these via linter? I believe @raaymax already set up Ruff. Is it a matter of setting it up?

FabienArcellier commented 6 months ago

I believe @raaymax already set up Ruff. Is it a matter of setting it up?

Yes, I think we have to set it up : https://docs.astral.sh/ruff/settings/#lint_flake8-quotes_inline-quotes. I have a PR to do for ruff. I will handle this config.