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

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, 32 insertions(+), 4 deletions(-)

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



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..c05e2e0 100644
--- a/resources/js/ext.translate.special.aggregategroups.js
+++ b/resources/js/ext.translate.special.aggregategroups.js
@@ -24,6 +24,7 @@
                                        .text( $target.siblings( 'a' ).text() )
                                        .appendTo( $select );
                                $target.parent( 'li' ).remove();
+                               $select.trigger( 'liszt:updated' );
                        }
                }
 
@@ -38,7 +39,8 @@
                var successFunction, params,
                        $target = $( event.target ),
                        parentId = $target.parents( '.mw-tpa-group' ).data( 
'id' ),
-                       $selected = $( '#mw-tpa-groupselect-' + parentId + ' 
option:selected' ),
+                       $select = $( '#mw-tpa-groupselect-' + parentId ),
+                       $selected = $select.find( 'option:selected' ),
                        subgroupId = $selected.val(),
                        subgroupName = $selected.text();
 
@@ -67,6 +69,7 @@
 
                                // remove this group from the select.
                                $selected.remove();
+                               $select.trigger( 'liszt:updated' );
                                $span.click( dissociate );
                        }
                };
@@ -110,6 +113,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 +155,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 +166,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: merged
Gerrit-Change-Id: I0dc4b71814eaad82246bfb69d793bc2a48551895
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Rillke <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Rillke <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to