Page MenuHomePhabricator

Create a Wikidata Property component for Default View
Closed, ResolvedPublic

Description

Description

Create a UI component to select, edit and view Wikidata Properties in their three valid forms:

  • literal (only view): Wikidata Property/Z6002
  • reference (view and edit): Wikidata Property Reference/Z6092
  • function call (view and edit): Fetch Wikidata Property Function Call/Z6822

The selector is needed to allow users to pick a property as input to T383631, which is under development in the current quarter. (It will also be needed for T383636, but the completion date for that isn't known yet.)

Notes:

  • four properties keys will be added soon to the definition of Z6002/Wikidata property, per T383636 and this MR.
  • At some point in future, we will complete the builtin implementation of Fetch Wikidata property, per T383636, but not necessarily in the current quarter.

Desired behavior/Acceptance criteria
  • in view mode:
    • all three forms (literal, reference and function call) are rendered using the Wikidata Property component
    • the component shows the Wikidata Property label and links to the external Wikidata reference
    • the component contains a visual aid (wikidata icon)
  • in edit mode:
    • both possible expected types (literal Wikidata Property/Z6002 or Wikidata Property Reference/Z6092) render the same selector Wikidata Property component (uses CdxLookup component)
    • sets the selector to whatever initial value it may have (if any)
    • allows searching and selecting from all available Wikidata Properties
    • on selection, produces the correct internal representation of the Wikidata Property (by creating a function call to Fetch Wikidata Property) or the Wikidata Property Reference

Internal representation

Literal Wikidata Property, is a literal object of type Z6002/Wikidata Property. It will only appear in read mode, for example, as a return value of the function call to Z6822 (not implemented yet).

{
  "Z1K1": "Z6002",
  "Z6002K1": "P31",
  "Z6002K2": ...,
  "Z6002K3": ...,
  "Z6002K4": ...,
  "Z6002K5": ...
}

Fetched Wikidata Properties are represented as a Function call to Z6822/Fetch Wikidata Property with a Z6092/Wikidata Property Reference object as an input, such as:

{
  "Z1K1": "Z7",
  "Z7K1": "Z6822",
  "Z6822K1": {
    "Z1K1": "Z6092",
    "Z6092K1": "P31"
  }
}

Referenced Wikidata Properties are represented as literal objects of type Z6092/Wikidata Property Reference object, such as:

{
  "Z1K1": "Z6092",
  "Z6092K1": "P31"
}

Content retrieval

Api for the Wikidata Property lookup:

Api for retrieving a Wikidata Property given its identifier:


Stretch Goals
  1. add matching label as supportingText in lookup results -> Amin will need to look at this since the match can be like this for example with 'instance' searchtext and how would you show that to a user:
"match": {
        "type": "alias",
        "language": "fr",
        "text": "instance dirigeante"
},
  1. add search_continue API call on scrolling to the end of the selector to load more results (pagination) ---

Completion checklist

Details

Event Timeline

gengh renamed this task from FrontEnd: Provide a selector for Wikidata properties to Create a Wikidata Property component for Default View.Jan 16 2025, 10:05 AM
gengh updated the task description. (Show Details)
gengh subscribed.

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

[mediawiki/extensions/WikiLambda@master] Add Wikidata Property components

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

DSmit-WMF changed the task status from Open to In Progress.Jan 20 2025, 2:28 PM
DSmit-WMF claimed this task.
DSmit-WMF updated the task description. (Show Details)

Change #1112749 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Add Wikidata Property components

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