Henning Snater has uploaded a new change for review.
https://gerrit.wikimedia.org/r/99343
Change subject: Use explicit checks for setClaim's/setReference's index
parameter
......................................................................
Use explicit checks for setClaim's/setReference's index parameter
Change-Id: If62023aa2898d99cb3e2d83110da19992c43272d
---
M lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
1 file changed, 12 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/43/99343/1
diff --git a/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
b/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
index d5456c1..906c461 100644
--- a/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
+++ b/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
@@ -230,7 +230,8 @@
*
* @param {object} claim
* @param {number} baseRevId
- * @param {number} [index]
+ * @param {number} [index] The claim index. Only needs to be specified
if the claim's index
+ * within the list of all claims of the parent entity shall be
changed.
* @return {jQuery.Promise}
*/
setClaim: function( claim, baseRevId, index ) {
@@ -240,7 +241,7 @@
baserevid: baseRevId
};
- if( index ) {
+ if( index !== undefined ) {
params.index = index;
}
@@ -349,8 +350,9 @@
* @param {number} baseRevId
* @param {string} [referenceHash] A hash of the reference that should
be updated.
* If not provided, a new reference is created.
- * @param {number} [index] The new reference's index. Only needs to be
specified if the
- * reference's index within the list of all the statement's
references shall be changed.
+ * @param {number} [index] The reference index. Only needs to be
specified if the reference's
+ * index within the list of all references of the parent
statement shall be changed or
+ * when the reference should be inserted at a specific position.
* @return {jQuery.Promise}
*/
setReference: function( statementGuid, snaks, baseRevId, referenceHash,
index ) {
@@ -361,11 +363,16 @@
baserevid: baseRevId
};
+ if( index === undefined && typeof referenceHash === 'number' ) {
+ index = referenceHash;
+ referenceHash = undefined;
+ }
+
if( referenceHash ) {
params.reference = referenceHash;
}
- if( index ) {
+ if( index !== undefined ) {
params.index = index;
}
--
To view, visit https://gerrit.wikimedia.org/r/99343
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If62023aa2898d99cb3e2d83110da19992c43272d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits