jenkins-bot has submitted this change and it was merged.

Change subject: Inject AbstractedRepoApi into views
......................................................................


Inject AbstractedRepoApi into views

Change-Id: Iac8442d396e98ad529e88b91f063e7e130653d97
---
M lib/resources/Resources.php
M lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js
M lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
M lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js
M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
M repo/resources/wikibase.ui.entityViewInit.js
8 files changed, 53 insertions(+), 18 deletions(-)

Approvals:
  Tobias Gritschacher: Looks good to me, approved
  WikidataJenkins: Verified
  jenkins-bot: Verified



diff --git a/lib/resources/Resources.php b/lib/resources/Resources.php
index 7c705fe..a92e69e 100644
--- a/lib/resources/Resources.php
+++ b/lib/resources/Resources.php
@@ -570,7 +570,6 @@
                        'dependencies' => array(
                                'jquery.wikibase.snakview',
                                'jquery.wikibase.snaklistview',
-                               'wikibase.AbstractedRepoApi',
                                'wikibase.datamodel',
                                'jquery.wikibase.toolbarcontroller',
                        ),
@@ -589,7 +588,6 @@
                                'jquery.wikibase.listview',
                                'jquery.wikibase.snaklistview',
                                'jquery.wikibase.toolbarcontroller',
-                               'wikibase.AbstractedRepoApi',
                                'wikibase.datamodel'
                        )
                ),
@@ -611,7 +609,6 @@
                                'jquery.wikibase.listview',
                                'jquery.wikibase.referenceview',
                                'jquery.wikibase.toolbarcontroller',
-                               'wikibase.AbstractedRepoApi',
                                'wikibase.datamodel',
                                'wikibase.utilities',
                        ),
@@ -637,7 +634,6 @@
                                'jquery.wikibase.statementview',
                                'jquery.wikibase.toolbarcontroller',
                                'wikibase',
-                               'wikibase.AbstractedRepoApi',
                                'wikibase.datamodel',
                                'wikibase.RepoApiError',
                                'wikibase.templates',
@@ -661,7 +657,6 @@
                                'jquery.wikibase.toolbarcontroller',
                                'wikibase',
                                'wikibase.datamodel',
-                               'wikibase.AbstractedRepoApi',
                        ),
                ),
 
diff --git 
a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js
index c10182e..cbf12b3 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js
@@ -21,6 +21,7 @@
  *
  * @option {wikibase.store.EntityStore} entityStore
  * @option {wikibase.ValueViewBuilder} valueViewBuilder
+ * @option {wikibase.AbstractedRepoApi} abstractedRepoApi
  */
 $.widget( 'wikibase.claimgrouplistview', PARENT, {
        /**
@@ -39,13 +40,18 @@
                value: null,
                entityType: wb.datamodel.Item.type,
                entityStore: null,
-               valueViewBuilder: null
+               valueViewBuilder: null,
+               abstractedRepoApi: null
        },
 
        /**
         * @see jQuery.Widget._create
         */
        _create: function() {
+               if ( !this.option( 'abstractedRepoApi' ) ) {
+                       throw new Error( 'wikibase.claimgrouplistview requires 
a wikibase.AbstractedRepoApi' );
+               }
+
                PARENT.prototype._create.call( this );
 
                var self = this,
@@ -169,7 +175,8 @@
                                                entityType: self.option( 
'entityType' ),
                                                firstClaimIndex: indexOf( 
value, self.option( 'value' ) ),
                                                entityStore: self.option( 
'entityStore' ),
-                                               valueViewBuilder: self.option( 
'valueViewBuilder' )
+                                               valueViewBuilder: self.option( 
'valueViewBuilder' ),
+                                               abstractedRepoApi: self.option( 
'abstractedRepoApi' )
                                        };
                                }
                        } )
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
index 86d3ce5..29ea853 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
@@ -19,6 +19,8 @@
  * @option {wb.store.EntityStore} entityStore
  *
  * @option {wikibase.ValueViewBuilder} valueViewBuilder
+
+ * @option {wikibase.AbstractedRepoApi} abstractedRepoApi
  *
  * @option {number|null} [firstClaimIndex] The index of the claimlistview's 
first claim within a
  *         list of claims.
@@ -68,7 +70,8 @@
                entityType: null,
                entityStore: null,
                firstClaimIndex: null,
-               valueViewBuilder: null
+               valueViewBuilder: null,
+               abstractedRepoApi: null
        },
 
        /**
@@ -89,6 +92,10 @@
         * @see jQuery.Widget._create
         */
        _create: function() {
+               if ( !this.option( 'abstractedRepoApi' ) ) {
+                       throw new Error( 'wikibase.claimlistview requires a 
wikibase.AbstractedRepoApi' );
+               }
+
                PARENT.prototype._create.call( this );
 
                this._listItemWidget = ( this.option( 'entityType' ) === 'item' 
)
@@ -219,6 +226,7 @@
                                                },
                                                entityStore: self.option( 
'entityStore' ),
                                                valueViewBuilder: self.option( 
'valueViewBuilder' ),
+                                               abstractedRepoApi: self.option( 
'abstractedRepoApi' ),
                                                index: indexOf( value, ( claims 
|| [] ), self.option( 'firstClaimIndex' ) )
                                        };
                                }
@@ -366,10 +374,9 @@
         */
        _removeClaimApiCall: function( claim ) {
                var guid = claim.getGuid(),
-                       abstractedApi = new wb.AbstractedRepoApi(),
                        revStore = wb.getRevisionStore();
 
-               return abstractedApi.removeClaim( guid, 
revStore.getClaimRevision( guid ) );
+               return this.option( 'abstractedRepoApi' ).removeClaim( guid, 
revStore.getClaimRevision( guid ) );
        },
 
        /**
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
index 5bc477d..06cddbc 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
@@ -21,6 +21,8 @@
  *
  * @option {wikibase.ValueViewBuilder} valueViewBuilder
  *
+ * @option {wikibase.AbstractedRepoApi} abstractedRepoApi
+ *
  * @option {number|null} index The claim's index within the list of claims (if 
the claim is
  *         contained within such a list).
  *         Default: null
@@ -87,6 +89,7 @@
                value: null,
                entityStore: null,
                valueViewBuilder: null,
+               abstractedRepoApi: null,
                predefined: {
                        mainSnak: false
                },
@@ -145,6 +148,10 @@
         * @throws {Error} if entityStore option is not set.
         */
        _create: function() {
+               if ( !this.option( 'abstractedRepoApi' ) ) {
+                       throw new Error( 'wikibase.claimview requires a 
wikibase.AbstractedRepoApi' );
+               }
+
                var self = this;
                this._claim = this.option( 'value' );
 
@@ -651,7 +658,6 @@
         */
        _saveClaimApiCall: function() {
                var self = this,
-                       abstractedApi = new wb.AbstractedRepoApi(),
                        revStore = wb.getRevisionStore(),
                        guid;
 
@@ -662,7 +668,7 @@
                        guid = guidGenerator.newGuid( mw.config.get( 
'wbEntityId' ) );
                }
 
-               return abstractedApi.setClaim(
+               return this.option( 'abstractedRepoApi' ).setClaim(
                        this._instantiateClaim( guid ),
                        revStore.getClaimRevision( guid ),
                        this.option( 'index' )
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
index acd4275..f6de46e 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
@@ -13,6 +13,7 @@
  *
  * @option {wb.store.EntityStore} entityStore
  * @option {wb.ValueViewBuilder} valueViewBuilder
+ * @option {wb.AbstractedRepoApi} abstractedRepoApi
  *
  * TODO: this is far from complete, right now this only serves the 
functionality to display an
  *       entity's claims (and statements in case of an item).
@@ -34,13 +35,18 @@
        options: {
                value: null,
                entityStore: null,
-               valueViewBuilder: null
+               valueViewBuilder: null,
+               abstractedRepoApi: null
        },
 
        /**
         * @see jQuery.Widget._create
         */
        _create: function() {
+               if ( !this.option( 'abstractedRepoApi' ) ) {
+                       throw new Error( 'wikibase.entityview requires a 
wikibase.AbstractedRepoApi' );
+               }
+
                var entity = this.option( 'value' );
 
                this.$claims = $( '.wb-claimgrouplistview', this.element 
).first();
@@ -52,7 +58,8 @@
                        value: entity.getClaims(),
                        entityType: entity.getType(),
                        entityStore: this.option( 'entityStore' ),
-                       valueViewBuilder: this.option( 'valueViewBuilder' )
+                       valueViewBuilder: this.option( 'valueViewBuilder' ),
+                       abstractedRepoApi: this.option( 'abstractedRepoApi' )
                } );
 
                this._handleEditModeAffairs();
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js
index 55ac044..6a8a0ac 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js
@@ -17,6 +17,8 @@
  *
  * @option valueViewBuilder {wikibase.ValueViewBuilder}
  *
+ * @option abstractedRepoApi {wikibase.AbstractedRepoApi}
+ *
  * @option index {number|null} The reference's index within the list of 
references (if the reference
  *         is contained within such a list).
  *         Default: null
@@ -78,6 +80,7 @@
                statementGuid: null,
                entityStore: null,
                valueViewBuilder: null,
+               abstractedRepoApi: null,
                index: null,
                helpMessage: mw.msg( 'wikibase-claimview-snak-new-tooltip' )
        },
@@ -126,6 +129,10 @@
 
                if ( !this.option( 'statementGuid' ) ) {
                        throw new Error( 'Statement GUID required to initialize 
a reference view.' );
+               }
+
+               if ( !this.option( 'abstractedRepoApi' ) ) {
+                       throw new Error( 'wikibase.referenceview requires a 
wikibase.AbstractedRepoApi' );
                }
 
                PARENT.prototype._create.call( this );
@@ -547,7 +554,7 @@
        _saveReferenceApiCall: function() {
                var self = this,
                        guid = this.option( 'statementGuid' ),
-                       abstractedApi = new wb.AbstractedRepoApi(),
+                       abstractedApi = this.option( 'abstractedRepoApi' ),
                        revStore = wb.getRevisionStore();
 
                return abstractedApi.setReference(
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
index 963de1b..f87a402 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
@@ -61,6 +61,10 @@
         * @see jQuery.claimview._create
         */
        _create: function() {
+               if ( !this.option( 'abstractedRepoApi' ) ) {
+                       throw new Error( 'wikibase.statementview requires a 
wikibase.AbstractedRepoApi' );
+               }
+
                PARENT.prototype._create.call( this );
 
                var self = this,
@@ -94,7 +98,8 @@
                                                        statementGuid: 
self.value().getGuid(),
                                                        index: index,
                                                        entityStore: 
self.option( 'entityStore' ),
-                                                       valueViewBuilder: 
self.option( 'valueViewBuilder' )
+                                                       valueViewBuilder: 
self.option( 'valueViewBuilder' ),
+                                                       abstractedRepoApi: 
self.option( 'abstractedRepoApi' )
                                                };
                                        }
                                } ),
@@ -347,7 +352,7 @@
         * @return {jQuery.Promise}
         */
        _removeReferenceApiCall: function( reference ) {
-               var abstractedApi = new wb.AbstractedRepoApi(),
+               var abstractedApi = this.option( 'abstractedRepoApi' ),
                        guid = this.value().getGuid();
 
                return abstractedApi.removeReferences(
diff --git a/repo/resources/wikibase.ui.entityViewInit.js 
b/repo/resources/wikibase.ui.entityViewInit.js
index 487abb9..47621ad 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -273,7 +273,8 @@
                                getFormatterStore( repoApi, dataTypes ),
                                getParserStore( repoApi ),
                                mw
-                       )
+                       ),
+                       abstractedRepoApi: abstractedRepoApi
                } ).appendTo( $claimsParent );
 
                // This is here to be sure there is never a duplicate id

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iac8442d396e98ad529e88b91f063e7e130653d97
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <adrian.l...@wikimedia.de>
Gerrit-Reviewer: Adrian Lang <adrian.l...@wikimedia.de>
Gerrit-Reviewer: Henning Snater <henning.sna...@wikimedia.de>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@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