Rillke has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/76503


Change subject: Make Special:AggregateGroups using jquery.chosen
......................................................................

Make Special:AggregateGroups using jquery.chosen

With the time, the number of translatable pages will grow. There are
already about 350 pages at Meta marked for translation.
This leads to a messy UI with the effect that you spend a lot of time
searching but not finding.
Using jQuery.chosen will ease finding the page you'd like to add to an
aggregated group.

jQuery.async is used to avoid freezing the browser and throwing
warnings about unresponsive scripts at the user.

Only a remote-data-service would solve this issue properly.

Bug: 52216
Change-Id: I0dc4b71814eaad82246bfb69d793bc2a48551895
---
M Resources.php
M resources/js/ext.translate.special.aggregategroups.js
M specials/SpecialAggregateGroups.php
3 files changed, 28 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/03/76503/1

diff --git a/Resources.php b/Resources.php
index e17bd30..a67d1b1 100644
--- a/Resources.php
+++ b/Resources.php
@@ -254,7 +254,11 @@
        'scripts' => 'resources/js/ext.translate.special.aggregategroups.js',
        'styles' => 'resources/css/ext.translate.special.aggregategroups.css',
        'position' => 'top',
-       'dependencies' => array( 'mediawiki.util' ),
+       'dependencies' => array(
+               'mediawiki.util',
+               'jquery.async',
+               'jquery.chosen'
+       ),
        'messages' => array(
                'tpt-aggregategroup-remove-confirm',
        ),
diff --git a/resources/js/ext.translate.special.aggregategroups.js 
b/resources/js/ext.translate.special.aggregategroups.js
index a77d7ed..3dc12cf 100644
--- a/resources/js/ext.translate.special.aggregategroups.js
+++ b/resources/js/ext.translate.special.aggregategroups.js
@@ -110,6 +110,17 @@
                        event.preventDefault();
                } );
 
+               // FIXME: These selects should be populated with AJAX. 
+               // At least there is no point in outputting them in HTML
+               // for each group. One would be enough that could be cloned.
+               $( '.mw-tpa-groupselect' ).eachAsync( {
+                       loop: function () {
+                               $(this).chosen( {
+                                       search_contains: true
+                               } );
+                       }
+               } );
+
                $( '#tpt-aggregategroups-save' ).on( 'click', function () {
                        var $select, successFunction, params,
                                aggGroupNameInputName = $( 
'input.tp-aggregategroup-add-name' ),
@@ -141,7 +152,10 @@
                                        $div.data( 'id', aggregateGroupId );
 
                                        if ( $select.length > 0 ) {
-                                               $groupSelector = $( '<select>' 
).attr( 'id', 'mw-tpa-groupselect-' + aggregateGroupId );
+                                               $groupSelector = $( '<select>' 
).attr({
+                                                       'id': 
'mw-tpa-groupselect-' + aggregateGroupId,
+                                                       'class': 
'mw-tpa-groupselect'
+                                               });
 
                                                $.each( 
data.aggregategroups.groups, function ( key, value ) {
                                                        $groupSelector.append( 
$( '<option>', { value: key } ).text( value ) );
@@ -149,10 +163,16 @@
 
                                                $addButton = $( $( 
'input.tp-aggregate-add-button' )[0] ).clone();
                                                $addButton.attr( 'id', 
aggregateGroupId );
-                                               $div.append( $groupSelector 
).append( $addButton );
+                                               $div.append( $groupSelector, 
$addButton );
                                                $addButton.click( associate );
                                                $removeSpan.click( removeGroup 
);
                                                $( 'div.tpt-add-new-group' 
).addClass( 'hidden' );
+
+                                               setTimeout( function () {
+                                                       $groupSelector.chosen( {
+                                                               
search_contains: true
+                                                       } );
+                                               }, 1 );
                                        } else {
                                                // First group in the wiki. 
Cannot clone the group selector, just reload this time.
                                                location.reload();
diff --git a/specials/SpecialAggregateGroups.php 
b/specials/SpecialAggregateGroups.php
index 5bd8251..1eac6e6 100644
--- a/specials/SpecialAggregateGroups.php
+++ b/specials/SpecialAggregateGroups.php
@@ -167,6 +167,7 @@
        protected function getGroupSelector( $availableGroups, $parent ) {
                $id = $this->htmlIdForGroup( $parent, 'mw-tpa-groupselect-' );
                $select = new XmlSelect( 'group', $id );
+               $select->setAttribute( 'class', 'mw-tpa-groupselect' );
 
                // Not calling $parent->getGroups() because it has done 
filtering already
                $subgroups = TranslateMetadata::getSubgroups( $parent->getId() 
);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0dc4b71814eaad82246bfb69d793bc2a48551895
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Rillke <[email protected]>

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

Reply via email to