Florianschmidtwelzow has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/354673 )

Change subject: Change DropdownWidgets to ComboBoxInputWidgets
......................................................................

Change DropdownWidgets to ComboBoxInputWidgets

This allows the user to type the value of the combo box into the input
text field and select matching items. A validation function will validate
the input value against the possible values and will return false if the
value is not allowed.

Bug: T165851
Change-Id: I695d31e60a225b6a5c9e8cbd6ba8ab64376f70ad
---
M resources/src/mediawiki.special/mediawiki.special.apisandbox.js
1 file changed, 20 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/73/354673/1

diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js 
b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
index f53850a..367fffc 100644
--- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
+++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
@@ -480,10 +480,10 @@
                                                throw new Error( 'Unknown 
parameter type ' + pi.type );
                                        }
 
-                                       items = $.map( pi.type, function ( v ) {
-                                               return new 
OO.ui.MenuOptionWidget( { data: String( v ), label: String( v ) } );
-                                       } );
                                        if ( Util.apiBool( pi.multi ) ) {
+                                               items = $.map( pi.type, 
function ( v ) {
+                                                       return new 
OO.ui.MenuOptionWidget( { data: String( v ), label: String( v ) } );
+                                               } );
                                                if ( pi.allspecifier !== 
undefined ) {
                                                        items.unshift( new 
OO.ui.MenuOptionWidget( {
                                                                data: 
pi.allspecifier,
@@ -502,9 +502,23 @@
                                                        widget.on( 'change', 
ApiSandbox.updateUI );
                                                }
                                        } else {
-                                               widget = new 
OO.ui.DropdownWidget( {
-                                                       menu: { items: items },
-                                                       $overlay: $( 
'#mw-apisandbox-ui' )
+                                               items = $.map( pi.type, 
function ( v ) {
+                                                       return { data: String( 
v ), label: String( v ) };
+                                               } );
+                                               widget = new 
OO.ui.ComboBoxInputWidget( {
+                                                       options: items,
+                                                       menu: {
+                                                               
filterFromInput: true
+                                                       },
+                                                       $overlay: $( 
'#mw-apisandbox-ui' ),
+                                                       validate: function ( 
value ) {
+                                                               for (var i in 
pi.type) {
+                                                                       if 
(pi.type[i] === value) {
+                                                                               
return true;
+                                                                       }
+                                                               }
+                                                               return false;
+                                                       }
                                                } );
                                                widget.paramInfo = pi;
                                                $.extend( widget, 
WidgetMethods.dropdownWidget );

-- 
To view, visit https://gerrit.wikimedia.org/r/354673
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I695d31e60a225b6a5c9e8cbd6ba8ab64376f70ad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to