Allow disabling exact input query in results in mw.widget.TitleWidget
authorpetarpetkovic <ppetkovic@wikimedia.org>
Fri, 24 Nov 2017 14:14:15 +0000 (15:14 +0100)
committerPetar.petkovic <ppetkovic@wikimedia.org>
Wed, 29 Nov 2017 19:09:13 +0000 (19:09 +0000)
* Add configuration option to mw.widget.TitleWidget, to make
addition of exact input query to the results optional.

Change-Id: Ic7a3aaf38a3827917e4d349cc6b828f37cc64b67

resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js

index 83a2612..5670ce4 100644 (file)
@@ -23,6 +23,7 @@
         * @cfg {boolean} [showImages] Show page images
         * @cfg {boolean} [showDescriptions] Show page descriptions
         * @cfg {boolean} [showMissing=true] Show missing pages
+        * @cfg {boolean} [addQueryInput=true] Add exact user's input query to results
         * @cfg {boolean} [excludeCurrentPage] Exclude the current page from suggestions
         * @cfg {boolean} [validateTitle=true] Whether the input must be a valid title (if set to true,
         *  the widget will marks itself red for invalid inputs, including an empty query).
@@ -46,6 +47,7 @@
                this.showImages = !!config.showImages;
                this.showDescriptions = !!config.showDescriptions;
                this.showMissing = config.showMissing !== false;
+               this.addQueryInput = config.addQueryInput !== false;
                this.excludeCurrentPage = !!config.excludeCurrentPage;
                this.validateTitle = config.validateTitle !== undefined ? config.validateTitle : true;
                this.cache = config.cache;
                }
 
                // Offer the exact text as a suggestion if the page exists
-               if ( pageExists && !pageExistsExact ) {
+               if ( this.addQueryInput && pageExists && !pageExistsExact ) {
                        titles.unshift( this.getQueryValue() );
                }