Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
6105 Vizualizări

In version 10, i created Custom widget that enabled attaching an Google map to the model which had an field for latitude and another one for longitude. Widget used to be initialized like this:

<widget type="gmaps_widget"
        style="{'width': '100%','height': '300px'}"
        options="{'latitude':'address_latitude','longitude':'address_longitude'}"/>

address_latitude and address_longitude are actually names of Float fields on model.

Inside widgets init method i had following way to extract parameter passed via options attribute:

init(parent, node) {
    var options = pyeval.py_eval(node.attrs.options || '{}');
    ..... }


Since in v11 Widget is rendered from BasicRenderer which passes record as a 2nd argument to constructor instead of node, what would be the right way to obtain parameters from view? Traversing whole arch from parent widget seams too bad choice.

Documentation and comments doesn't say anything about parameters, it only shows how to add new widget to widgetRegistry.

Imagine profil
Abandonează
Cel mai bun răspuns

You are totally right. I need to fix that.  

I wanted to actually introduce the concept of AbstractViewWidget, and make AbstractField inherit from that new class.  Also, each widget in the widget registry should then be a subclass of AbstractViewWidget.  We could this way define a nice API for widgets in views.  For example, a updateState method.  I'll do that someday, but this will be in master.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
dec. 24
114
2
nov. 24
82
1
oct. 24
256
0
sept. 24
212
2
sept. 24
646