jenkins-bot has submitted this change and it was merged.
Change subject: Update EntityId expert(s) to reflect changes in ValueView
......................................................................
Update EntityId expert(s) to reflect changes in ValueView
This requires version 0.4 of ValueView
Change-Id: Ic05b08d93641175c5e2ca58e991b51275be38080
---
M lib/WikibaseLib.hooks.php
M lib/resources/experts/EntityIdInput.js
D lib/resources/experts/EntityIdValue.js
M lib/resources/experts/resources.php
M lib/resources/experts/wikibase.experts.register.js
M lib/resources/formatters/wikibase.formatters.register.js
A lib/tests/qunit/experts/EntityIdInput.tests.js
M tests/browser/features/step_definitions/statement_steps.rb
M tests/browser/features/support/modules/statement_module.rb
9 files changed, 57 insertions(+), 138 deletions(-)
Approvals:
Tobias Gritschacher: Looks good to me, approved
WikidataJenkins: Verified
jenkins-bot: Verified
diff --git a/lib/WikibaseLib.hooks.php b/lib/WikibaseLib.hooks.php
index 5dc47c2..6457118 100644
--- a/lib/WikibaseLib.hooks.php
+++ b/lib/WikibaseLib.hooks.php
@@ -263,6 +263,16 @@
),
);
+ $testModules['qunit']['wikibase.experts.EntityIdInput.tests'] =
$moduleBase + array(
+ 'scripts' => array(
+ 'tests/qunit/experts/EntityIdInput.tests.js',
+ ),
+ 'dependencies' => array(
+ 'wikibase.experts.EntityIdInput',
+ 'wikibase.tests.qunit.testrunner',
+ ),
+ );
+
$testModules['qunit']['wikibase.parsers.EntityIdParser.tests']
= $moduleBase + array(
'scripts' => array(
'tests/qunit/wikibase.tests.js',
diff --git a/lib/resources/experts/EntityIdInput.js
b/lib/resources/experts/EntityIdInput.js
index 187f52e..117ce1e 100644
--- a/lib/resources/experts/EntityIdInput.js
+++ b/lib/resources/experts/EntityIdInput.js
@@ -25,19 +25,14 @@
* @extends jQuery.valueview.experts.StringValue
*/
wb.experts.EntityIdInput = vv.expert( 'wikibaseentityidinput', PARENT, {
- /**
- * Field used to remember a value as current value while the
value can't be displayed by
- * the entity selector as current value. Used if an Entity not
in the system is set as
- * current value. false implies that the current value is the
one of the entity selector.
- * @type {false|string}
- */
- _actualValue: false,
/**
* @see Query.valueview.experts.StringValue._init
*/
_init: function() {
PARENT.prototype._init.call( this );
+
+ // FIXME: Use SuggestedStringValue
var notifier = this._viewNotifier,
$input = this.$input,
@@ -46,82 +41,48 @@
$input.entityselector( {
url: mw.util.wikiScript( 'api' ),
selectOnAutocomplete: true
- } )
+ } );
+
+ var value = this.viewState().value();
+ var entityId = value && value.getPrefixedId(
WB_ENTITIES_PREFIXMAP );
+
+ this.$input.data( 'entityselector' ).selectedEntity(
entityId );
+ $input
.on( 'entityselectorselect', function( e, ui ) {
self._resizeInput();
} )
- .on(
- // "aftersetentity": When setting the entity
programmatically (editing an existing
- // Snak).
- // "response": Each time an API query returns
(the input value gets auto-completed).
- // "close": After having selected an entity by
clicking on a suggestion list item.
- 'entityselectoraftersetentity
entityselectorresponse entityselectorclose'
- + ' eachchange',
+ .on( 'eachchange',
function( e ) {
- self._resizeInput();
$( this ).data( 'entityselector'
).repositionMenu();
}
)
.on(
- 'eachchange entityselectorselect
entityselectoraftersetentity',
+ 'entityselectoraftersetentity',
function( e ) {
- // Entity selector's value is actual
value after change.
- self._actualValue = false;
-
- if( e.type !== 'eachchange' ) {
- // Already registered to
'eachchange' in StringValue expert.
- notifier.notify( 'change' );
- }
+ notifier.notify( 'change' );
}
);
},
/**
- * @see Query.valueview.Expert._getRawValue
+ * @see jQuery.valueview.Expert.rawValue
*
* @return string
- *
- * TODO: get/setRawValue should be consistent. Right now one
takes a DataValue object while
- * the other returns a string!
*/
- _getRawValue: function() {
- if( this._actualValue !== false ) {
- // Empty input field is displayed because some
entity, not in the system, is set as
- // current value.
- return this._actualValue;
- }
+ rawValue: function() {
var entitySelector = this.$input.data( 'entityselector'
),
selectedEntity =
entitySelector.selectedEntity();
- return selectedEntity ? selectedEntity.id : null;
+ return selectedEntity ? selectedEntity.id : '';
},
/**
- * @see Query.valueview.Expert._setRawValue
+ * @see jQuery.valueview.Expert.valueCharacteristics
*
- * @return wb.EntityId
+ * TODO: remove this once the parsing is done via API
*/
- _setRawValue: function( rawValue ) {
- var entityId = rawValue instanceof wb.EntityId
- ? rawValue.getPrefixedId( WB_ENTITIES_PREFIXMAP
)
- // TODO: be consistent with get/set, don't
check for string and EntityId!
- : ( ( typeof rawValue === 'string' && rawValue
) ? rawValue : null );
-
- this.$input.data( 'entityselector' ).selectedEntity(
entityId );
- this._resizeInput();
- },
-
- /**
- * @see Query.valueview.experts.StringValue.draw
- */
- draw: function() {
- this._newValue = false; // we use the entityselector to
manage the value immediately
- PARENT.prototype.draw.call( this );
-
- // Make sure entityselector is closed in non-edit mode:
- if( !this._viewState.isInEditMode() ) {
- this.$input.data( 'entityselector' ).close();
- }
+ valueCharacteristics: function() {
+ return { prefixmap: WB_ENTITIES_PREFIXMAP };
}
} );
diff --git a/lib/resources/experts/EntityIdValue.js
b/lib/resources/experts/EntityIdValue.js
deleted file mode 100644
index 1469eb5..0000000
--- a/lib/resources/experts/EntityIdValue.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @licence GNU GPL v2+
- * @author Daniel Werner < [email protected] >
- */
-wikibase.experts = wikibase.experts || {};
-
-( function( wb, vv ) {
- 'use strict';
-
- // temporarily define a hard coded prefix map until we get this from
the server
- var WB_ENTITIES_PREFIXMAP = {
- 'Q': 'item',
- 'P': 'property'
- };
-
- var PARENT = vv.BifidExpert,
- editableExpert = wb.experts.EntityIdInput;
-
- /**
- * Valueview expert for handling Wikibase Entity references.
- *
- * @since 0.4
- *
- * @constructor
- * @extends jQuery.valueview.experts.StringValue
- */
- wb.experts.EntityIdValue = vv.expert( 'entityidvalue', PARENT, {
- /**
- * @see jQuery.valueview.BifidExpert._editableExpert
- */
- _editableExpert: editableExpert,
-
- /**
- * @see jQuery.valueview.BifidExpert._staticExpert
- */
- _staticExpert: vv.experts.StaticDom,
-
- /**
- * @see jQuery.valueview.BifidExpert._staticExpertOptions
- */
- _staticExpertOptions: {
- domBuilder: function( currentRawValue, viewState ) {
- 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 };
- }
- } );
-
-}( wikibase, jQuery.valueview ) );
diff --git a/lib/resources/experts/resources.php
b/lib/resources/experts/resources.php
index 821346f..f03d950 100644
--- a/lib/resources/experts/resources.php
+++ b/lib/resources/experts/resources.php
@@ -23,11 +23,10 @@
),
'dependencies' => array(
'jquery.valueview.experts.CommonsMediaType',
- 'jquery.valueview.experts.UrlType',
'mw.ext.valueView',
'wikibase.dataTypes',
'wikibase.datamodel',
- 'wikibase.experts.EntityIdValue',
+ 'wikibase.experts.EntityIdInput',
),
),
@@ -46,21 +45,6 @@
'wikibase.datamodel',
),
),
-
- 'wikibase.experts.EntityIdValue' => $moduleTemplate + array(
- 'scripts' => array(
- 'EntityIdValue.js',
- ),
- 'dependencies' => array(
- 'jquery',
- 'jquery.valueview.Expert',
- 'jquery.valueview.BifidExpert',
- 'jquery.valueview.experts.StaticDom',
- 'wikibase',
- 'wikibase.experts.EntityIdInput',
- ),
- ),
-
);
} );
diff --git a/lib/resources/experts/wikibase.experts.register.js
b/lib/resources/experts/wikibase.experts.register.js
index c5d6d9c..5591c19 100644
--- a/lib/resources/experts/wikibase.experts.register.js
+++ b/lib/resources/experts/wikibase.experts.register.js
@@ -6,7 +6,7 @@
'use strict';
mw.ext.valueView.expertProvider.registerDataValueExpert(
- wb.experts.EntityIdValue,
+ wb.experts.EntityIdInput,
wb.EntityId.TYPE
);
@@ -24,7 +24,7 @@
var urlType = dataTypeStore.getDataType( 'url' );
if( urlType ) {
mw.ext.valueView.expertProvider.registerDataTypeExpert(
- vv.experts.UrlType,
+ vv.experts.StringValue,
urlType.getId()
);
}
diff --git a/lib/resources/formatters/wikibase.formatters.register.js
b/lib/resources/formatters/wikibase.formatters.register.js
index aea16a7..c008789 100644
--- a/lib/resources/formatters/wikibase.formatters.register.js
+++ b/lib/resources/formatters/wikibase.formatters.register.js
@@ -24,6 +24,11 @@
mw.ext.valueFormatters.valueFormatterProvider.registerDataValueFormatter(
wb.formatters.ApiBasedValueFormatter,
+ dv.StringValue.TYPE
+ );
+
+
mw.ext.valueFormatters.valueFormatterProvider.registerDataValueFormatter(
+ wb.formatters.ApiBasedValueFormatter,
dv.TimeValue.TYPE
);
diff --git a/lib/tests/qunit/experts/EntityIdInput.tests.js
b/lib/tests/qunit/experts/EntityIdInput.tests.js
new file mode 100644
index 0000000..71b087b
--- /dev/null
+++ b/lib/tests/qunit/experts/EntityIdInput.tests.js
@@ -0,0 +1,17 @@
+/**
+ * @licence GNU GPL v2+
+ * @author H. Snater < [email protected] >
+ */
+( function( $, QUnit, valueview ) {
+ 'use strict';
+
+ var testExpert = valueview.tests.testExpert;
+
+ QUnit.module( 'wikibase.experts.EntityIdInput' );
+
+ testExpert( {
+ expertConstructor: wikibase.experts.EntityIdInput,
+ } );
+
+}( jQuery, QUnit, jQuery.valueview ) );
+
diff --git a/tests/browser/features/step_definitions/statement_steps.rb
b/tests/browser/features/step_definitions/statement_steps.rb
index aaf397a..c1e7fb7 100644
--- a/tests/browser/features/step_definitions/statement_steps.rb
+++ b/tests/browser/features/step_definitions/statement_steps.rb
@@ -115,5 +115,5 @@
end
Then /^Statement string value of claim (.+) in group (.+) should be (.+)$/ do
|claim_index, group_index, value|
- on(ItemPage).statement_string_value_element(group_index,
claim_index).attribute_value("value").should == value
+ on(ItemPage).statement_string_value(group_index, claim_index).should == value
end
diff --git a/tests/browser/features/support/modules/statement_module.rb
b/tests/browser/features/support/modules/statement_module.rb
index 42bc4f9..15db72d 100644
--- a/tests/browser/features/support/modules/statement_module.rb
+++ b/tests/browser/features/support/modules/statement_module.rb
@@ -50,8 +50,8 @@
@browser.element(css: ".wb-claimlistview:nth-child(#{group_index})
div.wb-claim-name")
end
- def statement_string_value_element(group_index, claim_index)
- @browser.element(xpath: "//div[contains(@class,
'wb-claimlistview')][#{group_index}]//div[contains(@class,
'listview-item')][#{claim_index}]//textarea[contains(@class,
'valueview-input')]")
+ def statement_string_value(group_index, claim_index)
+ @browser.element(xpath: "//div[contains(@class,
'wb-claimlistview')][#{group_index}]//div[contains(@class,
'listview-item')][#{claim_index}]//div[contains(@class,
'valueview-instaticmode')]").text
end
def edit_claim(group_index, claim_index)
--
To view, visit https://gerrit.wikimedia.org/r/118705
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic05b08d93641175c5e2ca58e991b51275be38080
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>
Gerrit-Reviewer: Adrian Lang <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: WikidataJenkins <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits