jenkins-bot has submitted this change and it was merged.

Change subject: Add global username autocompletion
......................................................................


Add global username autocompletion

Adds ext.centralauth.globaluserautocomplete

Change-Id: Ieef6e4bcc3ef10f229d176b1597c5b82090b5562
---
M CentralAuth.php
M includes/specials/SpecialCentralAuth.php
M includes/specials/SpecialGlobalGroupMembership.php
M includes/specials/SpecialGlobalRenameUser.php
A modules/ext.centralauth.globaluserautocomplete.js
5 files changed, 60 insertions(+), 3 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CentralAuth.php b/CentralAuth.php
index 8c6da23..93eb314 100644
--- a/CentralAuth.php
+++ b/CentralAuth.php
@@ -528,6 +528,14 @@
        'styles' => 'ext.centralauth.noflash.css',
 ) + $commonModuleInfo;
 
+$wgResourceModules['ext.centralauth.globaluserautocomplete'] = array(
+       'scripts' => 'ext.centralauth.globaluserautocomplete.js',
+       'dependencies' => array(
+               'jquery.suggestions',
+               'mediawiki.api'
+       )
+) + $commonModuleInfo;
+
 $wgResourceModules['ext.centralauth.globalusers'] = array(
        'styles' => 'ext.centralauth.globalusers.css',
 ) + $commonModuleInfo;
diff --git a/includes/specials/SpecialCentralAuth.php 
b/includes/specials/SpecialCentralAuth.php
index 7e154b5..9d2dd23 100644
--- a/includes/specials/SpecialCentralAuth.php
+++ b/includes/specials/SpecialCentralAuth.php
@@ -35,6 +35,7 @@
 
                $this->getOutput()->setPageTitle( $this->msg( $this->mCanEdit ? 
'centralauth' : 'centralauth-ro' ) );
                $this->getOutput()->addModules( 'ext.centralauth' );
+               $this->getOutput()->addModules( 
'ext.centralauth.globaluserautocomplete' );
                $this->getOutput()->addModuleStyles( 'ext.centralauth.noflash' 
);
                $this->getOutput()->addJsConfigVars( 
'wgMergeMethodDescriptions', $this->getMergeMethodDescriptions() );
 
@@ -212,7 +213,8 @@
                        Html::hidden( 'title', 
$this->getPageTitle()->getPrefixedText() ) .
                                Xml::openElement( 'p' ) .
                                Xml::inputLabel( $this->msg( 
'centralauth-admin-username' )->text(),
-                                       'target', 'target', 25, 
$this->mUserName ) .
+                                       'target', 'target', 25, 
$this->mUserName,
+                                       array( 'class' => 
'mw-autocomplete-global-user' ) ) .
                                Xml::closeElement( 'p' ) .
                                Xml::openElement( 'p' ) .
                                Xml::submitButton( $lookup,
diff --git a/includes/specials/SpecialGlobalGroupMembership.php 
b/includes/specials/SpecialGlobalGroupMembership.php
index 4e4d7ba..88bd1f8 100644
--- a/includes/specials/SpecialGlobalGroupMembership.php
+++ b/includes/specials/SpecialGlobalGroupMembership.php
@@ -30,13 +30,15 @@
        function switchForm() {
                global $wgScript;
 
+               $this->getOutput()->addModules( 
'ext.centralauth.globaluserautocomplete' );
                $this->getOutput()->addModuleStyles( 'mediawiki.special' );
                $this->getOutput()->addHTML(
                        Xml::openElement( 'form', array( 'method' => 'get', 
'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1' ) ) .
                        Html::hidden( 'title',  $this->getPageTitle() ) .
                        Xml::openElement( 'fieldset' ) .
                        Xml::element( 'legend', array(), $this->msg( 
'userrights-lookup-user' )->text() ) .
-                       Xml::inputLabel( $this->msg( 'userrights-user-editname' 
)->text(), 'user', 'username', 30, $this->mTarget ) . ' <br />' .
+                       Xml::inputLabel( $this->msg( 'userrights-user-editname' 
)->text(), 'user', 'username', 30, $this->mTarget,
+                               array( 'class' => 'mw-autocomplete-global-user' 
) ) . ' <br />' .
                        Xml::submitButton( $this->msg( 'editusergroup' 
)->text() ) .
                        Xml::closeElement( 'fieldset' ) .
                        Xml::closeElement( 'form' ) . "\n"
diff --git a/includes/specials/SpecialGlobalRenameUser.php 
b/includes/specials/SpecialGlobalRenameUser.php
index da0aeaf..7875fcc 100644
--- a/includes/specials/SpecialGlobalRenameUser.php
+++ b/includes/specials/SpecialGlobalRenameUser.php
@@ -27,6 +27,7 @@
        public function execute( $par ) {
                parent::execute( $par );
                $this->getOutput()->addModules( 
'ext.centralauth.globalrenameuser' );
+               $this->getOutput()->addModules( 
'ext.centralauth.globaluserautocomplete' );
        }
 
        /**
@@ -39,7 +40,8 @@
                                'name' => 'oldname',
                                'label-message' => 
'centralauth-rename-form-oldname',
                                'type' => 'text',
-                               'required' => true
+                               'required' => true,
+                               'cssclass' => 'mw-autocomplete-global-user'
                        ),
                        'newname' => array(
                                'id' => 'mw-globalrenameuser-newname',
diff --git a/modules/ext.centralauth.globaluserautocomplete.js 
b/modules/ext.centralauth.globaluserautocomplete.js
new file mode 100644
index 0000000..4f4a041
--- /dev/null
+++ b/modules/ext.centralauth.globaluserautocomplete.js
@@ -0,0 +1,43 @@
+/*!
+ * Add autocomplete suggestions for names of global accounts.
+ * Lovingly stolen from core mediawiki.userSuggest
+ */
+( function ( mw, $ ) {
+       var api, config;
+
+       config = {
+               fetch: function ( userInput ) {
+                       var $textbox = this,
+                               node = this[0];
+
+                       api = api || new mw.Api();
+
+                       $.data( node, 'request', api.get( {
+                               action: 'query',
+                               list: 'globalallusers',
+                               // Prefix of list=globalallusers is case 
sensitive. Normalise first
+                               // character to uppercase so that "fo" may 
yield "Foo".
+                               aguprefix: userInput.charAt( 0 ).toUpperCase() 
+ userInput.slice( 1 )
+                       } ).done( function ( data ) {
+                               var users = $.map( data.query.globalallusers, 
function ( userObj ) {
+                                       return userObj.name;
+                               } );
+                               // Set the results as the autocomplete options
+                               $textbox.suggestions( 'suggestions', users );
+                       } ) );
+               },
+               cancel: function () {
+                       var node = this[0],
+                               request = $.data( node, 'request' );
+
+                       if ( request ) {
+                               request.abort();
+                               $.removeData( node, 'request' );
+                       }
+               }
+       };
+
+       $( function () {
+               $( '.mw-autocomplete-global-user' ).suggestions( config );
+       } );
+}( mediaWiki, jQuery ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ieef6e4bcc3ef10f229d176b1597c5b82090b5562
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MZMcBride <[email protected]>
Gerrit-Reviewer: PiRSquared17 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to