Making WordPress.org

Changeset 12583


Ignore:
Timestamp:
05/12/2023 08:05:07 AM (4 years ago)
Author:
amieiro
Message:

Add a new tab with the TM to the right sidebar

  • Add a new tab with the TM to the right sidebar.
  • Remember the las tab opened.
Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/js/editor.js

    r12511 r12583  
     1/* global $gp */
    12( function( $ ){
    23        var $html = $( 'html' );
    … …  
    300301                        }
    301302                }
     303                // Click on the last tab opened in the previous row, to show the same tab in the current row.
     304                $gp.editor.current.find( '.' + states['last-tab-type-open'] ).first().click();
     305        }
     306
     307        function changeRightTab( event ) {
     308                var tab = $( this );
     309                var tabType = tab.attr( 'class' ).split(' ')[0];
     310                var tabId = tab.attr( 'data-tab' );
     311                var divId = tabId.replace( 'tab', 'div' );
     312                var originalId = tabId.replace( /[^\d-]/g, '' ).replace( /^-+/g, '' );
     313                changeVisibleTab( tab );
     314                changeVisibleDiv( divId, originalId );
     315                updateDetailsState( 'last-tab-type-open', tabType );
     316                // Avoid to execute the code from the gp-translation-helpers plugin.
     317                event.stopImmediatePropagation();
     318        }
     319
     320        /**
     321         * Hides all tabs and show one of them, the last clicked.
     322         *
     323         * @param {Object} tab The selected tab.
     324         */
     325        function changeVisibleTab( tab ) {
     326                var tabId = tab.attr( 'data-tab' );
     327                tab.siblings().removeClass( 'current' );
     328                tab.parents( '.sidebar-tabs ' ).find( '.helper' ).removeClass( 'current' );
     329                tab.addClass( 'current' );
     330
     331                $( '#' + tabId ).addClass( 'current' );
     332        }
     333
     334
     335        /**
     336         * Hides all divs and show one of them, the last clicked.
     337         *
     338         * @param {string} tabId      The select tab id.
     339         * @param {number} originalId The id of the original string to translate.
     340         */
     341        function changeVisibleDiv( tabId, originalId ) {
     342                $( '#sidebar-div-meta-' + originalId ).hide();
     343                $( '#sidebar-div-discussion-' + originalId ).hide();
     344                $( '#sidebar-div-history-' + originalId ).hide();
     345                $( '#sidebar-div-other-locales-' + originalId ).hide();
     346                $( '#sidebar-div-translation-memory-' + originalId ).hide();
     347                $( '#' + tabId ).show();
    302348        }
    303349
    … …  
    330376                                .on( 'click', 'button.button-menu__toggle', toggleLinkMenu )
    331377                                .on( 'click', '.translation-suggestion.with-tooltip.openai', addSuggestion )
    332                                 .on( 'click', '.translation-suggestion.with-tooltip.deepl', addSuggestion );
     378                                .on( 'click', '.translation-suggestion.with-tooltip.deepl', addSuggestion )
     379                                .on( 'click', '.sidebar-tabs li', changeRightTab );
    333380                }
    334381        })( $gp.editor.install_hooks );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css

    r12511 r12583  
    31483148.meta.discussion,
    31493149.meta.history,
    3150 .meta.other-locales {
     3150.meta.other-locales,
     3151.meta.translation-memory {
    31513152        padding: 12px;
    31523153}
    … …  
    31903191}
    31913192
    3192 .meta.other-locales ul {
     3193.meta.other-locales ul, .meta.transation-memory ul {
    31933194        margin: 0;
    31943195        padding: 0;
     3196}
     3197
     3198.meta.translation-memory ul.suggestions-list {
     3199        list-style: none;
     3200        margin-left: 0;
     3201}
     3202
     3203.meta.translation-memory div.translation-suggestion {
     3204        margin: 1rem 0;
    31953205}
    31963206
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/translation-row-editor.php

    r12406 r12583  
    77$more_links = array();
    88if ( $translation->translation_status ) {
    9         $translation_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[status]' => 'either', 'filters[original_id]' => $translation->original_id, 'filters[translation_id]' => $translation->id ) );
     9        $translation_permalink               = gp_url_project_locale(
     10                $project,
     11                $locale->slug,
     12                $translation_set->slug,
     13                array(
     14                        'filters[status]'         => 'either',
     15                        'filters[original_id]'    => $translation->original_id,
     16                        'filters[translation_id]' => $translation->id,
     17                )
     18        );
    1019        $more_links['translation-permalink'] = '<a href="' . esc_url( $translation_permalink ) . '">Permalink to translation</a>';
    1120} else {
    12         $original_permalink = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[original_id]' => $translation->original_id ) );
     21        $original_permalink               = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[original_id]' => $translation->original_id ) );
    1322        $more_links['original-permalink'] = '<a href="' . esc_url( $original_permalink ) . '">Permalink to original</a>';
    1423}
    1524
    16 $original_history = gp_url_project_locale( $project, $locale->slug, $translation_set->slug, array( 'filters[status]' => 'either', 'filters[original_id]' => $translation->original_id, 'sort[by]' => 'translation_date_added', 'sort[how]' => 'asc' ) );
     25$original_history      = gp_url_project_locale(
     26        $project,
     27        $locale->slug,
     28        $translation_set->slug,
     29        array(
     30                'filters[status]'      => 'either',
     31                'filters[original_id]' => $translation->original_id,
     32                'sort[by]'             => 'translation_date_added',
     33                'sort[how]'            => 'asc',
     34        )
     35);
    1736$more_links['history'] = '<a href="' . esc_url( $original_history ) . '">Translation History</a>';
    1837
    … …  
    3150?>
    3251<tr class="editor <?php echo gp_translation_row_classes( $translation ); ?>" id="editor-<?php echo esc_attr( $translation->row_id ); ?>" row="<?php echo esc_attr( $translation->row_id ); ?>">
    33         <td colspan="<?php echo $can_approve ? 5 : 4 ?>">
     52        <td colspan="<?php echo $can_approve ? 5 : 4; ?>">
    3453                <div class="editor-panel">
    3554                        <div class="editor-panel__left">
    … …  
    8099                                                $plural   = $translation->plural_glossary_markup ?? esc_translation( $translation->plural );
    81100
    82                                                 if ( ! $translation->plural ) : ?>
     101                                                if ( ! $translation->plural ) :
     102                                                        ?>
    83103                                                        <div class="source-string__singular">
    84104                                                                <span class="original"><?php echo prepare_original( $singular ); ?></span>
    85105                                                                <span aria-hidden="true" class="original-raw"><?php echo esc_translation( $translation->singular ); ?></span>
    86106                                                        </div>
    87                                                 <?php else: ?>
     107                                                <?php else : ?>
    88108                                                        <div class="source-string__singular">
    89109                                                                <small>Singular:</small>
    … …  
    100120
    101121                                        <div class="source-details">
    102                                                 <?php if ( wporg_gp_should_display_original_context( $translation ) ): ?>
     122                                                <?php if ( wporg_gp_should_display_original_context( $translation ) ) : ?>
    103123                                                        <details open class="source-details__context">
    104124                                                                <summary>Context</summary>
    … …  
    106126                                                        </details>
    107127                                                <?php endif; ?>
    108                                                 <?php if ( $translation->extracted_comments ) :
     128                                                <?php
     129                                                if ( $translation->extracted_comments ) :
    109130                                                        ?>
    110131                                                        <details open class="source-details__comment">
    … …  
    155176                                                                                </li>
    156177                                                                        <?php else : ?>
    157                                                                                 <?php foreach( range( 0, $locale->nplurals - 1 ) as $plural_index ):
    158                                                                                         $plural_string = implode(', ', $locale->numbers_for_index( $plural_index ) );
     178                                                                                <?php
     179                                                                                foreach ( range( 0, $locale->nplurals - 1 ) as $plural_index ) :
     180                                                                                        $plural_string = implode( ', ', $locale->numbers_for_index( $plural_index ) );
    159181                                                                                        ?>
    160182                                                                                        <li>
    … …  
    162184                                                                                                                class="translation-form-list__tab with-tooltip<?php echo ( 0 === $plural_index ) ? ' translation-form-list__tab--active' : ''; ?>"
    163185                                                                                                                data-plural-index="<?php echo $plural_index; ?>"
    164                                                                                                                 aria-label="<?php printf('This plural form is used for numbers like: %s', $plural_string ); ?>"
     186                                                                                                                aria-label="<?php printf( 'This plural form is used for numbers like: %s', $plural_string ); ?>"
    165187                                                                                                                type="button">
    166188                                                                                                        <?php echo $plural_string; ?>
    … …  
    174196
    175197                                                <?php if ( ! $translation->plural ) : ?>
    176                                                         <?php wporg_gp_translate_textarea( $translation, [ $can_edit, $can_approve_translation ] ); ?>
     198                                                        <?php wporg_gp_translate_textarea( $translation, array( $can_edit, $can_approve_translation ) ); ?>
    177199                                                <?php else : ?>
    178                                                         <?php foreach( range( 0, $locale->nplurals - 1 ) as $plural_index ): ?>
    179                                                                 <?php wporg_gp_translate_textarea( $translation, [ $can_edit, $can_approve ], $plural_index ); ?>
     200                                                        <?php foreach ( range( 0, $locale->nplurals - 1 ) as $plural_index ) : ?>
     201                                                                <?php wporg_gp_translate_textarea( $translation, array( $can_edit, $can_approve ), $plural_index ); ?>
    180202                                                        <?php endforeach; ?>
    181203                                                <?php endif; ?>
    … …  
    240262                        <div class="editor-panel__right">
    241263<!--                            <div class="panel-header">
    242                                         <h3><?php /*_e( 'Meta', 'glotpress' ); */?></h3>
     264                                        <h3><?php /*_e( 'Meta', 'glotpress' ); */ ?></h3>
    243265                                </div>-->
    244266                                <div class="panel-content">
    245267                                        <?php ob_start(); ?>
    246                     <div class="meta" id="sidebar-div-meta-<?php echo $translation->row_id ?>">
     268                                        <div class="meta" id="sidebar-div-meta-<?php echo $translation->row_id; ?>">
    247269                                                <?php gp_tmpl_load( 'translation-row-editor-meta-feedback', get_defined_vars() ); ?>
    248                                                 <?php if ( $translation->translation_status && ( $can_approve_translation || $can_reject_self ) ): ?>
     270                                                <?php if ( $translation->translation_status && ( $can_approve_translation || $can_reject_self ) ) : ?>
    249271                                                        <div class="status-actions">
    250272                                                                <?php if ( $can_approve_translation ) : ?>
    … …  
    261283                                                                                <button class="button fuzzy" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-fuzzy_' . $translation->id ) ); ?>"><strong>~</strong> <?php _e( 'Fuzzy', 'glotpress' ); ?></button>
    262284                                                                        <?php endif; ?>
    263                                                                 <?php elseif ( $can_reject_self ): ?>
     285                                                                <?php elseif ( $can_reject_self ) : ?>
    264286                                                                        <button class="button reject" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-rejected_' . $translation->id ) ); ?>"><strong>&minus;</strong> <?php _e( 'Reject Suggestion', 'glotpress' ); ?></button>
    265287                                                                        <button class="button fuzzy" tabindex="-1" data-nonce="<?php echo esc_attr( wp_create_nonce( 'update-translation-status-fuzzy_' . $translation->id ) ); ?>"><strong>~</strong> <?php _e( 'Fuzzy', 'glotpress' ); ?></button>
    … …  
    275297                                                </dl>
    276298
    277                                                 <?php if ( $translation->translation_added && $translation->translation_added !== '0000-00-00 00:00:00' ): ?>
     299                                                <?php if ( $translation->translation_added && $translation->translation_added !== '0000-00-00 00:00:00' ) : ?>
    278300                                                        <dl>
    279301                                                                <dt><?php _e( 'Added:', 'glotpress' ); ?></dt>
    … …  
    281303                                                        </dl>
    282304                                                <?php endif; ?>
    283                                                 <?php if ( $translation->date_modified && $translation->date_modified !== '0000-00-00 00:00:00' && $translation->date_modified !== $translation->translation_added ): ?>
     305                                                <?php if ( $translation->date_modified && $translation->date_modified !== '0000-00-00 00:00:00' && $translation->date_modified !== $translation->translation_added ) : ?>
    284306                                                        <dl>
    285307                                                                <dt><?php _e( 'Last modified:', 'glotpress' ); ?></dt>
    … …  
    295317                                                <?php if ( $translation->user_last_modified && ( ! $translation->user || $translation->user->ID !== $translation->user_last_modified->ID ) ) : ?>
    296318                                                        <dl>
    297                                                                 <dt><?php
    298                                                                         if ( 'current' === $translation->translation_status ) {
    299                                                                                 _e( 'Approved by:', 'glotpress' );
    300                                                                         } elseif ( 'rejected' === $translation->translation_status ) {
    301                                                                                 _e( 'Rejected by:', 'glotpress' );
    302                                                                         } else {
    303                                                                                 _e( 'Last updated by:', 'glotpress' );
    304                                                                         }
    305                                                                         ?>
     319                                                                <dt>
     320                                                                <?php
     321                                                                if ( 'current' === $translation->translation_status ) {
     322                                                                        _e( 'Approved by:', 'glotpress' );
     323                                                                } elseif ( 'rejected' === $translation->translation_status ) {
     324                                                                        _e( 'Rejected by:', 'glotpress' );
     325                                                                } else {
     326                                                                        _e( 'Last updated by:', 'glotpress' );
     327                                                                }
     328                                                                ?>
    306329                                                                </dt>
    307330                                                                <dd><?php gp_link_user( $translation->user_last_modified ); ?></dd>
    … …  
    311334                                                <dl>
    312335                                                        <dt><?php _e( 'Priority of the original:', 'glotpress' ); ?></dt>
    313                                                         <?php if ( $can_write ): ?>
    314                                                                 <dd><?php
     336                                                        <?php if ( $can_write ) : ?>
     337                                                                <dd>
     338                                                                <?php
    315339                                                                        echo gp_select(
    316340                                                                                'priority-' . $translation->original_id,
    … …  
    323347                                                                                )
    324348                                                                        );
    325                                                                         ?></dd>
     349                                                                ?>
     350                                                                        </dd>
    326351                                                        <?php else : ?>
    327352                                                                <dd><?php echo gp_array_get( GP::$original->get_static( 'priorities' ), $translation->priority, 'unknown' ); ?></dd>
    … …  
    338363                                        $sidebar_tabs .= '      <li class="tab-history" data-tab="sidebar-tab-history-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '">History&nbsp;<span class="count"></span></li>';
    339364                                        $sidebar_tabs .= '      <li class="tab-other-locales" data-tab="sidebar-tab-other-locales-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '">Other&nbsp;locales&nbsp;<span class="count"></span></li>';
     365                                        $sidebar_tabs .= '      <li class="tab-translation-memory" data-tab="sidebar-tab-translation-memory-' . $translation->row_id . '" data-row-id="' . $translation->row_id . '">TM&nbsp;<span class="count"></span></li>';
    340366                                        $sidebar_tabs .= '</ul>';
    341367                                        $sidebar_tabs .= $meta_sidebar;
    … …  
    343369                                        $sidebar_tabs .= '<div class="meta history" id="sidebar-div-history-' . $translation->row_id . '"  data-row-id="' . $translation->row_id . '" style="display: none;"></div>';
    344370                                        $sidebar_tabs .= '<div class="meta other-locales" id="sidebar-div-other-locales-' . $translation->row_id . '"  data-row-id="' . $translation->row_id . '" style="display: none;"></div>';
     371                                        $sidebar_tabs .= '<div class="meta translation-memory" id="sidebar-div-translation-memory-' . $translation->row_id . '"  data-row-id="' . $translation->row_id . '" style="display: none;"></div>';
    345372                                        $sidebar_tabs .= '</nav>';
    346373
Note: See TracChangeset for help on using the changeset viewer.