Daniel Werner has uploaded a new change for review.
https://gerrit.wikimedia.org/r/64544
Change subject: Update of the jQuery.wikibase.Claimview's isValid behavior
......................................................................
Update of the jQuery.wikibase.Claimview's isValid behavior
isValid() does not return true for an empty value now. Returning true in this
case did result into
"save" buttons being enabled in some cases where the value was empty and where
saving the value
would result in an error being thrown.
Change-Id: If4e1196551835776100382416430ae289f82c825
---
M lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
M lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js
2 files changed, 9 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/44/64544/1
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
index edefed6..6344718 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
@@ -177,14 +177,19 @@
},
/**
- * Returns whether the claimview is valid according to its current
contents.
+ * Returns whether the claimview is valid according to its current
contents. An Empty value
+ * will be considered not valid (also, an empty value can not be saved).
* @since 0.4
*
* @return {boolean}
*/
isValid: function() {
- var snakview = this.$mainSnak.data( 'snakview' );
- return ( snakview.isValid() && ( !this._qualifiers ||
this._qualifiers.isValid() ) );
+ try {
+ this._instantiateClaim( null );
+ } catch( e ) {
+ return false;
+ }
+ return true;
},
/**
@@ -382,6 +387,7 @@
*
* @param {string} guid
* @return {wb.Claim}
+ * @throws {Error} In case the widget's current value is insufficient
for building a claim.
*/
_instantiateClaim: function( guid ) {
return new wb.Claim(
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js
index 98f51c2..5cf74b2 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js
@@ -567,7 +567,6 @@
this.draw();
},
-
/**
* Returns the current Snak represented by the view or null in case the
view is in edit mode,
* also allows to set the view to represent a given Snak.
--
To view, visit https://gerrit.wikimedia.org/r/64544
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If4e1196551835776100382416430ae289f82c825
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits