Amire80 has uploaded a new change for review.

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


Change subject: Show only older requests with the same number of translations
......................................................................

Show only older requests with the same number of translations

Change-Id: I1b90ee9cb51a16afd16f4aad41b7efe6dcbd9a32
---
M resources/js/ext.translate.special.translatesandbox.js
M tests/browser/features/manage_translator_sandbox.feature
2 files changed, 35 insertions(+), 24 deletions(-)


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

diff --git a/resources/js/ext.translate.special.translatesandbox.js 
b/resources/js/ext.translate.special.translatesandbox.js
index bc95f7e..0e22080 100644
--- a/resources/js/ext.translate.special.translatesandbox.js
+++ b/resources/js/ext.translate.special.translatesandbox.js
@@ -297,12 +297,31 @@
                }
        }
 
-       function indicateOlderRequests() {
+       /**
+        * Returns older requests with the same number of translations.
+        * @return {jQuery} Older requests
+        */
+       function getOlderRequests() {
                var $lastSelectedRequest = $( '.row.request.selected' ).last(),
-                       $olderRequests = $lastSelectedRequest.nextAll( 
':not(.hide)' ),
-                       oldRequestsCount = $olderRequests.length,
-                       oldRequestsCountString = mw.language.convertNumber( 
oldRequestsCount ),
+                       currentTranslationCount = $lastSelectedRequest.data( 
'data' ).translations;
+
+               return $lastSelectedRequest.nextAll( ':not(.hide)' ).filter( 
function ( index ) {
+                       return ( $( this ).data( 'data' ).translations === 
currentTranslationCount );
+               } );
+       }
+
+       /**
+        * Updates the number of older requests with the same number
+        * of translations at the link in the bottom of the requests row
+        * or hides that link if there are no such requests.
+        */
+       function indicateOlderRequests() {
+               var oldRequestsCount, oldRequestsCountString,
+                       $olderRequests = getOlderRequests(),
                        $olderRequestsIndicator = $( 
'.older-requests-indicator' );
+
+               oldRequestsCount = $olderRequests.length;
+               oldRequestsCountString = mw.language.convertNumber( 
oldRequestsCount );
 
                if ( oldRequestsCount ) {
                        $olderRequestsIndicator
@@ -467,17 +486,13 @@
                } );
 
                $( '.older-requests-indicator' ).on( 'click', function ( e ) {
-                       var $lastSelectedRequest = $requestRows.filter( 
'.selected' ).last(),
-                               $olderRequests = $lastSelectedRequest.nextAll( 
':not(.hide)' );
+                       e.preventDefault();
 
-                       $olderRequests.each( function( index, request ) {
+                       getOlderRequests().each( function( index, request ) {
                                $( request ).find( '.request-selector' )
                                        .prop( 'checked', true ) // Otherwise 
the state doesn't actually change
                                        .change();
-
                        } );
-
-                       e.preventDefault();
                } );
 
                if ( $requestRows.length ) {
diff --git a/tests/browser/features/manage_translator_sandbox.feature 
b/tests/browser/features/manage_translator_sandbox.feature
index 442376e..c5a655e 100644
--- a/tests/browser/features/manage_translator_sandbox.feature
+++ b/tests/browser/features/manage_translator_sandbox.feature
@@ -47,19 +47,15 @@
 
   Scenario: Selecting older requests
     Given I am on the Translator sandbox management page with users in the 
sandbox
-    When I click on "Pupu0" in the first column
-      And I click on "Orava1" in the first column
-      And I click on the link that says "3 older requests" at the bottom of 
the first column
-    Then I should see the checkbox next to the request from "Orava1" checked
-      And I should see the checkbox next to the request from "Orava1" enabled
-      And I should see the checkbox next to the request from "Orava0" enabled
-      And I should see the checkbox next to the request from "Orava0" checked
-      And I should see the checkbox next to the request from "Pupu0" checked
-      And I should see the checkbox next to the request from "Pupu0" enabled
-      And I should see the checkbox next to the request from "Pupu1" checked
-      And I should see the checkbox next to the request from "Pupu1" enabled
-      And I should see "4 users selected" at the bottom of the first column
-      And I should see "4 users selected" in the header of the second column
+    When I click on "Orava3" in the first column
+      And I click on the link that says "1 older requests" at the bottom of 
the first column
+    Then I should see the checkbox next to the request from "Pupu3" checked
+      And I should see the checkbox next to the request from "Pupu3" enabled
+      And I should see the checkbox next to the request from "Orava3" checked
+      And I should see the checkbox next to the request from "Orava3" enabled
+      And I should see the checkbox next to the request from "Pupu2" unchecked
+      And I should see "2 users selected" at the bottom of the first column
+      And I should see "2 users selected" in the header of the second column
 
   Scenario: Selecting all users
     Given I am on the Translator sandbox management page with users in the 
sandbox
@@ -122,7 +118,7 @@
       And I should see the "Accept" button displayed in the second column
       And I should see the "Reject" button displayed in the second column
       And I should see "1 user selected" at the bottom of the first column
-      And I should see "10 older requests" in the older requests link at the 
bottom of the first column
+      And I should not see the older requests link at the bottom of the first 
column
 
   Scenario: Clicking on a name of a user who didn't make any translations 
shows the user information and the action buttons and doesn't show translations
     Given I am on the Translator sandbox management page with users in the 
sandbox

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

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

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

Reply via email to