2023-05-10 14:23:42 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface EditCheckInspector class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2023-05-10 14:23:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit check inspector
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.FragmentInspector
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ui.EditCheckInspector = function VeUiEditCheckInspector( config ) {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ui.EditCheckInspector.super.call( this, config );
|
|
|
|
|
|
|
|
// Pre-initialization
|
|
|
|
this.$element.addClass( 've-ui-editCheckInspector' );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.EditCheckInspector, ve.ui.FragmentInspector );
|
|
|
|
|
2023-08-14 16:07:00 +00:00
|
|
|
ve.ui.EditCheckInspector.static.name = 'editCheckReferencesInspector';
|
2023-05-10 14:23:42 +00:00
|
|
|
|
|
|
|
// ve.ui.EditCheckInspector.static.title = OO.ui.deferMsg( 'editcheck-dialog-title' );
|
|
|
|
ve.ui.EditCheckInspector.static.title = OO.ui.deferMsg( 'editcheck-dialog-addref-title' );
|
|
|
|
|
|
|
|
// ve.ui.EditCheckInspector.static.size = 'context';
|
|
|
|
|
|
|
|
ve.ui.EditCheckInspector.static.actions = [
|
|
|
|
{
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ),
|
|
|
|
flags: [ 'safe', 'back' ],
|
|
|
|
modes: [ 'mobile', 'desktop' ]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
action: 'continue',
|
|
|
|
icon: 'next',
|
|
|
|
flags: [ 'primary', 'progressive' ],
|
|
|
|
modes: [ 'mobile' ]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.EditCheckInspector.prototype.initialize = function () {
|
|
|
|
// Parent method
|
|
|
|
ve.ui.EditCheckInspector.super.prototype.initialize.call( this );
|
|
|
|
|
|
|
|
// Survey panel
|
|
|
|
this.answerRadioSelect = new OO.ui.RadioSelectWidget( {
|
|
|
|
items: [
|
|
|
|
new OO.ui.RadioOptionWidget( {
|
2023-08-24 03:16:02 +00:00
|
|
|
data: 'uncertain',
|
|
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-uncertain' )
|
2023-05-10 14:23:42 +00:00
|
|
|
} ),
|
|
|
|
new OO.ui.RadioOptionWidget( {
|
2023-08-24 03:16:02 +00:00
|
|
|
data: 'common-knowledge',
|
|
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-common-knowledge' )
|
2023-05-10 14:23:42 +00:00
|
|
|
} ),
|
|
|
|
new OO.ui.RadioOptionWidget( {
|
2023-08-24 03:16:02 +00:00
|
|
|
data: 'irrelevant',
|
|
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-irrelevant' )
|
2023-05-10 14:23:42 +00:00
|
|
|
} ),
|
|
|
|
new OO.ui.RadioOptionWidget( {
|
|
|
|
data: 'other',
|
|
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-other' )
|
|
|
|
} )
|
|
|
|
]
|
|
|
|
} );
|
|
|
|
this.answerRadioSelect.connect( this, { select: 'updateActions' } );
|
|
|
|
|
|
|
|
this.answerConfirm = new OO.ui.ButtonWidget( {
|
|
|
|
flags: [ 'progressive' ],
|
|
|
|
framed: false,
|
2023-10-09 15:02:19 +00:00
|
|
|
label: ve.msg( 'ooui-dialog-process-continue' ),
|
2023-05-10 14:23:42 +00:00
|
|
|
disabled: true
|
|
|
|
} );
|
|
|
|
this.answerConfirm.toggle( !OO.ui.isMobile() );
|
|
|
|
this.answerConfirm.connect( this, { click: [ 'executeAction', 'continue' ] } );
|
|
|
|
|
|
|
|
this.form.addItems(
|
|
|
|
new OO.ui.FieldsetLayout( {
|
|
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-question' ),
|
|
|
|
items: [
|
|
|
|
new OO.ui.FieldLayout( this.answerRadioSelect, {
|
|
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-description' ),
|
|
|
|
align: 'top'
|
|
|
|
} ),
|
|
|
|
new OO.ui.FieldLayout( this.answerConfirm, {
|
|
|
|
align: 'left'
|
|
|
|
} )
|
|
|
|
]
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.ui.EditCheckInspector.prototype.updateActions = function () {
|
2024-06-28 04:23:34 +00:00
|
|
|
const isSelected = !!this.answerRadioSelect.findSelectedItem();
|
|
|
|
// desktop
|
|
|
|
this.answerConfirm.setDisabled( !isSelected );
|
|
|
|
// mobile
|
|
|
|
this.actions.setAbilities( { continue: isSelected } );
|
2023-05-10 14:23:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.EditCheckInspector.prototype.getSetupProcess = function ( data ) {
|
|
|
|
data = data || {};
|
|
|
|
return ve.ui.EditCheckInspector.super.prototype.getSetupProcess.call( this, data )
|
|
|
|
.first( function () {
|
|
|
|
this.surface = data.surface;
|
|
|
|
this.saveProcessDeferred = data.saveProcessDeferred;
|
|
|
|
this.answerRadioSelect.selectItem( null );
|
|
|
|
}, this );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.EditCheckInspector.prototype.getReadyProcess = function ( data ) {
|
|
|
|
return ve.ui.EditCheckInspector.super.prototype.getReadyProcess.call( this, data )
|
|
|
|
.first( function () {
|
|
|
|
this.actions.setMode( OO.ui.isMobile() ? 'mobile' : 'desktop' );
|
2024-06-28 04:23:34 +00:00
|
|
|
this.updateActions();
|
2023-05-10 14:23:42 +00:00
|
|
|
}, this );
|
|
|
|
};
|
|
|
|
|
2024-11-19 13:41:38 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2023-05-10 14:23:42 +00:00
|
|
|
ve.ui.EditCheckInspector.prototype.getActionProcess = function ( action ) {
|
|
|
|
if ( action === '' ) {
|
|
|
|
return new OO.ui.Process( function () {
|
|
|
|
this.close();
|
|
|
|
}, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( action === 'continue' ) {
|
|
|
|
return new OO.ui.Process( function () {
|
|
|
|
this.close( { action: 'reject', reason: this.answerRadioSelect.findSelectedItem().getData() } );
|
2023-08-14 16:07:00 +00:00
|
|
|
ve.track( 'activity.editCheckReferences', { action: 'dialog-choose-' + this.answerRadioSelect.findSelectedItem().getData() } );
|
2023-05-10 14:23:42 +00:00
|
|
|
}, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ve.ui.EditCheckInspector.super.prototype.getActionProcess.call( this, action );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.windowFactory.register( ve.ui.EditCheckInspector );
|