Santhosh has submitted this change and it was merged.

Change subject: "Hide your translations" button
......................................................................


"Hide your translations" button

Change-Id: I170f019b7eb5f19229b66a275732d320617c2c5e
---
M Translate.i18n.php
M Translate.php
M resources/css/ext.translate.messagetable.css
M resources/js/ext.translate.messagetable.js
M resources/js/ext.translate.special.translate.js
M utils/TuxMessageTable.php
6 files changed, 73 insertions(+), 17 deletions(-)

Approvals:
  Santhosh: Verified; Looks good to me, approved



diff --git a/Translate.i18n.php b/Translate.i18n.php
index fee6950..dd8496e 100644
--- a/Translate.i18n.php
+++ b/Translate.i18n.php
@@ -11,6 +11,8 @@
 /** English
  * @author Nike
  * @author Siebrand
+ * @author Amire80
+ * @author Santhosh.thottingal
  */
 $messages['en'] = array(
        'translate' => 'Translate',
@@ -465,6 +467,8 @@
        'tux-editor-clear-translated' => 'Hide translated',
        'tux-editor-proofreading-mode' => 'Proofread',
        'tux-editor-translate-mode' => 'List',
+       'tux-editor-proofreading-hide-own-translations' => 'Hide my 
translations',
+       'tux-editor-proofreading-show-own-translations' => 'Show my 
translations',
        'tux-editor-outdated-warning' => 'This translation may need to be 
updated.',
        'tux-editor-outdated-warning-diff-link' => 'Show differences',
        'tux-editor-doc-editor-placeholder' => 'Message documentation',
@@ -954,6 +958,10 @@
        'tux-editor-translate-mode' => 'Label for the button that appears at 
the footer of the translation editor.
 Pressing the button goes to the translation mode.
 {{Identical|List}}',
+       'tux-editor-proofreading-hide-own-translations' => 'A label for a 
button that appears at the bottom of the translation editor in proofreading 
mode.
+Pressing the button hides the user\'s own translations from the list.',
+       'tux-editor-proofreading-show-own-translations' => 'A label for a 
button that appears at the bottom of the translation editor in proofreading 
mode.
+Pressing the button shows the user\'s own translations in the list.',
        'tux-editor-doc-editor-placeholder' => 'A placeholder that appears in 
the message documentation editor.
 {{Identical|Message documentation}}',
        'tux-editor-doc-editor-save' => 'A button that saves the documentation 
string',
diff --git a/Translate.php b/Translate.php
index c6cd203..88545e2 100644
--- a/Translate.php
+++ b/Translate.php
@@ -473,6 +473,8 @@
                'translate-workflow-state-',
                'tpt-discouraged-language-force',
                'tpt-discouraged-language',
+               'tux-editor-proofreading-hide-own-translations',
+               'tux-editor-proofreading-show-own-translations',
        ),
 ) + $resourcePaths;
 
diff --git a/resources/css/ext.translate.messagetable.css 
b/resources/css/ext.translate.messagetable.css
index f1b073d..ffe3732 100644
--- a/resources/css/ext.translate.messagetable.css
+++ b/resources/css/ext.translate.messagetable.css
@@ -203,7 +203,6 @@
 
 .tux-action-bar .toggle.button {
        height: 35px;
-       width: 50%;
        font-size: 15px;
        vertical-align: middle;
        border-radius: 0;
@@ -218,6 +217,10 @@
        border-radius: 0 3px 3px 0;
 }
 
+.tux-action-bar .tux-view-switcher .toggle.button {
+       width: 50%;
+}
+
 .tux-action-bar .translate-mode-button:before {
        content: "";
        height: 15px;
diff --git a/resources/js/ext.translate.messagetable.js 
b/resources/js/ext.translate.messagetable.js
index 6547815..36e24fd 100644
--- a/resources/js/ext.translate.messagetable.js
+++ b/resources/js/ext.translate.messagetable.js
@@ -369,7 +369,10 @@
                 */
                switchMode: function ( mode ) {
                        var messageTable = this,
-                               filter = messageTable.$loader.data( 'filter' );
+                               filter = messageTable.$loader.data( 'filter' ),
+                               $tuxTabUntranslated,
+                               $controlOwnButton,
+                               $hideTranslatedButton;
 
                        messageTable.$actionBar.find( '.down' ).removeClass( 
'down' );
                        if ( mode === 'translate' ) {
@@ -379,14 +382,14 @@
                                messageTable.$actionBar.find( 
'.tux-proofread-button' ).addClass( 'down' );
                        }
 
-                       if ( messageTable.mode === mode ) {
-                               // no change in the mode
-                               return;
-                       }
                        messageTable.mode = mode;
                        mw.translate.changeUrl( { action: this.mode } );
 
                        $( '.tux-message, .tux-message-proofread').remove();
+
+                       $tuxTabUntranslated = $( '.tux-message-selector > 
.tux-tab-untranslated' );
+                       $controlOwnButton = messageTable.$actionBar.find( 
'.tux-proofread-own-translations-button' );
+                       $hideTranslatedButton = messageTable.$actionBar.find( 
'.tux-editor-clear-translated' );
 
                        if ( messageTable.mode === 'proofread' ) {
                                $( '.tux-message-selector > 
.tux-tab-untranslated' ).addClass( 'hide' );
@@ -397,8 +400,16 @@
                                        mw.translate.changeFilter( 'translated' 
);
                                        $( '.tux-message-selector > 
.tux-tab-translated' ).addClass( 'selected' );
                                }
+                               $tuxTabUntranslated.addClass( 'hide' );
+                               $controlOwnButton.removeClass( 'hide' );
+                               $hideTranslatedButton.addClass( 'hide' );
                        } else {
-                               $( '.tux-message-selector > 
.tux-tab-untranslated' ).removeClass( 'hide' );
+                               $tuxTabUntranslated.removeClass( 'hide' );
+                               $controlOwnButton.addClass( 'hide' );
+
+                               if ( messageTable.$loader.data( 'filter' 
).indexOf( '!translated' ) > -1 ) {
+                                       $hideTranslatedButton.removeClass( 
'hide' );
+                               }
                        }
 
                        $.each( messageTable.messages, function ( index, 
message ) {
diff --git a/resources/js/ext.translate.special.translate.js 
b/resources/js/ext.translate.special.translate.js
index 1ff1b82..39c6b17 100644
--- a/resources/js/ext.translate.special.translate.js
+++ b/resources/js/ext.translate.special.translate.js
@@ -234,6 +234,19 @@
                        .filter( '.translated, .proofread' );
        }
 
+       function getOwnTranslatedMessages( $translateContainer ) {
+               $translateContainer = $translateContainer || $( 
'.ext-translate-container' );
+
+               return $translateContainer.find( '.tux-message-proofread' )
+                       .filter( function () {
+                               var $this = $( this );
+
+                               return ( $this.hasClass( 'translated' ) &&
+                                       $this.data( 'message' 
).properties['last-translator-text'] === mw.user.getName()
+                               );
+                       } );
+       }
+
        function workflowSelectionHandler ( state ) {
                var $status = $( '.tux-workflow-status' );
 
@@ -280,8 +293,8 @@
        }
 
        $( document ).ready( function () {
-               var targetLanguage, $translateContainer, 
$hideTranslatedButton,$messageList,
-                       docLanguageAutonym, docLanguageCode, ulsOptions, 
filter, uri;
+               var $translateContainer, $hideTranslatedButton, 
$controlOwnButton, $messageList,
+                       targetLanguage, docLanguageAutonym, docLanguageCode, 
ulsOptions, filter, uri;
 
                $messageList = $( '.tux-messagelist' );
                if ( $messageList.length ) {
@@ -366,7 +379,6 @@
 
                $translateContainer = $( '.ext-translate-container' );
 
-               // TODO: this could should be in messagetable
                $hideTranslatedButton = $translateContainer.find( 
'.tux-editor-clear-translated' );
                $hideTranslatedButton
                        .prop( 'disabled', !getTranslatedMessages( 
$translateContainer ).length )
@@ -375,6 +387,22 @@
                                $( this ).prop( 'disabled', true );
                        } );
 
+               $controlOwnButton = $translateContainer.find( 
'.tux-proofread-own-translations-button' );
+               $controlOwnButton.click( function () {
+                       var $this = $( this ),
+                               ownTranslatedMessages = 
getOwnTranslatedMessages( $translateContainer ),
+                               hideMessage = mw.msg( 
'tux-editor-proofreading-hide-own-translations' ),
+                               showMessage = mw.msg( 
'tux-editor-proofreading-show-own-translations' );
+
+                       if ( $this.hasClass( 'down' ) ) {
+                               ownTranslatedMessages.removeClass( 'hide' );
+                               $this.removeClass( 'down' ).text( hideMessage );
+                       } else {
+                               ownTranslatedMessages.addClass( 'hide' );
+                               $this.addClass( 'down' ).text( showMessage );
+                       }
+               } );
+
                // Workflow state selector
                $translateContainer.find( '.tux-workflow-status' )
                        .on( 'click', function () {
diff --git a/utils/TuxMessageTable.php b/utils/TuxMessageTable.php
index 0f649f8..d8200a3 100644
--- a/utils/TuxMessageTable.php
+++ b/utils/TuxMessageTable.php
@@ -52,17 +52,20 @@
 
                // Hide this button by default and show it only if the filter 
is relevant
                $footer .= '<div class="three columns text-center">'
-                       . '<button class="button tux-editor-clear-translated 
hide">'
+                       . '<button class="toggle button 
tux-proofread-own-translations-button hide-own hide">'
+                       . $this->msg( 
'tux-editor-proofreading-hide-own-translations' )->escaped()
+                       . '</button>';
+
+               // Hide this button by default and show it only if the filter 
is relevant
+               $footer .= '<button class="toggle button 
tux-editor-clear-translated hide">'
                        . $this->msg( 'tux-editor-clear-translated' )->escaped()
                        . '</button>'
                        . '</div>';
 
-
-               $footer .= '<div class="four columns text-center">'
-                               . '<button class="toggle button down 
translate-mode-button">'
-                               . $this->msg( 'tux-editor-translate-mode' 
)->escaped()
-                               . '</button>';
-
+               $footer .= '<div class="four columns tux-view-switcher 
text-center">'
+                       . '<button class="toggle button down 
translate-mode-button">'
+                       . $this->msg( 'tux-editor-translate-mode' )->escaped()
+                       . '</button>';
 
                if ( $this->getUser()->isallowed( 'translate-messagereview' ) ) 
{
                        $footer .=  '<button class="toggle button 
tux-proofread-button">'
@@ -71,6 +74,7 @@
                }
 
                $footer .= '</div>';
+
                // Actual message table is fetched and rendered at client side. 
This just provides
                // the loader and action bar.
                return $this->header() . $footer . '</div>';

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I170f019b7eb5f19229b66a275732d320617c2c5e
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Pginer <pgi...@wikimedia.org>
Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to