mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-27 15:50:29 +00:00
Rename OutlineParameterCheckboxWidget to OutlineParameterCheckboxLayout
This not really just a checkbox widget anymore it inherits from FieldLayout and became something more in that direction. Let's use a mixture of these things to make it a bit clearer. See also comment in Ie81b84be288553343017c4aaf8691c4e266995f5 Change-Id: Iff1746a8e5e94b56eb6c27465405aaf6b74c2310
This commit is contained in:
parent
4761ed3b15
commit
407ff95597
|
@ -19,6 +19,7 @@
|
|||
{
|
||||
"name": "User Interface",
|
||||
"classes": [
|
||||
"ve.ui.MW*Layout",
|
||||
"ve.ui.MW*Page",
|
||||
"ve.ui.MW*Window",
|
||||
"ve.ui.MWTransclusionsBooklet"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
{
|
||||
"name": "User Interface",
|
||||
"classes": [
|
||||
"ve.ui.MW*Layout",
|
||||
"ve.ui.MW*Page",
|
||||
"ve.ui.MW*Window",
|
||||
"ve.ui.MWTransclusionsBooklet"
|
||||
|
|
|
@ -2149,7 +2149,7 @@
|
|||
"modules/ve-mw/ui/contextitems/ve.ui.MWTransclusionContextItem.js",
|
||||
"modules/ve-mw/ui/contextitems/ve.ui.MWDefinedTransclusionContextItem.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTemplateOutlineCheckboxListWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTemplateOutlineParameterCheckboxWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTemplateOutlineParameterCheckboxLayout.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTemplateOutlineTemplateWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineContainerWidget.js"
|
||||
],
|
||||
|
@ -2832,7 +2832,7 @@
|
|||
"lib/ve/rebaser/src/dm/ve.dm.RebaseServer.js",
|
||||
"lib/ve/tests/dm/ve.dm.TestRebaseClient.js",
|
||||
"lib/ve/tests/dm/ve.dm.TestRebaseServer.js",
|
||||
"modules/ve-mw/tests/ui/widgets/ve.ui.MWTemplateOutlineParameterCheckboxWidget.test.js"
|
||||
"modules/ve-mw/tests/ui/widgets/ve.ui.MWTemplateOutlineParameterCheckboxLayout.test.js"
|
||||
],
|
||||
"dependencies": [
|
||||
"unicodejs",
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
( function () {
|
||||
QUnit.module( 've.ui.MWTemplateOutlineParameterCheckboxLayout', ve.test.utils.mwEnvironment );
|
||||
|
||||
QUnit.test( 'interprets param with no attributes', ( assert ) => {
|
||||
const layout = new ve.ui.MWTemplateOutlineParameterCheckboxLayout( {} );
|
||||
|
||||
assert.strictEqual( layout.fieldWidget.disabled, false );
|
||||
assert.strictEqual( layout.fieldWidget.selected, false );
|
||||
assert.strictEqual( layout.fieldWidget.title, null );
|
||||
} );
|
||||
|
||||
QUnit.test( 'interprets required param', ( assert ) => {
|
||||
const layout = new ve.ui.MWTemplateOutlineParameterCheckboxLayout( { required: true } );
|
||||
|
||||
assert.strictEqual( layout.fieldWidget.disabled, true );
|
||||
assert.strictEqual( layout.fieldWidget.selected, true );
|
||||
assert.notStrictEqual( layout.fieldWidget.title, null );
|
||||
} );
|
||||
|
||||
QUnit.test( 'interprets included param', ( assert ) => {
|
||||
const layout = new ve.ui.MWTemplateOutlineParameterCheckboxLayout( { selected: true } );
|
||||
|
||||
assert.strictEqual( layout.fieldWidget.disabled, false );
|
||||
assert.strictEqual( layout.fieldWidget.selected, true );
|
||||
assert.strictEqual( layout.fieldWidget.title, null );
|
||||
} );
|
||||
}() );
|
|
@ -1,27 +0,0 @@
|
|||
( function () {
|
||||
QUnit.module( 've.ui.MWTemplateOutlineParameterCheckboxWidget', ve.test.utils.mwEnvironment );
|
||||
|
||||
QUnit.test( 'interprets param with no attributes', ( assert ) => {
|
||||
const widget = new ve.ui.MWTemplateOutlineParameterCheckboxWidget( {} );
|
||||
|
||||
assert.strictEqual( widget.fieldWidget.disabled, false );
|
||||
assert.strictEqual( widget.fieldWidget.selected, false );
|
||||
assert.strictEqual( widget.fieldWidget.title, null );
|
||||
} );
|
||||
|
||||
QUnit.test( 'interprets required param', ( assert ) => {
|
||||
const widget = new ve.ui.MWTemplateOutlineParameterCheckboxWidget( { required: true } );
|
||||
|
||||
assert.strictEqual( widget.fieldWidget.disabled, true );
|
||||
assert.strictEqual( widget.fieldWidget.selected, true );
|
||||
assert.notStrictEqual( widget.fieldWidget.title, null );
|
||||
} );
|
||||
|
||||
QUnit.test( 'interprets included param', ( assert ) => {
|
||||
const widget = new ve.ui.MWTemplateOutlineParameterCheckboxWidget( { selected: true } );
|
||||
|
||||
assert.strictEqual( widget.fieldWidget.disabled, false );
|
||||
assert.strictEqual( widget.fieldWidget.selected, true );
|
||||
assert.strictEqual( widget.fieldWidget.title, null );
|
||||
} );
|
||||
}() );
|
|
@ -531,7 +531,7 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) {
|
|||
// Generate sample data.
|
||||
items: intRange.map(
|
||||
function ( j ) {
|
||||
return new ve.ui.MWTemplateOutlineParameterCheckboxWidget( {
|
||||
return new ve.ui.MWTemplateOutlineParameterCheckboxLayout( {
|
||||
required: j < 5,
|
||||
// TODO: Label can be a passed as an unevaluated lazy message function.
|
||||
label: 'Parameter number ' + ( j + 1 ) + ' plus long text continuation',
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* @constructor
|
||||
* @param {Object} [config] Configuration options
|
||||
* @cfg {ve.ui.MWTemplateOutlineParameterCheckboxWidget[]} [items] An array of options to add to the multiselect.
|
||||
* @cfg {ve.ui.MWTemplateOutlineParameterCheckboxLayout[]} [items] An array of options to add to the multiselect.
|
||||
*/
|
||||
ve.ui.MWTemplateOutlineCheckboxListWidget = function VeUiMWTemplateOutlineCheckboxListWidget( config ) {
|
||||
// Parent constructor
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* VisualEditor user interface MWTemplateOutlineParameterCheckboxWidget class.
|
||||
* VisualEditor user interface MWTemplateOutlineParameterCheckboxLayout class.
|
||||
*
|
||||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
@ -8,12 +8,12 @@
|
|||
* Container for checkbox and label
|
||||
*
|
||||
* @class
|
||||
* @extends OO.ui.Widget
|
||||
* @extends OO.ui.FieldLayout
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWTemplateOutlineParameterCheckboxWidget = function VeUiMWTemplateOutlineParameterCheckboxWidget( config ) {
|
||||
ve.ui.MWTemplateOutlineParameterCheckboxLayout = function VeUiMWTemplateOutlineParameterCheckboxLayout( config ) {
|
||||
config = config || {};
|
||||
config = $.extend( { align: 'inline' }, config );
|
||||
|
||||
|
@ -28,7 +28,7 @@ ve.ui.MWTemplateOutlineParameterCheckboxWidget = function VeUiMWTemplateOutlineP
|
|||
} );
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWTemplateOutlineParameterCheckboxWidget.super.call( this, checkbox, config );
|
||||
ve.ui.MWTemplateOutlineParameterCheckboxLayout.super.call( this, checkbox, config );
|
||||
|
||||
// Initialization
|
||||
this.$element.addClass( 've-ui-templateOutlineItem' );
|
||||
|
@ -43,14 +43,14 @@ ve.ui.MWTemplateOutlineParameterCheckboxWidget = function VeUiMWTemplateOutlineP
|
|||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWTemplateOutlineParameterCheckboxWidget, OO.ui.FieldLayout );
|
||||
OO.inheritClass( ve.ui.MWTemplateOutlineParameterCheckboxLayout, OO.ui.FieldLayout );
|
||||
|
||||
/* Methods */
|
||||
ve.ui.MWTemplateOutlineParameterCheckboxWidget.prototype.onEdit = function ( value ) {
|
||||
ve.ui.MWTemplateOutlineParameterCheckboxLayout.prototype.onEdit = function ( value ) {
|
||||
this.emit( 'change', value );
|
||||
};
|
||||
|
||||
ve.ui.MWTemplateOutlineParameterCheckboxWidget.prototype.onLabelClick = function () {
|
||||
ve.ui.MWTemplateOutlineParameterCheckboxLayout.prototype.onLabelClick = function () {
|
||||
if ( !this.fieldWidget.isSelected() ) {
|
||||
this.fieldWidget.setSelected( true );
|
||||
}
|
Loading…
Reference in a new issue