[MediaWiki-commits] [Gerrit] Split up getDataType code in snakview value variation - change (mediawiki...Wikibase)

2015-06-29 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Split up getDataType code in snakview value variation
..


Split up getDataType code in snakview value variation

Makes this code slightly more readable.

Change-Id: I8039b1c234f64aa83425b368f29e0c9c1ce4e731
---
M view/resources/jquery/wikibase/snakview/snakview.variations.Value.js
1 file changed, 21 insertions(+), 11 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/view/resources/jquery/wikibase/snakview/snakview.variations.Value.js 
b/view/resources/jquery/wikibase/snakview/snakview.variations.Value.js
index fea0e98..731a075 100644
--- a/view/resources/jquery/wikibase/snakview/snakview.variations.Value.js
+++ b/view/resources/jquery/wikibase/snakview/snakview.variations.Value.js
@@ -108,6 +108,26 @@
}
 
/**
+* @private
+*
+* @param 
{wikibase.store.FetchedContent|undefined|null} property
+* @return {dataTypes.DataType|null}
+*/
+   function _getDataType( property ) {
+   // If the set property is not there, we have to 
display a warning. This can happen
+   // if a property got deleted but the Snaks 
using it didn't change the property.
+   var dataTypeId = property
+   ? property.getContent().getDataTypeId()
+   : false;
+
+   if( dataTypeId ) {
+   return self._dataTypeStore.getDataType( 
dataTypeId );
+   }
+
+   return null;
+   }
+
+   /**
 * Handles a data value type mismatch by rendering 
appropriate messages.
 * Such a mismatch can happen whenever something 
changes internally but there were no
 * update scripts executed to change the data store. 
E.g. if a data type changes its
@@ -161,17 +181,7 @@
return;
}
 
-   // If the set property is not there, we 
have to display a warning. This can
-   // happen if a property got deleted but 
the Snaks using it didn't change the
-   // property.
-   var dataTypeId = fetchedProperty
-   ? 
fetchedProperty.getContent().getDataTypeId()
-   : false;
-   var dataType = null;
-
-   if( dataTypeId ) {
-   dataType = 
self._dataTypeStore.getDataType( dataTypeId );
-   }
+   var dataType = _getDataType( 
fetchedProperty );
 
// If the new value's type is not the 
data value type used by the Snak's
// property data type, something is 
very wrong. Display warning!

-- 
To view, visit https://gerrit.wikimedia.org/r/219353
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8039b1c234f64aa83425b368f29e0c9c1ce4e731
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude aude.w...@gmail.com
Gerrit-Reviewer: Aude aude.w...@gmail.com
Gerrit-Reviewer: Hoo man h...@online.de
Gerrit-Reviewer: Thiemo Mättig (WMDE) thiemo.maet...@wikimedia.de
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Split up getDataType code in snakview value variation - change (mediawiki...Wikibase)

2015-06-19 Thread Aude (Code Review)
Aude has uploaded a new change for review.

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

Change subject: Split up getDataType code in snakview value variation
..

Split up getDataType code in snakview value variation

Makes this code slightly more readable.

Change-Id: I8039b1c234f64aa83425b368f29e0c9c1ce4e731
---
M view/resources/jquery/wikibase/snakview/snakview.variations.Value.js
1 file changed, 19 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/53/219353/1

diff --git 
a/view/resources/jquery/wikibase/snakview/snakview.variations.Value.js 
b/view/resources/jquery/wikibase/snakview/snakview.variations.Value.js
index fea0e98..2e4ae93 100644
--- a/view/resources/jquery/wikibase/snakview/snakview.variations.Value.js
+++ b/view/resources/jquery/wikibase/snakview/snakview.variations.Value.js
@@ -161,17 +161,7 @@
return;
}
 
-   // If the set property is not there, we 
have to display a warning. This can
-   // happen if a property got deleted but 
the Snaks using it didn't change the
-   // property.
-   var dataTypeId = fetchedProperty
-   ? 
fetchedProperty.getContent().getDataTypeId()
-   : false;
-   var dataType = null;
-
-   if( dataTypeId ) {
-   dataType = 
self._dataTypeStore.getDataType( dataTypeId );
-   }
+   var dataType = self._getDataType( 
fetchedProperty );
 
// If the new value's type is not the 
data value type used by the Snak's
// property data type, something is 
very wrong. Display warning!
@@ -212,6 +202,24 @@
},
 
/**
+* @param {wikibase.store.FetchedContent} property|null
+* @private
+*/
+   _getDataType: function( property ) {
+   // If the set property is not there, we have to display 
a warning. This can happen
+   // if a property got deleted but the Snaks using it 
didn't change the property.
+   var dataTypeId = property
+   ? property.getContent().getDataTypeId()
+   : false;
+
+   if( dataTypeId ) {
+   return this._dataTypeStore.getDataType( 
dataTypeId );
+   }
+
+   return null;
+   },
+
+   /**
 * @inheritdoc
 */
startEditing: function() {

-- 
To view, visit https://gerrit.wikimedia.org/r/219353
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8039b1c234f64aa83425b368f29e0c9c1ce4e731
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude aude.w...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits