mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-11 16:49:26 +00:00
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:
parent
d056400800
commit
48d0699f09
|
@ -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 );
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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' );
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue