Jforrester has uploaded a new change for review. https://gerrit.wikimedia.org/r/292038
Change subject: Update OOjs UI to v0.17.4 ...................................................................... Update OOjs UI to v0.17.4 Release notes: https://git.wikimedia.org/blob/oojs%2Fui.git/v0.17.4/History.md Change-Id: I35019c565ec1d72fde0b69f217cab8d73ce441a4 --- M composer.json M composer.lock M composer/autoload_classmap.php M composer/installed.json M oojs/oojs-ui/History.md M oojs/oojs-ui/bin/testsuitegenerator.rb M oojs/oojs-ui/demos/pages/widgets.js M oojs/oojs-ui/demos/pages/widgets.php M oojs/oojs-ui/package.json A oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php 10 files changed, 322 insertions(+), 73 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vendor refs/changes/38/292038/1 diff --git a/composer.json b/composer.json index d7e2349..399c1b7 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "mediawiki/at-ease": "1.1.0", "monolog/monolog": "1.18.2", "nmred/kafka-php": "0.1.5", - "oojs/oojs-ui": "0.17.3", + "oojs/oojs-ui": "0.17.4", "oyejorge/less.php": "1.7.0.10", "pear/console_getopt": "1.4.1", "pear/mail": "1.3.0", diff --git a/composer.lock b/composer.lock index 5aab7d2..9002cb1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "014853eafd992dc582170aaa7e326f59", - "content-hash": "b57c820fef6a8b03501865f136b2d062", + "hash": "3d1ef062aaa88cabee593cc0ead19680", + "content-hash": "a379c30c5fa9a8232638f95886900c84", "packages": [ { "name": "composer/semver", @@ -430,16 +430,16 @@ }, { "name": "oojs/oojs-ui", - "version": "v0.17.3", + "version": "v0.17.4", "source": { "type": "git", "url": "https://github.com/wikimedia/oojs-ui.git", - "reference": "48ba46ffbb0300abd4418ac9581a9eb81fa72a00" + "reference": "c4f738414ee5a45d975f0a9a9ad7d562faf920cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/oojs-ui/zipball/48ba46ffbb0300abd4418ac9581a9eb81fa72a00", - "reference": "48ba46ffbb0300abd4418ac9581a9eb81fa72a00", + "url": "https://api.github.com/repos/wikimedia/oojs-ui/zipball/c4f738414ee5a45d975f0a9a9ad7d562faf920cc", + "reference": "c4f738414ee5a45d975f0a9a9ad7d562faf920cc", "shasum": "" }, "require": { @@ -505,7 +505,7 @@ ], "description": "Provides library of common widgets, layouts, and windows.", "homepage": "https://www.mediawiki.org/wiki/OOjs_UI", - "time": "2016-05-24 22:04:46" + "time": "2016-05-31 19:57:20" }, { "name": "oyejorge/less.php", diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index f4e8fec..dfe9f0d 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -534,6 +534,7 @@ 'OOUI\\ButtonInputWidget' => $vendorDir . '/oojs/oojs-ui/php/widgets/ButtonInputWidget.php', 'OOUI\\ButtonWidget' => $vendorDir . '/oojs/oojs-ui/php/widgets/ButtonWidget.php', 'OOUI\\CheckboxInputWidget' => $vendorDir . '/oojs/oojs-ui/php/widgets/CheckboxInputWidget.php', + 'OOUI\\CheckboxMultiselectInputWidget' => $vendorDir . '/oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php', 'OOUI\\ComboBoxInputWidget' => $vendorDir . '/oojs/oojs-ui/php/widgets/ComboBoxInputWidget.php', 'OOUI\\DropdownInputWidget' => $vendorDir . '/oojs/oojs-ui/php/widgets/DropdownInputWidget.php', 'OOUI\\Element' => $vendorDir . '/oojs/oojs-ui/php/Element.php', diff --git a/composer/installed.json b/composer/installed.json index 5ab5a72..131d6e3 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1745,18 +1745,73 @@ "homepage": "https://github.com/wikimedia/IPSet" }, { - "name": "oojs/oojs-ui", - "version": "v0.17.3", - "version_normalized": "0.17.3.0", + "name": "wikimedia/cdb", + "version": "1.4.1", + "version_normalized": "1.4.1.0", "source": { "type": "git", - "url": "https://github.com/wikimedia/oojs-ui.git", - "reference": "48ba46ffbb0300abd4418ac9581a9eb81fa72a00" + "url": "https://github.com/wikimedia/cdb.git", + "reference": "d49d96232f045311dc1f21bf0d7e40adf82a1f1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/oojs-ui/zipball/48ba46ffbb0300abd4418ac9581a9eb81fa72a00", - "reference": "48ba46ffbb0300abd4418ac9581a9eb81fa72a00", + "url": "https://api.github.com/repos/wikimedia/cdb/zipball/d49d96232f045311dc1f21bf0d7e40adf82a1f1d", + "reference": "d49d96232f045311dc1f21bf0d7e40adf82a1f1d", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "0.9", + "mediawiki/mediawiki-codesniffer": "0.5.0", + "phpunit/phpunit": "4.6.*" + }, + "time": "2016-05-29 07:39:26", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "Daniel Kinzler" + }, + { + "name": "Tim Starling", + "email": "tstarl...@wikimedia.org" + }, + { + "name": "Chad Horohoe", + "email": "c...@wikimedia.org" + }, + { + "name": "Ori Livneh", + "email": "o...@wikimedia.org" + } + ], + "description": "Constant Database (CDB) wrapper library for PHP. Provides pure-PHP fallback when dba_* functions are absent.", + "homepage": "https://www.mediawiki.org/wiki/CDB" + }, + { + "name": "oojs/oojs-ui", + "version": "v0.17.4", + "version_normalized": "0.17.4.0", + "source": { + "type": "git", + "url": "https://github.com/wikimedia/oojs-ui.git", + "reference": "c4f738414ee5a45d975f0a9a9ad7d562faf920cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wikimedia/oojs-ui/zipball/c4f738414ee5a45d975f0a9a9ad7d562faf920cc", + "reference": "c4f738414ee5a45d975f0a9a9ad7d562faf920cc", "shasum": "" }, "require": { @@ -1768,7 +1823,7 @@ "mediawiki/mediawiki-codesniffer": "0.6.0", "phpunit/phpunit": "4.8.21" }, - "time": "2016-05-24 22:04:46", + "time": "2016-05-31 19:57:20", "type": "library", "installation-source": "dist", "autoload": { @@ -1824,60 +1879,5 @@ ], "description": "Provides library of common widgets, layouts, and windows.", "homepage": "https://www.mediawiki.org/wiki/OOjs_UI" - }, - { - "name": "wikimedia/cdb", - "version": "1.4.1", - "version_normalized": "1.4.1.0", - "source": { - "type": "git", - "url": "https://github.com/wikimedia/cdb.git", - "reference": "d49d96232f045311dc1f21bf0d7e40adf82a1f1d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wikimedia/cdb/zipball/d49d96232f045311dc1f21bf0d7e40adf82a1f1d", - "reference": "d49d96232f045311dc1f21bf0d7e40adf82a1f1d", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "jakub-onderka/php-parallel-lint": "0.9", - "mediawiki/mediawiki-codesniffer": "0.5.0", - "phpunit/phpunit": "4.6.*" - }, - "time": "2016-05-29 07:39:26", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "Daniel Kinzler" - }, - { - "name": "Tim Starling", - "email": "tstarl...@wikimedia.org" - }, - { - "name": "Chad Horohoe", - "email": "c...@wikimedia.org" - }, - { - "name": "Ori Livneh", - "email": "o...@wikimedia.org" - } - ], - "description": "Constant Database (CDB) wrapper library for PHP. Provides pure-PHP fallback when dba_* functions are absent.", - "homepage": "https://www.mediawiki.org/wiki/CDB" } ] diff --git a/oojs/oojs-ui/History.md b/oojs/oojs-ui/History.md index 80dced4..2fa313e 100644 --- a/oojs/oojs-ui/History.md +++ b/oojs/oojs-ui/History.md @@ -1,5 +1,26 @@ # OOjs UI Release History +## v0.17.4 / 2016-05-31 +### Features +* DropdownWidget: Handle type-to-search when menu is not expanded (Bartosz Dziewoński) +* Implement MultiselectWidget, CheckboxMultiselectWidget and CheckboxMultiselectInputWidget (Bartosz Dziewoński) +* SelectWidget: Improve focus behaviour (Bartosz Dziewoński) + +### Styles +* icons: Use B/I/S/U icons for British and Candian English variants (Ed Sanders) +* MediaWiki theme: Provide an adjacent disabled ButtonGroup/SelectWidget button border (Volker E) +* MediaWiki theme: Make iconed and non-iconed buttons have the same height (Roan Kattouw) + +### Code +* ButtonElement: Remove unnecessary inheritance duplication of `display` (Volker E) +* GroupWidget: Mix in GroupElement, rather than inherit from it (Bartosz Dziewoński) +* LookupElement: Add missing `@mixins` documentation (Bartosz Dziewoński) +* SelectWidget: Implement `#getFirstSelectableItem` in terms of `#getRelativeSelectableItem` (Bartosz Dziewoński) +* SelectWidget: Optimize `#getRelativeSelectableItem` without filter (Bartosz Dziewoński) +* styles: Remove unnecessary CSS rules on disabled buttons (Volker E) +* styles: Simplify disabled `.oo-ui-tool-link` rules (Volker E) + + ## v0.17.3 / 2016-05-24 ### Deprecations * [DEPRECATING CHANGE] CapsuleMultiSelectWidget: Rename to CapsuleMultiselectWidget (Bartosz Dziewoński) diff --git a/oojs/oojs-ui/bin/testsuitegenerator.rb b/oojs/oojs-ui/bin/testsuitegenerator.rb index dffeb98..c925187 100644 --- a/oojs/oojs-ui/bin/testsuitegenerator.rb +++ b/oojs/oojs-ui/bin/testsuitegenerator.rb @@ -14,7 +14,8 @@ tests = [] classes = php.select{|c| class_names.include? c[:name] } - untestable_classes = %w[DropdownInputWidget ComboBoxInputWidget RadioSelectInputWidget] + untestable_classes = %w[DropdownInputWidget ComboBoxInputWidget + RadioSelectInputWidget CheckboxMultiselectInputWidget] testable_classes = classes .reject{|c| c[:abstract] } # can't test abstract classes .reject{|c| !c[:parent] || c[:trait] || c[:parent] == 'Theme' } # can't test abstract diff --git a/oojs/oojs-ui/demos/pages/widgets.js b/oojs/oojs-ui/demos/pages/widgets.js index 29a33d5..17c822d 100644 --- a/oojs/oojs-ui/demos/pages/widgets.js +++ b/oojs/oojs-ui/demos/pages/widgets.js @@ -727,6 +727,29 @@ } ), new OO.ui.FieldLayout( + new OO.ui.CheckboxMultiselectWidget( { + items: [ + new OO.ui.CheckboxMultioptionWidget( { + data: 'cat', + label: 'Cat' + } ), + new OO.ui.CheckboxMultioptionWidget( { + data: 'dog', + label: 'Dog' + } ), + new OO.ui.CheckboxMultioptionWidget( { + data: 'goldfish', + label: 'Goldfish', + disabled: true + } ) + ] + } ), + { + align: 'top', + label: 'CheckboxMultiselectWidget' + } + ), + new OO.ui.FieldLayout( new OO.ui.RadioSelectInputWidget( { value: 'dog', options: [ @@ -750,6 +773,29 @@ } ), new OO.ui.FieldLayout( + new OO.ui.CheckboxMultiselectInputWidget( { + value: [ 'dog', 'cat' ], + options: [ + { + data: 'cat', + label: 'Cat' + }, + { + data: 'dog', + label: 'Dog' + }, + { + data: 'goldfish', + label: 'Goldfish' + } + ] + } ), + { + align: 'top', + label: 'CheckboxMultiselectInputWidget' + } + ), + new OO.ui.FieldLayout( new OO.ui.NumberInputWidget(), { label: 'NumberInputWidget', diff --git a/oojs/oojs-ui/demos/pages/widgets.php b/oojs/oojs-ui/demos/pages/widgets.php index 903ff25..d34d30a 100644 --- a/oojs/oojs-ui/demos/pages/widgets.php +++ b/oojs/oojs-ui/demos/pages/widgets.php @@ -451,6 +451,29 @@ ] ), new OOUI\FieldLayout( + new OOUI\CheckboxMultiselectInputWidget( [ + 'value' => [ 'dog', 'cat' ], + 'options' => [ + [ + 'data' => 'cat', + 'label' => 'Cat' + ], + [ + 'data' => 'dog', + 'label' => 'Dog' + ], + [ + 'data' => 'goldfish', + 'label' => 'Goldfish' + ], + ] + ] ), + [ + 'align' => 'top', + 'label' => 'CheckboxMultiselectInputWidget', + ] + ), + new OOUI\FieldLayout( new OOUI\TextInputWidget( [ 'value' => 'Text input' ] ), [ 'label' => "TextInputWidget\xE2\x80\x8E", diff --git a/oojs/oojs-ui/package.json b/oojs/oojs-ui/package.json index 70fa829..4ad0d6c 100644 --- a/oojs/oojs-ui/package.json +++ b/oojs/oojs-ui/package.json @@ -1,6 +1,6 @@ { "name": "oojs-ui", - "version": "0.17.3", + "version": "0.17.4", "description": "User interface classes built on the OOjs framework.", "keywords": [ "oojs-plugin", diff --git a/oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php b/oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php new file mode 100644 index 0000000..a9b8da4 --- /dev/null +++ b/oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php @@ -0,0 +1,157 @@ +<?php + +namespace OOUI; + +/** + * Multiple checkbox input widget. Intended to be used within a OO.ui.FormLayout. + */ +class CheckboxMultiselectInputWidget extends InputWidget { + + /* Static Properties */ + + public static $supportsSimpleLabel = false; + + /* Properties */ + + /** + * @var string|null + */ + protected $name = null; + + /** + * Input value. + * + * @var string[] + */ + protected $value = []; + + /** + * Layouts for this input, as FieldLayouts. + * + * @var array + */ + protected $fields = []; + + /** + * @param array $config Configuration options + * @param array[] $config['options'] Array of menu options in the format + * `array( 'data' => …, 'label' => … )` + */ + public function __construct( array $config = [] ) { + // Parent constructor + parent::__construct( $config ); + + if ( isset( $config['name'] ) ) { + $this->name = $config['name']; + } + + // Initialization + $this->setOptions( isset( $config['options'] ) ? $config['options'] : [] ); + // Have to repeat this from parent, as we need options to be set up for this to make sense + $this->setValue( isset( $config['value'] ) ? $config['value'] : null ); + $this->addClasses( [ 'oo-ui-checkboxMultiselectInputWidget' ] ); + } + + protected function getInputElement( $config ) { + // Actually unused + return new Tag( 'div' ); + } + + /** + * Set the value of the input. + * + * @param string[] $value New value + * @return $this + */ + public function setValue( $value ) { + $this->value = $this->cleanUpValue( $value ); + // Deselect all options + foreach ( $this->fields as $field ) { + $field->getField()->setSelected( false ); + } + // Select the requested ones + foreach ( $this->value as $key ) { + $this->fields[ $key ]->getField()->setSelected( true ); + } + return $this; + } + + /** + * Clean up incoming value. + * + * @param string[] $value Original value + * @return string[] Cleaned up value + */ + protected function cleanUpValue( $value ) { + $cleanValue = []; + if ( !is_array( $value ) ) { + return $cleanValue; + } + foreach ( $value as $singleValue ) { + $singleValue = parent::cleanUpValue( $singleValue ); + // Remove options that we don't have here + if ( !isset( $this->fields[ $singleValue ] ) ) { + continue; + } + $cleanValue[] = $singleValue; + } + return $cleanValue; + } + + /** + * Set the options available for this input. + * + * @param array[] $options Array of menu options in the format + * `array( 'data' => …, 'label' => … )` + * @return $this + */ + public function setOptions( $options ) { + $this->fields = []; + + // Rebuild the checkboxes + $this->clearContent(); + $name = $this->name; + foreach ( $options as $opt ) { + $optValue = parent::cleanUpValue( $opt['data'] ); + $field = new FieldLayout( + new CheckboxInputWidget( [ + 'name' => $name, + 'value' => $optValue, + 'disabled' => $this->isDisabled(), + ] ), + [ + 'label' => isset( $opt['label'] ) ? $opt['label'] : $optValue, + 'align' => 'inline', + ] + ); + + $this->fields[ $optValue ] = $field; + $this->appendContent( $field ); + } + + // Re-set the value, checking the checkboxes as needed. + // This will also get rid of any stale options that we just removed. + $this->setValue( $this->getValue() ); + + return $this; + } + + public function setDisabled( $state ) { + parent::setDisabled( $state ); + foreach ( $this->fields as $field ) { + $field->getField()->setDisabled( $this->isDisabled() ); + } + return $this; + } + + public function getConfig( &$config ) { + $o = []; + foreach ( $this->fields as $field ) { + $label = $field->getLabel(); + $data = $field->getField()->getValue(); + $o[] = [ 'data' => $data, 'label' => $label ]; + } + $config['options'] = $o; + return parent::getConfig( $config ); + } +} -- To view, visit https://gerrit.wikimedia.org/r/292038 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I35019c565ec1d72fde0b69f217cab8d73ce441a4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/vendor Gerrit-Branch: master Gerrit-Owner: Jforrester <jforres...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits