Add method to get the updated ref from the edit panel

That's another step to separate the editing form the dialog. The dialog should not know about internals of the edit panel.

And eventually the dialog can get rid of the referenceModel property.

Bug: T369005
Change-Id: I9cf3a68ef58bc5791497af362c0572734e4bcadd
This commit is contained in:
WMDE-Fisch 2024-08-01 17:12:11 +02:00
parent d056400800
commit 48d0699f09
3 changed files with 15 additions and 1 deletions

View file

@ -219,7 +219,7 @@ ve.ui.MWReferenceDialog.prototype.insertReference = function ( ref ) {
ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) {
if ( action === 'insert' || action === 'done' ) {
return new OO.ui.Process( () => {
this.referenceModel.setGroup( this.editPanel.referenceGroupInput.getValue() );
this.referenceModel = this.editPanel.getReferenceFromEditing();
if ( !( this.selectedNode instanceof ve.dm.MWReferenceNode ) ) {
this.insertReference( this.referenceModel );

View file

@ -31,6 +31,7 @@ ve.ui.MWReferenceEditPanel = function VeUiMWReferenceEditPanel( config ) {
// Properties
this.originalGroup = null;
this.internalList = null;
this.referenceModel = null;
// Create content editor
this.referenceTarget = ve.init.target.createTargetWidget(
@ -192,11 +193,23 @@ ve.ui.MWReferenceEditPanel.prototype.setInternalList = function ( internalList )
* @param {ve.dm.MWReferenceModel} ref
*/
ve.ui.MWReferenceEditPanel.prototype.setReferenceForEditing = function ( ref ) {
this.referenceModel = ref;
this.setFormFieldsFromRef( ref );
this.updateReuseWarningFromRef( ref );
this.updateExtendsWarningFromRef( ref );
};
/**
* @return {ve.dm.MWReferenceModel|null} Updated reference
*/
ve.ui.MWReferenceEditPanel.prototype.getReferenceFromEditing = function () {
if ( this.referenceModel ) {
this.referenceModel.setGroup( this.referenceGroupInput.getValue() );
}
return this.referenceModel;
};
/**
* @private
* @param {ve.dm.MWReferenceModel} ref

View file

@ -23,4 +23,5 @@ QUnit.test( 'setReferenceForEditing', ( assert ) => {
assert.false( editPanel.referenceGroupInput.isDisabled() );
assert.false( editPanel.reuseWarning.isVisible() );
assert.false( editPanel.extendsWarning.isVisible() );
assert.strictEqual( editPanel.getReferenceFromEditing().getGroup(), 'g' );
} );