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

Reply via email to