Page MenuHomePhabricator

TemplateData: Add parameter type for selecting one of predefined values (like "<select>" or ENUM)
Open, HighPublic1 Story Points

Tokens
"Like" token, awarded by Liuxinyu970226."Burninate" token, awarded by czar."Barnstar" token, awarded by Psychoslave."Orange Medal" token, awarded by Krinkle."Like" token, awarded by FoXFTW."Like" token, awarded by eranroz."Like" token, awarded by Amire80."Like" token, awarded by fbstj."Mountain of Wealth" token, awarded by Ricordisamoa.
Assigned To
None
Authored By
AzaToth, Jul 15 2013

Description

Sometimes for templates, you have a pre-defined set of values to use for a parameter. Perhaps it could be a nice thing to expose valid values to the user in a drop down or something.


Version: unspecified
Severity: enhancement

Details

Reference
bz51375

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:58 AM
bzimport added a project: TemplateData.
bzimport set Reference to bz51375.
AzaToth created this task.Jul 15 2013, 5:41 PM
NicoV added a comment.Jul 16 2013, 9:53 AM

See "bug 50760 - Support suggested values" which is quite similar.

https://bugzilla.wikimedia.org/show_bug.cgi?id=50760

Ping @TrevorParscal.

Since wikitext template editing will always be possible, we can't (yet?) enforce values in VisualEditor. We can only suggest.

E.g. if a template parameter "foo" is specified as values: ['a', 'b']. and wikitext has {{echo|foo=x}}, we need to provide a way to edit that, while still being able to set it to a or b.

  • Bug 50760 has been marked as a duplicate of this bug. ***

(In reply to comment #2)

Ping @TrevorParscal.
Since wikitext template editing will always be possible, we can't (yet?)
enforce values in VisualEditor. We can only suggest.
E.g. if a template parameter "foo" is specified as values: ['a', 'b']. and
wikitext has {{echo|foo=x}}, we need to provide a way to edit that, while
still
being able to set it to a or b.

The "normal" way is a drop-down with the target of the drop-down being a free-entry text field that suggests entries (but does not block other entries).

  • Bug 52754 has been marked as a duplicate of this bug. ***
Krinkle added a comment.EditedMay 20 2014, 8:01 PM

Yeah, we should add this. Though it doesn't have to be as a parameter type. I imagine we could also do it more generically.

params: {

"key": {
  "type": ...
  "values": [ .. ]

The upside is that this is easier to specify and validate.

An nice bonus is that it would allow one to preserve types regardless of whether the possible values are finite or not (e.g. freeform strings, numbers, dates, page names).

Down side is that it's tricky for consumers like VisualEditor to have a dropdown menu for values that aren't simple strings.

But I think that's fine. Those consumers can choose to support it however they like. E.g. they could support "values" only for string values.

As a nice bonus this would allow VisualEditor to make dedicated select interfaces much better. E.g. a colour picker with limited values could be a row with squares and you visually pick one of those colours (like radio buttons). And a parameter that takes file names (e.g. for icons), could have live previews for the 10 different icons it supports.

The type-restricted implementation would look something like this:

params: {

"key": {
  "type": "options"
  "values": [ .. ]

And would treat them as type: 'string' with no further type association.

It also has the downside of having a "param" property (values) that only makes sense in combination with another. Making it slightly less intuitive.

fbstj added a subscriber: fbstj.Dec 16 2014, 3:30 PM
Jdforrester-WMF moved this task from Backlog to Next-up on the TemplateData board.Jan 12 2015, 9:19 PM
Ricordisamoa added a subscriber: Ricordisamoa.

params: {

"key": {
  "type": ...
  "values": [ .. ]

Seems a good way of specifying it, +1

fbstj awarded a token.Apr 16 2015, 1:03 PM
fbstj removed a subscriber: fbstj.
MSGJ added a subscriber: MSGJ.May 19 2015, 8:51 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 9 2015, 8:20 PM

Change 263655 had a related patch set uploaded (by Alex Monk):
[WIP] Add a parameter key to limit possible valid values to a given set

https://gerrit.wikimedia.org/r/263655

Krenair claimed this task.Jan 12 2016, 8:16 PM
Krenair moved this task from Next-up to Doing on the TemplateData board.
Jdforrester-WMF edited a custom field.
AlexMonk-WMF added a subscriber: Krenair.
eranroz added a subscriber: eranroz.
FoXFTW added a subscriber: FoXFTW.

Change 263655 abandoned by Alex Monk:
[WIP] Add a parameter key to limit possible valid values to a given set

https://gerrit.wikimedia.org/r/263655

Krenair removed AlexMonk-WMF as the assignee of this task.Jan 5 2017, 10:22 PM
Krenair added a subscriber: Krenair.
Tgr added a subscriber: Tgr.May 12 2017, 12:56 PM
Krinkle removed a subscriber: Krinkle.

That's something which would be extremely useful.

I'm currently working on a proposal for ease Wikitionary contribution through templatedata. Such a feature would for example allow to select word category (verb, adjective…).

It would also be useful to be able to use a set of possible values provided by some template/module.

czar awarded a token.Nov 10 2017, 2:46 AM
czar added a subscriber: czar.
czar added a comment.Nov 10 2017, 2:54 AM

Is this still on the docket? It's vital. Is there some other way of specifying valid string values in TemplateData (TD)? If not, that would appear to be a large oversight if TD is supposed to help users easily interact with template params

Elitre added a subscriber: Deskana.Nov 10 2017, 4:48 PM
Evad37 added a subscriber: Evad37.Nov 20 2017, 10:48 PM

Change 263655 restored by Krinkle:
[WIP] Add a parameter key to limit possible valid values to a given set

https://gerrit.wikimedia.org/r/263655