Git rid of the ref class property in the dialog class

The model is now fully owned by the edit panel and I could not find
any usages of this outside of that class using codesearch.

Bug: T369005
Change-Id: I911fee99d6c910e6e40e0b3cbdb4c7ab60b413c6
This commit is contained in:
WMDE-Fisch 2024-08-13 19:37:50 +02:00
parent 3af9dfdb71
commit f5c96716f0

View file

@ -19,7 +19,6 @@ ve.ui.MWReferenceDialog = function VeUiMWReferenceDialog( config ) {
ve.ui.MWReferenceDialog.super.call( this, config ); ve.ui.MWReferenceDialog.super.call( this, config );
// Properties // Properties
this.referenceModel = null;
this.reuseReference = false; this.reuseReference = false;
}; };
@ -185,13 +184,13 @@ ve.ui.MWReferenceDialog.prototype.insertReference = function ( ref ) {
ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) { ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) {
if ( action === 'insert' || action === 'done' ) { if ( action === 'insert' || action === 'done' ) {
return new OO.ui.Process( () => { return new OO.ui.Process( () => {
this.referenceModel = this.editPanel.getReferenceFromEditing(); const ref = this.editPanel.getReferenceFromEditing();
if ( !( this.selectedNode instanceof ve.dm.MWReferenceNode ) ) { if ( !( this.selectedNode instanceof ve.dm.MWReferenceNode ) ) {
this.insertReference( this.referenceModel ); this.insertReference( ref );
} }
this.referenceModel.updateInternalItem( this.getFragment().getSurface() ); ref.updateInternalItem( this.getFragment().getSurface() );
this.close( { action: action } ); this.close( { action: action } );
} ); } );
@ -212,15 +211,16 @@ ve.ui.MWReferenceDialog.prototype.getSetupProcess = function ( data ) {
this.editPanel.setInternalList( this.getFragment().getDocument().getInternalList() ); this.editPanel.setInternalList( this.getFragment().getDocument().getInternalList() );
this.actions.setAbilities( { done: false } ); this.actions.setAbilities( { done: false } );
let ref;
if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) { if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) {
// edit an existing reference // edit an existing reference
this.referenceModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.selectedNode ); ref = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.selectedNode );
} else { } else {
// create a new reference // create a new reference
this.referenceModel = new ve.dm.MWReferenceModel( this.getFragment().getDocument() ); ref = new ve.dm.MWReferenceModel( this.getFragment().getDocument() );
this.actions.setAbilities( { insert: false } ); this.actions.setAbilities( { insert: false } );
} }
this.editPanel.setReferenceForEditing( this.referenceModel ); this.editPanel.setReferenceForEditing( ref );
this.editPanel.setReadOnly( this.isReadOnly() ); this.editPanel.setReadOnly( this.isReadOnly() );
this.reuseSearch.setInternalList( this.getFragment().getDocument().getInternalList() ); this.reuseSearch.setInternalList( this.getFragment().getDocument().getInternalList() );
@ -242,7 +242,6 @@ ve.ui.MWReferenceDialog.prototype.getTeardownProcess = function ( data ) {
.first( () => { .first( () => {
this.editPanel.clear(); this.editPanel.clear();
this.reuseSearch.clearSearch(); this.reuseSearch.clearSearch();
this.referenceModel = null;
} ); } );
}; };