jenkins-bot has submitted this change and it was merged. Change subject: Remove addtoolbar/statementview-referenceview ......................................................................
Remove addtoolbar/statementview-referenceview Change-Id: If84d8e63df86f26ba5fc253d338632ffd8f9a93c --- M repo/resources/Resources.php M repo/resources/wikibase.ui.entityViewInit.js M view/resources/jquery/wikibase/jquery.wikibase.statementview.js M view/resources/jquery/wikibase/resources.php M view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementlistview-statementview.js D view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementview-referenceview.js M view/resources/jquery/wikibase/toolbar/controller/resources.php M view/resources/wikibase/view/ControllerViewFactory.js M view/resources/wikibase/view/ViewFactory.js M view/tests/qunit/jquery/wikibase/jquery.wikibase.statementview.tests.js M view/tests/qunit/wikibase/view/ViewFactory.tests.js 11 files changed, 45 insertions(+), 100 deletions(-) Approvals: Jonas Kress (WMDE): Looks good to me, approved jenkins-bot: Verified diff --git a/repo/resources/Resources.php b/repo/resources/Resources.php index c49854c..617ab26 100644 --- a/repo/resources/Resources.php +++ b/repo/resources/Resources.php @@ -82,7 +82,6 @@ 'jquery.wikibase.toolbarcontroller.definitions.addtoolbar.statementgrouplistview-statementgroupview', 'jquery.wikibase.toolbarcontroller.definitions.addtoolbar.statementlistview-statementview', 'jquery.wikibase.toolbarcontroller.definitions.addtoolbar.referenceview-snakview', - 'jquery.wikibase.toolbarcontroller.definitions.addtoolbar.statementview-referenceview', 'jquery.wikibase.toolbarcontroller.definitions.addtoolbar.statementview-snakview', 'jquery.wikibase.toolbarcontroller.definitions.removetoolbar.referenceview', 'jquery.wikibase.toolbarcontroller.definitions.removetoolbar.referenceview-snakview', diff --git a/repo/resources/wikibase.ui.entityViewInit.js b/repo/resources/wikibase.ui.entityViewInit.js index 12222f1..a2369e2 100644 --- a/repo/resources/wikibase.ui.entityViewInit.js +++ b/repo/resources/wikibase.ui.entityViewInit.js @@ -28,7 +28,6 @@ 'statementgrouplistview-statementgroupview', 'statementlistview-statementview', 'statementview-snakview', - 'statementview-referenceview', 'referenceview-snakview' ], removetoolbar: [ diff --git a/view/resources/jquery/wikibase/jquery.wikibase.statementview.js b/view/resources/jquery/wikibase/jquery.wikibase.statementview.js index 91ac71d..01f0914 100644 --- a/view/resources/jquery/wikibase/jquery.wikibase.statementview.js +++ b/view/resources/jquery/wikibase/jquery.wikibase.statementview.js @@ -138,6 +138,12 @@ _$toggler: null, /** + * @property {Object} + * @private + */ + _referenceAdder: null, + + /** * @inheritdoc * @protected * @@ -161,6 +167,21 @@ } else { this._createReferencesToggler(); } + + var self = this; + this._referenceAdder = this.options.getAdder( + function() { + var listview = self._referencesListview, + lia = listview.listItemAdapter(); + + listview.enterNewItem().done( function( $referenceview ) { + var referenceview = lia.liInstance( $referenceview ); + referenceview.focus(); + } ); + }, + this.$references, + mw.msg( 'wikibase-addreference' ) + ); this.element.toggleClass( 'wb-new', this.options.value === null ); }, @@ -454,6 +475,8 @@ .off( '.' + this.widgetName ) .empty(); this._referencesListview = null; + this._referenceAdder.destroy(); + this._referenceAdder = null; }, /** @@ -728,6 +751,7 @@ if ( this._referencesListview ) { this._referencesListview.option( key, value ); } + this._referenceAdder[ value ? 'disable' : 'enable'](); } if ( key === 'value' ) { this.element.toggleClass( 'wb-new', value === null ); diff --git a/view/resources/jquery/wikibase/resources.php b/view/resources/jquery/wikibase/resources.php index ca93844..0be9dbb 100644 --- a/view/resources/jquery/wikibase/resources.php +++ b/view/resources/jquery/wikibase/resources.php @@ -411,6 +411,7 @@ 'wikibase.utilities', ), 'messages' => array( + 'wikibase-addreference', 'wikibase-claimview-snak-tooltip', 'wikibase-claimview-snak-new-tooltip', 'wikibase-statementview-rank-preferred', diff --git a/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementlistview-statementview.js b/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementlistview-statementview.js index 355eb73..da331d0 100644 --- a/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementlistview-statementview.js +++ b/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementlistview-statementview.js @@ -33,9 +33,7 @@ return; } - statementlistview.enterNewItem().done( function( statementview ) { - statementview.focus(); - } ); + statementlistview.enterNewItem(); // Re-focus "add" button after having added or having cancelled adding a statement: var eventName = 'statementlistviewafterstopediting.addtoolbar'; diff --git a/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementview-referenceview.js b/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementview-referenceview.js deleted file mode 100644 index d00b0a5..0000000 --- a/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementview-referenceview.js +++ /dev/null @@ -1,76 +0,0 @@ -( function( $, mw ) { - 'use strict'; - -/** - * @ignore - * - * @license GPL-2.0+ - * @author H. Snater < mediaw...@snater.com > - */ -$.wikibase.toolbarcontroller.definition( 'addtoolbar', { - id: 'statementview-referenceview', - selector: '.wikibase-statementview', - events: { - statementviewcreate: function( event, toolbarController ) { - var $statementview = $( event.target ), - statementview = $statementview.data( 'statementview' ), - $node = statementview.$references; - $node = $( '<div/>' ).appendTo( $node ); - - $node - .addtoolbar( { - label: mw.msg( 'wikibase-addreference' ) - } ) - .on( 'addtoolbaradd.addtoolbar', function( e ) { - if ( e.target !== $node.get( 0 ) ) { - return; - } - - statementview._controller.startEditing().done( function() { - var listview = statementview._referencesListview, - lia = listview.listItemAdapter(); - - listview.enterNewItem().done( function( $referenceview ) { - var referenceview = lia.liInstance( $referenceview ); - referenceview.focus(); - } ); - } ); - } ); - - toolbarController.registerEventHandler( - event.data.toolbar.type, - event.data.toolbar.id, - 'listviewdestroy', - function( event, toolbarController ) { - var $listview = $( event.target ), - $node = $listview.parent(); - - if ( !$node.hasClass( '.wikibase-statementview-references' ) ) { - return; - } - - toolbarController.destroyToolbar( $node.data( 'addtoolbar' ) ); - $node.off( 'addtoolbar' ); - } - ); - - toolbarController.registerEventHandler( - event.data.toolbar.type, - event.data.toolbar.id, - 'statementviewdisable', - function( event ) { - if ( event.target !== $statementview.get( 0 ) ) { - return; - } - $node.data( 'addtoolbar' )[ - statementview.option( 'disabled' ) - ? 'disable' - : 'enable' - ](); - } - ); - } - } -} ); - -}( jQuery, mediaWiki ) ); diff --git a/view/resources/jquery/wikibase/toolbar/controller/resources.php b/view/resources/jquery/wikibase/toolbar/controller/resources.php index 55367f8..851e0d4 100644 --- a/view/resources/jquery/wikibase/toolbar/controller/resources.php +++ b/view/resources/jquery/wikibase/toolbar/controller/resources.php @@ -51,21 +51,6 @@ ), ), - 'jquery.wikibase.toolbarcontroller.definitions.addtoolbar.statementview-referenceview' => $moduleTemplate + array( - 'scripts' => array( - 'definitions/addtoolbar/statementview-referenceview.js', - ), - 'dependencies' => array( - 'jquery.wikibase.addtoolbar', - 'jquery.wikibase.listview', - 'jquery.wikibase.statementview', - 'jquery.wikibase.toolbarcontroller', - ), - 'messages' => array( - 'wikibase-addreference', - ), - ), - 'jquery.wikibase.toolbarcontroller.definitions.addtoolbar.statementview-snakview' => $moduleTemplate + array( 'scripts' => array( 'definitions/addtoolbar/statementview-snakview.js', diff --git a/view/resources/wikibase/view/ControllerViewFactory.js b/view/resources/wikibase/view/ControllerViewFactory.js index 0b51fcd..3a1115e 100644 --- a/view/resources/wikibase/view/ControllerViewFactory.js +++ b/view/resources/wikibase/view/ControllerViewFactory.js @@ -98,7 +98,7 @@ }; var statementsChanger = this._entityChangersFactory.getStatementsChanger(); - controller = statementview._controller = this._getController( + controller = this._getController( this._toolbarFactory.getToolbarContainer( statementview.element ), statementview, statementsChanger, diff --git a/view/resources/wikibase/view/ViewFactory.js b/view/resources/wikibase/view/ViewFactory.js index 883359c..30b5e36 100644 --- a/view/resources/wikibase/view/ViewFactory.js +++ b/view/resources/wikibase/view/ViewFactory.js @@ -401,6 +401,7 @@ }; SELF.prototype.getStatementView = function( startEditingCallback, entityId, propertyId, value, $dom ) { + var structureEditorFactory = this._structureEditorFactory; var currentPropertyId = value ? value.getClaim().getMainSnak().getPropertyId() : propertyId; var view = this._getView( 'statementview', @@ -426,6 +427,12 @@ false ), entityIdPlainFormatter: this._entityIdPlainFormatter, + getAdder: function( doAdd, $dom, label ) { + var newDoAdd = function() { + return startEditingCallback().then( doAdd ); + }; + return structureEditorFactory.getAdder( newDoAdd, $dom, label ); + }, guidGenerator: new wb.utilities.ClaimGuidGenerator( entityId ), qualifiersListItemAdapter: this.getListItemAdapterForSnakListView( startEditingCallback ) } diff --git a/view/tests/qunit/jquery/wikibase/jquery.wikibase.statementview.tests.js b/view/tests/qunit/jquery/wikibase/jquery.wikibase.statementview.tests.js index 30ad200..de02176 100644 --- a/view/tests/qunit/jquery/wikibase/jquery.wikibase.statementview.tests.js +++ b/view/tests/qunit/jquery/wikibase/jquery.wikibase.statementview.tests.js @@ -27,6 +27,11 @@ */ var createStatementview = function( options, $node ) { options = $.extend( { + getAdder: function() { + return { + destroy: function() {} + }; + }, buildReferenceListItemAdapter: function() { return wb.tests.getMockListItemAdapter( 'mytestreferenceview', diff --git a/view/tests/qunit/wikibase/view/ViewFactory.tests.js b/view/tests/qunit/wikibase/view/ViewFactory.tests.js index 24bc4a4..8d66dab 100644 --- a/view/tests/qunit/wikibase/view/ViewFactory.tests.js +++ b/view/tests/qunit/wikibase/view/ViewFactory.tests.js @@ -228,8 +228,9 @@ var entityId = 'Q1', value = null, entityIdPlainFormatter = {}, + structureEditorFactory = { getAdder: function() {} }, viewFactory = new ViewFactory( - null, + structureEditorFactory, null, null, null, @@ -287,7 +288,8 @@ var entityId = 'Q1', propertyId = 'propertyId', value = null, - viewFactory = new ViewFactory(), + structureEditorFactory = { getAdder: function() {} }, + viewFactory = new ViewFactory( structureEditorFactory ), ListItemAdapter = sinon.spy( $.wikibase.listview, 'ListItemAdapter' ), dom = {}; @@ -315,7 +317,8 @@ assert.expect( 1 ); var propertyId = 'P1', value = new wb.datamodel.Statement( new wb.datamodel.Claim( new wb.datamodel.PropertyNoValueSnak( propertyId ) ) ), - viewFactory = new ViewFactory(), + structureEditorFactory = { getAdder: function() {} }, + viewFactory = new ViewFactory( structureEditorFactory ), ListItemAdapter = sinon.spy( $.wikibase.listview, 'ListItemAdapter' ), dom = {}; -- To view, visit https://gerrit.wikimedia.org/r/298756 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If84d8e63df86f26ba5fc253d338632ffd8f9a93c Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Adrian Heine <m...@adrianheine.de> Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.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