aboutsummaryrefslogtreecommitdiffstats
path: root/includes/htmlform/fields/HTMLCheckMatrix.php
diff options
context:
space:
mode:
authorMoriel Schottlender <moriel@gmail.com>2018-07-26 16:14:41 -0700
committerBartosz DziewoƄski <matma.rex@gmail.com>2018-08-22 21:31:27 +0200
commit5a430cdc1c0224b8e95509b58ad4be7abda2674c (patch)
treed62072d4fc96a1ae62a4591090d3381391e02af3 /includes/htmlform/fields/HTMLCheckMatrix.php
parent82acdac2c4f7553fefc7d3b1188cca1546b471d2 (diff)
downloadmediawikicore-5a430cdc1c0224b8e95509b58ad4be7abda2674c.tar.gz
mediawikicore-5a430cdc1c0224b8e95509b58ad4be7abda2674c.zip
OOUIfy CheckMatrix in PHP and JS
This is to make sure that the design is similar, but also so that the widget can be read in JS where needed and that we can toggle the disabled state on/off through the whole widget, that is made from a series of checkbox widgets. Bug: T199946 Change-Id: I9943b0aa1746fdfb60c7d4c88d6d4d7ac0589a2c
Diffstat (limited to 'includes/htmlform/fields/HTMLCheckMatrix.php')
-rw-r--r--includes/htmlform/fields/HTMLCheckMatrix.php55
1 files changed, 37 insertions, 18 deletions
diff --git a/includes/htmlform/fields/HTMLCheckMatrix.php b/includes/htmlform/fields/HTMLCheckMatrix.php
index da68a626a6be..a679e45951af 100644
--- a/includes/htmlform/fields/HTMLCheckMatrix.php
+++ b/includes/htmlform/fields/HTMLCheckMatrix.php
@@ -129,7 +129,7 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
$thisAttribs['class'] = 'checkmatrix-forced checkmatrix-forced-on';
}
- $checkbox = $this->getOneCheckbox( $checked, $attribs + $thisAttribs );
+ $checkbox = $this->getOneCheckboxHTML( $checked, $attribs + $thisAttribs );
$rowContents .= Html::rawElement(
'td',
@@ -148,24 +148,35 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
return $html;
}
- protected function getOneCheckbox( $checked, $attribs ) {
- if ( $this->mParent instanceof OOUIHTMLForm ) {
- return new OOUI\CheckboxInputWidget( [
- 'name' => "{$this->mName}[]",
- 'selected' => $checked,
- ] + OOUI\Element::configFromHtmlAttributes(
- $attribs
- ) );
- } else {
- $checkbox = Xml::check( "{$this->mName}[]", $checked, $attribs );
- if ( $this->mParent->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
- $checkbox = Html::openElement( 'div', [ 'class' => 'mw-ui-checkbox' ] ) .
- $checkbox .
- Html::element( 'label', [ 'for' => $attribs['id'] ] ) .
- Html::closeElement( 'div' );
- }
- return $checkbox;
+ public function getInputOOUI( $value ) {
+ $attribs = $this->getAttributes( [ 'disabled', 'tabindex' ] );
+
+ return new MediaWiki\Widget\CheckMatrixWidget(
+ [
+ 'name' => $this->mName,
+ 'infusable' => true,
+ 'id' => $this->mID,
+ 'rows' => $this->mParams['rows'],
+ 'columns' => $this->mParams['columns'],
+ 'tooltips' => $this->mParams['tooltips'],
+ 'forcedOff' => isset( $this->mParams['force-options-off'] ) ?
+ $this->mParams['force-options-off'] : [],
+ 'forcedOn' => isset( $this->mParams['force-options-on'] ) ?
+ $this->mParams['force-options-on'] : [],
+ 'values' => $value
+ ] + OOUI\Element::configFromHtmlAttributes( $attribs )
+ );
+ }
+
+ protected function getOneCheckboxHTML( $checked, $attribs ) {
+ $checkbox = Xml::check( "{$this->mName}[]", $checked, $attribs );
+ if ( $this->mParent->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
+ $checkbox = Html::openElement( 'div', [ 'class' => 'mw-ui-checkbox' ] ) .
+ $checkbox .
+ Html::element( 'label', [ 'for' => $attribs['id'] ] ) .
+ Html::closeElement( 'div' );
}
+ return $checkbox;
}
protected function isTagForcedOff( $tag ) {
@@ -262,4 +273,12 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
return $res;
}
+
+ protected function getOOUIModules() {
+ return [ 'mediawiki.widgets.CheckMatrixWidget' ];
+ }
+
+ protected function shouldInfuseOOUI() {
+ return true;
+ }
}