TitlesMultiselectWidget: pass through additional configs
authorThalia <thalia.e.chan@googlemail.com>
Thu, 8 Nov 2018 13:52:55 +0000 (13:52 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Tue, 13 Nov 2018 19:28:54 +0000 (19:28 +0000)
Pass through 'limit' and 'showMissing' configs.

Also set 'showMissing' to false for partial blocks.

Bug: T208626
Bug: T208627
Change-Id: Ifa75e2d390bf349226ad69d68adcdcaf742ab560

includes/htmlform/fields/HTMLTitlesMultiselectField.php
includes/specials/SpecialBlock.php
includes/widget/TitlesMultiselectWidget.php

index c93c940..9385c81 100644 (file)
@@ -95,6 +95,14 @@ class HTMLTitlesMultiselectField extends HTMLTitleTextField {
                        $params['placeholder'] = $this->msg( 'mw-widgets-titlesmultiselect-placeholder' )->plain();
                }
 
+               if ( isset( $this->mParams['max'] ) ) {
+                       $params['limit'] = $this->mParams['max'];
+               }
+
+               if ( isset( $this->mParams['showMissing'] ) ) {
+                       $params['showMissing'] = $this->mParams['showMissing'];
+               }
+
                if ( !is_null( $value ) ) {
                        // $value is a string, but the widget expects an array
                        $params['default'] = $value === '' ? [] : explode( "\n", $value );
index 6b9b9d4..918ce4a 100644 (file)
@@ -171,6 +171,7 @@ class SpecialBlock extends FormSpecialPage {
                                'exists' => true,
                                'max' => 10,
                                'cssclass' => 'mw-block-page-restrictions',
+                               'showMissing' => false,
                        ];
                }
 
index 95304b0..61aa405 100644 (file)
@@ -15,12 +15,16 @@ class TitlesMultiselectWidget extends \OOUI\Widget {
        protected $titlesArray = [];
        protected $inputName = null;
        protected $inputPlaceholder = null;
+       protected $limit = null;
+       protected $showMissing = null;
 
        /**
         * @param array $config Configuration options
         *   - array $config['titles'] Array of titles to use as preset data
         *   - array $config['placeholder'] Placeholder message for input
         *   - array $config['name'] Name attribute (used in forms)
+        *   - number $config['limit'] Maximum number of selected titles
+        *   - bool $config['showMissing'] Show missing pages
         */
        public function __construct( array $config = [] ) {
                parent::__construct( $config );
@@ -35,6 +39,12 @@ class TitlesMultiselectWidget extends \OOUI\Widget {
                if ( isset( $config['placeholder'] ) ) {
                        $this->inputPlaceholder = $config['placeholder'];
                }
+               if ( isset( $config['limit'] ) ) {
+                       $this->limit = $config['limit'];
+               }
+               if ( isset( $config['showMissing'] ) ) {
+                       $this->showMissing = $config['showMissing'];
+               }
 
                $textarea = new MultilineTextInputWidget( [
                        'name' => $this->inputName,
@@ -59,6 +69,12 @@ class TitlesMultiselectWidget extends \OOUI\Widget {
                if ( $this->inputPlaceholder !== null ) {
                        $config['placeholder'] = $this->inputPlaceholder;
                }
+               if ( $this->limit !== null ) {
+                       $config['limit'] = $this->limit;
+               }
+               if ( $this->showMissing !== null ) {
+                       $config['showMissing'] = $this->showMissing;
+               }
 
                $config['$overlay'] = true;
                return parent::getConfig( $config );