Part of "front-end standardisation" Q2 priority project.
Version: unspecified
Severity: enhancement
Part of "front-end standardisation" Q2 priority project.
Version: unspecified
Severity: enhancement
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Open | None | T49145 Formally deprecate jQuery UI after we've stopped using jQuery UI in extensions and core | |||
Open | None | T100270 Replace use of jQuery UI and MW UI with OOUI across all Wikimedia-deployed extensions and core | |||
Resolved | matmarex | T74715 Convert some MW core special pages to OOUI | |||
Resolved | • TrevorParscal | T74714 Provide the OOUI PHP module inside MW core | |||
Resolved | • TrevorParscal | T74713 Get OOUI PHP to be good to go | |||
Resolved | • werdna | T76535 Decide on technology for Living Style Guide | |||
Resolved | cscott | T74716 Enhancement of OOUI PHP widgets with JS |
I don't like the word "resurrect" for this, the widgets ain't dead. Better words include "reconstitute" or "infuse" (as in, infuse with JavaScript behaviors) or maybe just "rebuild".
The big open questions:
Example to consider is a DropdownWidget (which has radically different PHP and JS implementations) inside a FieldLayout (whose constructor accepts positional parameters) inside a FieldsetLayout (whose constructor accepts OOUI objects as parameters).
My suggested answers (based on what would be helpful for https://gerrit.wikimedia.org/r/187141):
Note that I'm assuming that top-level widgets will have unique IDs assigned by the author, so that those IDs can be used in an OO.ui.infuse(...) call on the JS side. This means that most children of that widget will have a unique selector rooted at that ID (possibly using the nth-child selector). So maybe we wouldn't actually need to create many new id attributes at all. On the other hand, it's pretty trivial to generate unique IDs, and having an ID for every referenced element may be the easiest way to get started. So maybe what we really want is a nameOf(Element $elem) helper on the PHP side, which in the first implementation can add a unique ID and return it. Future work might walk the DOM a little bit and see if we can avoid creating a new uniqueID by returning a path from some named ancestor.
@cscott: That sounds pretty good. Two points though:
@Krinkle: I still need to be able to name a specific object created on the PHP side. IDs are the right thing for that.
For example, in https://gerrit.wikimedia.org/r/187141 (well, the way that patch *should* be written) I need to be able to fetch a specific ButtonGroupWidget and then add/remove new buttons from it. Other users might wish to attach event handlers to specific widgets. Just blindly infusing everything doesn't give me any way to name the specific widget which I want to get a JS object for.
I've got a rough implementation for this. I'll push it to gerrit by the end of the day.
Change 190367 had a related patch set uploaded (by Cscott):
WIP: infusion of PHP widgets with JS
Change 190368 had a related patch set uploaded (by Cscott):
Implement OO.ui.infuse to reconstitute PHP widgets in client-side JS
Tomorrow I'll try to update my patch to the Collection extension ( https://gerrit.wikimedia.org/r/187141 ) to use this, to demonstrate a practical use.
There were some comments about the 'infuse' name. I don't have any favorite paint colors here. But to make the discussion concrete, we need names for:
Suggestions for a naming scheme for these six items are welcome.
Change 190367 merged by jenkins-bot:
Serialize PHP widget state into data-ooui attribute
Change 190368 merged by jenkins-bot:
Implement OO.ui.infuse to reconstitute PHP widgets in client-side JS