Amire80 has uploaded a new change for review.

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


Change subject: Display the absence of any requests as a header
......................................................................

Display the absence of any requests as a header

Move all the request counter updating to front end.
Update tests and remove irrelevant steps.

Change-Id: I47f98f9a27ef28d822d50ef95a28310438a45943
---
M resources/js/ext.translate.special.translatesandbox.js
M specials/SpecialTranslateSandbox.php
M tests/browser/features/manage_translator_sandbox.feature
M tests/browser/features/step_definitions/manage_translator_sandbox_steps.rb
4 files changed, 21 insertions(+), 14 deletions(-)


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

diff --git a/resources/js/ext.translate.special.translatesandbox.js 
b/resources/js/ext.translate.special.translatesandbox.js
index c0facae..fcf3c07 100644
--- a/resources/js/ext.translate.special.translatesandbox.js
+++ b/resources/js/ext.translate.special.translatesandbox.js
@@ -313,8 +313,22 @@
         * Updates the number of requests.
         */
        function updateRequestCount() {
-               $( '.request-count' )
-                       .text( mw.msg( 'tsb-request-count', $( 
'.request:not(.hide)' ).length ) );
+               var $requests = $( '.requests-list .request' ),
+                       visibleRequestsCount = $requests.filter( ':not(.hide)' 
).length;
+
+               $( '.request-count' ).text(
+                       mw.msg( 'tsb-request-count', mw.language.convertNumber( 
visibleRequestsCount ) )
+               );
+
+               if ( $requests.length === 0 ) {
+                       $( '.details.pane' )
+                               .empty()
+                               .append(
+                                       $( '<div>' )
+                                               .addClass( 'tsb-header row' )
+                                               .text( mw.msg( 
'tsb-no-requests-from-new-users' ) )
+                               );
+               }
        }
 
        /**
@@ -485,8 +499,7 @@
        $( document ).ready( function () {
                var $requestCheckboxes = $( '.request-selector' ),
                        $selectAll = $( '.request-selector-all' ),
-                       $requestRows = $( '.requests .request' ),
-                       $detailsPane = $( '.details.pane' );
+                       $requestRows = $( '.requests .request' );
 
                // Delay so we get the correct height on page load
                window.setTimeout( setPanesHeight, 0 );
@@ -505,9 +518,9 @@
 
                if ( $requestRows.length ) {
                        $requestRows.first().click();
-               } else {
-                       $detailsPane.text( mw.msg( 
'tsb-no-requests-from-new-users' ) );
                }
+
+               updateRequestCount();
        } );
 
        // ======================================
diff --git a/specials/SpecialTranslateSandbox.php 
b/specials/SpecialTranslateSandbox.php
index 49a5076..1991630 100644
--- a/specials/SpecialTranslateSandbox.php
+++ b/specials/SpecialTranslateSandbox.php
@@ -221,9 +221,7 @@
                        {$this->msg( "tsb-all-languages-button-label" 
)->escaped()}
                </button>
        </div>
-       <div class="five columns request-count">
-               {$this->msg( "tsb-request-count" )->numParams( $count 
)->parse()}
-       </div>
+       <div class="five columns request-count"></div>
        <div class="three columns center">
                <input class="request-selector-all" name="request" 
type="checkbox" />
        </div>
diff --git a/tests/browser/features/manage_translator_sandbox.feature 
b/tests/browser/features/manage_translator_sandbox.feature
index 89f7598..1a35ef2 100644
--- a/tests/browser/features/manage_translator_sandbox.feature
+++ b/tests/browser/features/manage_translator_sandbox.feature
@@ -18,7 +18,7 @@
     Then no users are displayed in the first column
       And I should see "0 requests" at the top of the first column
       And I should see "0 users selected" at the bottom of the first column
-      And I should see "No requests from new users" in the second column
+      And I should see "No requests from new users" in the header of the 
second column
       And I should not see the older requests link at the bottom of the first 
column
 
   Scenario: Existing users can be searched on the list
diff --git 
a/tests/browser/features/step_definitions/manage_translator_sandbox_steps.rb 
b/tests/browser/features/step_definitions/manage_translator_sandbox_steps.rb
index c01e402..3caade9 100644
--- a/tests/browser/features/step_definitions/manage_translator_sandbox_steps.rb
+++ b/tests/browser/features/step_definitions/manage_translator_sandbox_steps.rb
@@ -136,10 +136,6 @@
        on(ManageTranslatorSandboxPage).request_count.should == text
 end
 
-Then(/^I should see "(.*)" in the second column$/) do |text|
-       on(ManageTranslatorSandboxPage).details.should == text
-end
-
 Then(/^I should see the button that clears language selection$/) do
        on(ManageTranslatorSandboxPage).clear_language_selector_element.should 
be_visible
 end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I47f98f9a27ef28d822d50ef95a28310438a45943
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