Wikidata/Notes/valueview Widgets

Widgets required as interface between the user and 'DataValue' objects.

$('...').valueview.widget

edit

Base for several widgets where each is specific to one type of DataValue. Widgets for more complicated types of DataValue might consist out of several basic widgets. These are somewhat similar to the old wb.ui.PropertyEditTool.EditableValue.Interface (details) and its different implementations.

They represent the value as static DOM but also serve the input form to edit the value. Usually different variations of this are just used as wrappers, holding another jQuery widget (e.g. a data picker or a map). This is necessary to have a very basic common (programming-) interface for different widgets as well as managing the widgets static DOM representation.

Note: Not yet clear whether this has to know about which ValueFormatter should be used to display the value or whether we want to use ValueFormatter definitions at all for displaying the static DOM version.


Public functions:

  • startEditing() for switching into the view where edit forms are displayed.
  • stopEditing( resetValue ) for switching back into static DOM view. if resetValue is true, the initial value from before starting the edit mode will be displayed again.
  • value() (NOTE: Think about this naming since it doesn't directly return a DataValue) returns a $.Promise (because of API interaction). When resolved, the promises callback will provide the current value as DataValue object.
  • value( value ) changes the view to display the given DataValue.
  • ...

Example implementations:

  • $('...').valueview.geocoordinate
  • $('...').valueview.string
  • $('...').valueview.date
  • ...

Options

  • value: DataValue (optional) initial value to be displayed.
  • ...


$('...').valueview

edit

Serves as a factory, initiating the right widget for creating a DataValue for a given DataType object.

Obviously, this will require a map of which valueview.value widget is responsible for which type of data value.

Note: Later, there might be a second map allowing to register specific, more fine-grained widgets specific to DataType objects rather than widgets only for DataValue.

Options:

  • dataType: DataType information required to choose the right widget for factoring a DataValue of that type.
  • ...other options to be passed through to the actual data type specific widget...

$('...').valueeditor

edit

(inherits or uses $('...').valueview)

Some higher level concept of an editor using the valueview widget. This will contain a mechanism for rendering a live-preview while the user is typing. This could also serve an edit toolbar already, implementing the logic for 'edit', 'cancel' and other buttons to switch between edit/static DOM modes and to fire additional events.

Options: Same options as the valueview widget plus some options for controlling additional edit features.