Jonas Kress (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/251494
Change subject: Remove referenceview edit mode handling ...................................................................... Remove referenceview edit mode handling Bug: T117702 Change-Id: I227c5ff2ac8842ea0e6b8f3490bdfa572997aa1a --- M view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementview-referenceview.js M view/resources/jquery/wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js 2 files changed, 12 insertions(+), 85 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/94/251494/1 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 index 58d3fd0..3537d5b 100644 --- a/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementview-referenceview.js +++ b/view/resources/jquery/wikibase/toolbar/controller/definitions/addtoolbar/statementview-referenceview.js @@ -31,6 +31,9 @@ return; } + $listview.closest( '.wikibase-statementview' ) + .data( 'statementview' ).startEditing(); + listview.enterNewItem().done( function( $referenceview ) { var referenceview = lia.liInstance( $referenceview ); referenceview.focus(); diff --git a/view/resources/jquery/wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js b/view/resources/jquery/wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js index ac516d4..bf44a5e 100644 --- a/view/resources/jquery/wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js +++ b/view/resources/jquery/wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js @@ -12,108 +12,32 @@ selector: ':' + $.wikibase.referenceview.prototype.namespace + '-' + $.wikibase.referenceview.prototype.widgetName, events: { - referenceviewcreate: function( event ) { + referenceviewafterstartediting: function( event ) { var $referenceview = $( event.target ), referenceview = $referenceview.data( 'referenceview' ), options = {}, - $container = $referenceview.find( '.wikibase-toolbar-container' ); - - if ( !$container.length ) { $container = $( '<div/>' ).appendTo( $referenceview.find( '.wikibase-referenceview-heading' ) ); - } options.$container = $container; - function removeFromListView() { - var $statementview = $referenceview.closest( ':wikibase-statementview' ), - statementview = $statementview.data( 'statementview' ); + var $statementview = $referenceview.closest( ':wikibase-statementview' ), + statementview = $statementview.data( 'statementview' ); + function removeFromListView() { statementview._referencesListview.removeItem( $referenceview ); } - if ( !referenceview.options.statementGuid || !referenceview.value() ) { - var $statementview = $referenceview.closest( ':wikibase-statementview' ), - statementview = $statementview.data( 'statementview' ); - if ( !statementview.isInEditMode() ) { - options.label = mw.msg( 'wikibase-cancel' ); - } - $referenceview.removetoolbar( options ) - .on( 'removetoolbarremove.removetoolbar', function( event ) { - removeFromListView(); - } ); - - return; + if ( ( !referenceview.options.statementGuid || !referenceview.value() ) && !statementview.isInEditMode() ) { + options.label = mw.msg( 'wikibase-cancel' ); } - - options.getHelpMessage = function() { - return $.Deferred().resolve( referenceview.options.helpMessage ).promise(); - }; - - var edittoolbar = $referenceview.edittoolbar( options ).data( 'edittoolbar' ); - - var guid = referenceview.options.statementGuid; - var referencesChanger = referenceview.options.referencesChanger; - var controller = new wikibase.view.ToolbarViewController( - { - remove: function( reference ) { - return referencesChanger.removeReference( guid, reference ); - }, - save: function( reference ) { - return referencesChanger.setReference( guid, reference ); - } - }, - edittoolbar, - referenceview - ); - edittoolbar.setController( controller ); - edittoolbar.option( - 'onRemove', - function() { - controller.remove().done( function() { - removeFromListView(); - } ); - } - ); - - $referenceview.on( 'keydown.edittoolbar', function( event ) { - if ( referenceview.option( 'disabled' ) ) { - return; - } - if ( event.keyCode === $.ui.keyCode.ESCAPE ) { - controller.stopEditing( true ); - } else if ( event.keyCode === $.ui.keyCode.ENTER ) { - controller.stopEditing( false ); - } + $referenceview.removetoolbar( options ) + .on( 'removetoolbarremove.removetoolbar', function( event ) { + removeFromListView(); } ); - }, - referenceviewdisable: function( event ) { - var $referenceview = $( event.target ), - referenceview = $referenceview.data( 'referenceview' ); - if ( !referenceview ) { - return; - } - - var disable = referenceview.option( 'disabled' ), - edittoolbar = $referenceview.data( 'edittoolbar' ); - - if ( !edittoolbar ) { - return; - } - - var btnSave = edittoolbar.getButton( 'save' ), - enableSave = ( referenceview.isValid() && !referenceview.isInitialValue() ); - - edittoolbar.option( 'disabled', disable ); - if ( !disable ) { - btnSave.option( 'disabled', !enableSave ); - } } - - // Destroying the referenceview will destroy the toolbar. Trying to destroy the toolbar - // in parallel will cause interference. } } ); -- To view, visit https://gerrit.wikimedia.org/r/251494 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I227c5ff2ac8842ea0e6b8f3490bdfa572997aa1a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits