Page MenuHomePhabricator

[MEX] 3.1.2 Extend strategy pattern to include the input field in WikibaseWbui2025EditableSnakValue using `<component :is='...'>`
Closed, ResolvedPublic

Description

The WikibaseWbui2025EditableSnakValue component currently has different input elements depending on the value type:

<cdx-text-input v-if="!valueStrategy.isLookupDatatype() && snakTypeSelection === 'value'" v-model="textvalue"></cdx-text-input>
<cdx-lookup
	v-else-if="valueStrategy.isLookupDatatype()"
	v-model:selected="lookupSelection"
	v-model:input-value="lookupInputValue"
	:menu-items="lookupMenuItems"
	:menu-config="menuConfig"
	@update:input-value="onUpdateInputValue"
	@load-more="onLoadMore"
>
</cdx-lookup>

The <v-if>/<v-else-if>/<v-else> pattern is not especially maintainable or extensible, and leads to the view becoming busy with logic for all the different types of inputs, without it being clear what logic applies for which snak types.

Extend the valueStrategy pattern to inject the appropriate input element for the current data type, moving associated state management logic to subcomponents (e.g. SnakTextInput, SnakLookupInput).

Acceptance Criteria

  • WikibaseWbui2025EditableSnakValue no longer includes <v-if>/<v-else-if> to display the snak input field, and instead uses <component is='...'> to inject an appropriate subcomponent.
  • Appropriate subcomponents are implemented, and encapsulate the logic for the input type.

Event Timeline

Change #1204808 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Use valueStrategy pattern to manage componens in editableSnakValue

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

Change #1204808 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Use valueStrategy pattern to manage componens in editableSnakValue

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