Page MenuHomePhabricator

Suggested values: Support labels
Open, Needs TriagePublic

Description

Often, template parameters are cryptic. For this reason, it would be great if this feature could support labels. For example, the template might expect a language code like en or hi, but the template user should still see English and Hindi, otherwise the WYSIWYG experience is kinda ruined. There are many more examples, where templates use (cryptic) abbreviations for their template parameters, which are rather non-descriptive for template users (see link below).
If a known value was selected, then the label should be be displayed in the overview and in the input field, not the code.
Labels should be I18N.

If the label also contained elementary wiki syntax, a trivial wikilink could still be re-styled into a clickable link, just as the search suggestions are also clickable. Means: Could even contain some inline HTML.

Reported on

See also
https://www.mediawiki.org/wiki/Topic:Ve06hyihctm4p86n

Event Timeline

thiemowmde subscribed.

From a technical standpoint this is relatively easily to implement. We use the existing OOUI ComboBoxInputWidget. Items can have labels that are different from the submitted value. The widget even supports icons and item groups. The complex part of this task is to decide if and how exactly we want to support this. Problem is: once decided it's very hard to change the TemplateData specification.

As of now, suggested values look like this in the TemplateData JSON:

"suggestedvalues": [
    "Germany",
    "Poland"
]

This is how it might look like with labels:

"suggestedvalues": [
    {
        "data": "de",
        "label": "Germany"
    },
    {
        "data": "pl",
        "label": "Poland"
    }
]
  • The old format should still be allowed. The two can even be mixed.
  • The "data" and "label" keys follow OOUI terminology.
  • "data" must be required.
  • "data" should be a string. Numbers don't make much sense here. However, the string should be allowed to be empty.
  • While we could check for uniqueness, there is probably not much value in doing so. The harsh way TemplateData reports validation errors should only be used when the JSON is not safely usable otherwise. This is not the case here.
  • We might want to make "label" optional. It defaults to what "data" says then. Again, this follows existing OOUI specifications, specifically the behavior of TagMultiselectWidget.
  • "label" should follow the existing definition of InterfaceText.
  • The old format with an array of strings can not support InterfaceText, as this would clash with the new format.
  • Later iterations can e.g. add an "icon".