Page MenuHomePhabricator

Auto-suggest widget that returns properties limited to 1 or more data types
Closed, ResolvedPublic

Description

We need an auto-suggest widget where the choices offered will be properties limited to a particular data type - e.g. properties beginning with 'ca' with data type “item” (excluding properties with data type “quantity”, “geo coordinate”, etc)

Why do we need it?

  • We're planning to support adding arbitrary statements to files on commons - a user can choose an arbitrary property, and give it a value. In order to be able to deliver incrementally we need to implement this one data type at a time (initially we'll only be supporting properties with data type wikibase-entity), so we need to be able to limit the properties that a user can choose to a particular data type

How are we going to build it?
2 possible approaches:

  • modify wbsearchentities so that it accepts data-type as a param, and filters on the server side
  • filter out data types we don't want from wbsearchentities responses on the client side, and make additional requests if we don't have enough data (using the continue param)

Acceptance Criteria:

  • I can use wbsearchentities from a js autosuggest to display to the user matching wikidata properties limited to 1 or more data types

Event Timeline

Cparle created this task.Mar 27 2019, 12:50 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 27 2019, 12:50 PM

I believe wbsearchentities does return the datatype for type=property, but I don't think it is possible to filter the resultset on specific datatypes yet (except on the client, though that could mean flooding the server with requests...)

Aha, so it does. Edited ticket description

Cparle renamed this task from Add data type to wbsearchentities to Auto-suggest widget that returns P-items limited to 1 or more data types.Mar 27 2019, 3:26 PM
Cparle updated the task description. (Show Details)
Ramsey-WMF triaged this task as High priority.Mar 28 2019, 3:06 PM
Ramsey-WMF moved this task from Untriaged to Triaged on the Multimedia board.
Cparle renamed this task from Auto-suggest widget that returns P-items limited to 1 or more data types to [DO THIS FIRST] Auto-suggest widget that returns P-items limited to 1 or more data types.Apr 2 2019, 4:52 PM
Cparle updated the task description. (Show Details)Apr 5 2019, 3:17 PM
Cparle claimed this task.May 7 2019, 4:29 PM
Lucas_Werkmeister_WMDE renamed this task from [DO THIS FIRST] Auto-suggest widget that returns P-items limited to 1 or more data types to [DO THIS FIRST] Auto-suggest widget that returns properties limited to 1 or more data types.May 9 2019, 10:59 AM
Lucas_Werkmeister_WMDE updated the task description. (Show Details)

Change 509352 had a related patch set uploaded (by Cparle; owner: Cparle):
[mediawiki/extensions/WikibaseMediaInfo@master] Allow ItemInputWidget be used for properties

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

Cparle updated the task description. (Show Details)May 10 2019, 10:32 AM

datatype isn't stored in the search index, and so to do this in wbsearchentities we'd be doing the search query and then filtering the results ... also, datatype is only relevant for wikibase properties, and wbsearchentities can return any kind of entity

For this reason my first attempt at this is on the client side instead

Change 509352 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Allow ItemInputWidget be used for properties

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

Cparle updated the task description. (Show Details)May 15 2019, 11:15 AM

Ok now this is merged, here's how to create a widget with an auto-suggest for properties that'll only show properties with the datatype 'wikibase-item':

var propertyInputWidget = new mw.mediaInfo.statements.ItemInputWidget( { entityType: "property", filter: { field: "datatype", value: "wikibase-item" } } );
$('.someSelector').append( propertyInputWidget.$element );
Cparle closed this task as Resolved.May 15 2019, 11:18 AM
Cparle renamed this task from [DO THIS FIRST] Auto-suggest widget that returns properties limited to 1 or more data types to Auto-suggest widget that returns properties limited to 1 or more data types.May 15 2019, 3:01 PM