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
propertieskeys 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:
- https://www.wikidata.org/w/api.php?action=help&modules=wbsearchentities
- type=property
- Example: https://www.wikidata.org/w/api.php?action=wbsearchentities&search=instance&language=en&type=property
Api for retrieving a Wikidata Property given its identifier:
- https://www.wikidata.org/w/api.php?action=help&modules=wbgetentities
- Example: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=P31
Stretch Goals
- 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"
},- add search_continue API call on scrolling to the end of the selector to load more results (pagination) ---
Completion checklist
- Before closing this task, review one by one the checklist available here: https://www.mediawiki.org/wiki/Abstract_Wikipedia_team/Definition_of_Done#Front-end_Task/Bug_Completion_Checklist