Adrian Lang has uploaded a new change for review. https://gerrit.wikimedia.org/r/110151
Change subject: Use API for formatting Wikibase item links ...................................................................... Use API for formatting Wikibase item links Change-Id: Ida65a6c07572bf146ac496e5e23fb0615ddc73db --- M composer.json M lib/resources/Resources.php M lib/resources/formatters/wikibase.formatters.register.js M lib/resources/jquery.valueview.experts.wikibase/experts.wikibase.EntityIdValue.js 4 files changed, 12 insertions(+), 37 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/51/110151/1 diff --git a/composer.json b/composer.json index 9540cac..c7fde1c 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "data-values/data-types": "~0.1", "data-values/serialization": "~0.1", "data-values/javascript": "~0.2", - "data-values/value-view": "0.*,>=0.1.1", + "data-values/value-view": "master-dev", "wikibase/data-model": "0.6.*", "diff/diff": ">=0.9", "wikibase/easyrdf_lite": "*" diff --git a/lib/resources/Resources.php b/lib/resources/Resources.php index 1b20432..fd4c090 100644 --- a/lib/resources/Resources.php +++ b/lib/resources/Resources.php @@ -160,6 +160,7 @@ 'dataValues.values', 'mw.ext.valueFormatters', 'wikibase.QuantityFormatter', + 'wikibase.datamodel' ), ), @@ -847,7 +848,6 @@ 'jquery.eachchange', 'jquery.inputautoexpand', 'wikibase.utilities', - 'wikibase.store.FetchedContent' ), 'messages' => array( 'wikibase-entity-item', diff --git a/lib/resources/formatters/wikibase.formatters.register.js b/lib/resources/formatters/wikibase.formatters.register.js index 9ea1470..e875c97 100644 --- a/lib/resources/formatters/wikibase.formatters.register.js +++ b/lib/resources/formatters/wikibase.formatters.register.js @@ -17,4 +17,9 @@ wb.dataTypes.getDataType( 'commonsMedia' ) ); + mw.ext.valueFormatters.valueFormatterProvider.registerDataValueFormatter( + wb.formatters.ApiBasedValueFormatter, + wb.EntityId.TYPE + ); + }( mediaWiki, wikibase, dataValues ) ); diff --git a/lib/resources/jquery.valueview.experts.wikibase/experts.wikibase.EntityIdValue.js b/lib/resources/jquery.valueview.experts.wikibase/experts.wikibase.EntityIdValue.js index cf73014..9ff0acb 100644 --- a/lib/resources/jquery.valueview.experts.wikibase/experts.wikibase.EntityIdValue.js +++ b/lib/resources/jquery.valueview.experts.wikibase/experts.wikibase.EntityIdValue.js @@ -2,7 +2,7 @@ * @licence GNU GPL v2+ * @author Daniel Werner < daniel.wer...@wikimedia.de > */ -( function( mw, wb, $, vv ) { +( function( mw, wb, vv ) { 'use strict'; // temporarily define a hard coded prefix map until we get this from the server @@ -13,27 +13,6 @@ var PARENT = vv.BifidExpert, editableExpert = vv.experts.wikibase.EntityIdInput; - - /** - * Helper for building a pretty link or info about an Entity. - * - * @param {string} entityId - * @returns jQuery - */ - function buildEntityRefDom( entityId ) { - var fetchedEntity = wb.fetchedEntities[ entityId ]; - - if( !fetchedEntity ) { - // Entity missing, deleted or not in local store, generate info: - return wb.utilities.ui.buildMissingEntityInfo( entityId, wb.Item ); - } - - var $label = wb.utilities.ui.buildPrettyEntityLabel( fetchedEntity.getContent() ); - - return $( '<a/>', { - href: fetchedEntity.getTitle().getUrl() - } ).append( $label ); - } /** * Valueview expert for handling Wikibase Entity references. @@ -59,24 +38,15 @@ */ _staticExpertOptions: { domBuilder: function( currentRawValue, viewState ) { - if( !currentRawValue ) { - return ''; - } - - // We have to check for string or instance of wb.EntityId since the EntityIdInput - // expert has this huge flaw that it takes a wb.EntityId but returns a string as - // raw value. This is all related to the current entity ID mess. - var entityId = currentRawValue instanceof wb.EntityId - ? currentRawValue.getPrefixedId( WB_ENTITIES_PREFIXMAP ) - : currentRawValue; - - return buildEntityRefDom( entityId ); + return viewState.getFormattedValue(); }, baseExpert: editableExpert }, /** * @see jQuery.valueview.Expert.valueCharacteristics + * + * TODO: remove this once the parsing is done via API */ valueCharacteristics: function() { return { prefixmap: WB_ENTITIES_PREFIXMAP }; @@ -90,4 +60,4 @@ vv.experts.wikibase.EntityIdValue ); -}( mediaWiki, wikibase, jQuery, jQuery.valueview ) ); +}( mediaWiki, wikibase, jQuery.valueview ) ); -- To view, visit https://gerrit.wikimedia.org/r/110151 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ida65a6c07572bf146ac496e5e23fb0615ddc73db Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Adrian Lang <adrian.l...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits