Page MenuHomePhabricator

[Front-end/Default view]: Adapt enum selector to also accommodate lightweight enum types
Closed, ResolvedPublic

Description

Description

Goals
  • Users should be able to use persisted enum types in their usual workflows:
    • When trying a function that has a lightweight enum type as one of their input types, a user should be able to select a value from the enum list
    • When selecting a type in Default View, users should be able to select any of the persisted enum types
Technical details

Or add a different component, if needed.

Example User Flow

Flow 1: Use enum types in the Function Evaluator widget

Prerequisite:

  • Create an enum type (e.g. "Enummeration of grammatical geners")
  • Create a function that uses that enum type as an input (e.g. "Add article to lexeme")
  • The function must have connected implementations

Step 1: Go to Function page

  1. Go to the view page for the "Add article to lexeme" function
  2. Explore the "Try this function" widget

Expected outcome:

  • The field for "Enumeration of grammatical gender" should be identical to any other Enum (e.g. Month, boolean)
    • Should render a codex selector component
    • On click, should display the available options in the enum list
    • The experience should be identical than with other enum types (e.g. "input month" field in "Get day of week from date" function: https://www.wikifunctions.org/wiki/Z13163 )
Enum type selectorEnum type click on selector
Screenshot from 2025-04-24 11-27-22.png (843×1 px, 90 KB)
Screenshot from 2025-04-24 11-28-49.png (850×1 px, 93 KB)

Step 2: Select input and try the Function

  1. Select "feminine" in the "grammatical gender" selector
  2. Click "Run function"

Expected outcome:

  • On "network" exploration, the function call should have a valid shape with correct enum value selection:
{
    "Z1K1": "Z7",
    "Z7K1": "Z23773",
    "Z23773K1": {
        "Z1K1": "Z6095",
        "Z6095K1": "L31222"
    },
    "Z23773K2": {
        "Z1K1": "Z23772",
        "Z23772K1": {
            "Z1K1": "Z6091",
            "Z6091K1": "Q1775415"
        }
    }
}

Flow 2: Use enum types in Default View type selection

Case 1: Create a type with a key of type "Enumeration of grammatical genders"

  • Go to Special:CreateObject
  • Select Type
  • Add a key, for 'value type' fill in 'Enumeration of grammatical genders' -> currently not working because of wikilambdasearch_type =Z4 does not yet return the wikidata enums. (no return type) @gengh will think about this
  • Add a list item and this should show the selectbox with the enums (masculine, feminine, neuter)

Question: what should happen here. Its only searching for actual types so type=Z4, so it wont return the 'enumeration for gram gender'.
We can select function call and then it will show up. What should happen?

Expected outcome:

  • 'Enumeration of grammatical genders' should appear in the list for 'value type'
Read modeEdit mode
Screenshot from 2025-06-17 08-21-32.png (296×472 px, 12 KB)
Screenshot from 2025-06-17 08-21-49.png (306×748 px, 15 KB)
Screenshot from 2025-06-17 08-21-18.png (467×487 px, 25 KB)
Screenshot from 2025-06-17 08-22-02.png (423×758 px, 20 KB)

Case 2: Select instances in a typed list

  • Go to Special:CreateObject
  • Select 'function call' from the ModeSelector
  • For 'function' fill in 'Typed List'
  • For 'List item type' fill in 'Enumeration of grammatical genders' -> currently not working because of wikilambdasearch_type =Z4 does not yet return the wikidata enums. (no return type) @gengh will think about this
  • Add a list item and this should show the selectbox with the enums (masculine, feminine, neuter)
  • select on of them and publish

Expected outcome:

  • 'Enumeration of grammatical genders' should appear in the list for 'list item type'
  • Read only mode shows the wikidata enum name + link with the wikidata logo in front
  • Edit mode shows a selectbox with the enums from the 'Enumeration of grammatical genders' list
  • Publishes successfully with data structure: TBD
Read modeEdit mode
Screenshot 2025-05-19 at 15.17.34.png (364×962 px, 16 KB)
Screenshot 2025-05-19 at 15.17.51.png (552×998 px, 30 KB)

Completion checklist

Event Timeline

DSmit-WMF changed the task status from Open to In Progress.May 12 2025, 1:01 PM
DSmit-WMF claimed this task.

Change #1148298 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] Create an Wikidata enum selector to also accommodate lightweight enum types

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

Change #1151722 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] [DNM] Wikidata enum single component

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

Works great:

  • on edit, a value of wikidata enum type shows a selector with all available objects
  • on view, shows the selected item; falls back to wikidata ad-hoc component; can be expanded to see details

enum-selector.gif (593×932 px, 767 KB)

Change #1151722 abandoned by Genoveva Galarza:

[mediawiki/extensions/WikiLambda@master] [DNM] Wikidata enum single component

Reason:

These changes were integrated into the parent patch

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

Change #1148298 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Create an Wikidata enum selector to also accommodate lightweight enum types

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

DMartin-WMF updated the task description. (Show Details)