[refactor] Don't setup the edit panel when re-using a ref

In the setup process the dialog is loaded and initialized. For the
case where the user opens this dialog to directly re-use a
reference, it does not make sense to fill out the form or create
the internal ref model. The edit panel is not used then.

This method might also be an entry point to create a new sub-ref
when triggered from e.g. Citoid. Switching to the re-use panel
still would not require to setup the edit panel.

I'm also moving a setup for the abilities, that's only relevant
in the edit case.

Bug: T375156
Change-Id: I061b88abc6cfd702a53208bac76be7a2ed6812c2
This commit is contained in:
WMDE-Fisch 2024-09-19 10:22:57 +02:00
parent 442ba0bf6b
commit 60eb760dd8

View file

@ -234,33 +234,32 @@ ve.ui.MWReferenceDialog.prototype.getSetupProcess = function ( data ) {
data = data || {};
return ve.ui.MWReferenceDialog.super.prototype.getSetupProcess.call( this, data )
.next( () => {
this.panels.setItem( this.editPanel );
const docRefs = ve.dm.MWDocumentReferences.static.refsForDoc(
this.getFragment().getDocument()
);
this.editPanel.setDocumentReferences( docRefs );
this.actions.setAbilities( { done: false } );
let ref;
if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) {
// edit an existing reference
ref = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.selectedNode );
if ( ref.extendsRef ) {
this.title.setLabel( ve.msg( 'cite-ve-dialog-reference-title-edit-details' ) );
}
} else {
// create a new reference
ref = new ve.dm.MWReferenceModel( this.getFragment().getDocument() );
this.actions.setAbilities( { insert: false } );
}
this.editPanel.setReferenceForEditing( ref );
this.editPanel.setReadOnly( this.isReadOnly() );
this.reuseSearch.setInternalList( this.getFragment().getDocument().getInternalList() );
this.reuseReference = !!data.reuseReference;
if ( this.reuseReference ) {
this.reuseSearch.setInternalList( this.getFragment().getDocument().getInternalList() );
this.openReusePanel();
} else {
this.panels.setItem( this.editPanel );
const docRefs = ve.dm.MWDocumentReferences.static.refsForDoc(
this.getFragment().getDocument()
);
this.editPanel.setDocumentReferences( docRefs );
let ref;
if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) {
// edit an existing reference
ref = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.selectedNode );
if ( ref.extendsRef ) {
this.title.setLabel( ve.msg( 'cite-ve-dialog-reference-title-edit-details' ) );
}
this.actions.setAbilities( { done: false } );
} else {
// create a new reference
ref = new ve.dm.MWReferenceModel( this.getFragment().getDocument() );
this.actions.setAbilities( { insert: false } );
}
this.editPanel.setReferenceForEditing( ref );
this.editPanel.setReadOnly( this.isReadOnly() );
}
this.trackedInputChange = false;