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

Change subject: Feature to add a new unit to facilitate manual splitting for 
Special:PageMigration
......................................................................


Feature to add a new unit to facilitate manual splitting for 
Special:PageMigration

A new '+' icon has been added to add a new empty unit after the current one to
allow manual splitting of the translation units.

Bug: 65739
Change-Id: I2e794483665e7666117d410c33058550c7dd92cc
---
M resources/css/ext.translate.special.pagemigration.css
M resources/js/ext.translate.special.pagemigration.js
2 files changed, 55 insertions(+), 15 deletions(-)

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



diff --git a/resources/css/ext.translate.special.pagemigration.css 
b/resources/css/ext.translate.special.pagemigration.css
index 78a35ff..4a4113e 100644
--- a/resources/css/ext.translate.special.pagemigration.css
+++ b/resources/css/ext.translate.special.pagemigration.css
@@ -31,19 +31,21 @@
        border: 2px solid transparent;
 }
 
-#actions div:last-child .swap {
+#actions div:last-child .swap,
+#actions div:last-child .add {
        display: none;
 }
 
 .edit,
 .save-edit,
 .delete,
-.swap {
+.swap,
+.add {
        width: 10%;
        height: 10%;
        float: left;
-       margin-left: 10%;
-       margin-right: 10%;
+       margin-left: 5%;
+       margin-right: 5%;
        cursor: pointer;
 }
 
@@ -78,4 +80,11 @@
        background: url('../images/label-tick.png') transparent;
        background-image: linear-gradient(transparent, transparent), 
url('../images/label-tick.png');
        background-image: -webkit-linear-gradient(transparent, transparent), 
url('../images/label-tick.png');
+}
+
+.add {
+       display: inline-block;
+       background: url('../images/add.png');
+       background-image: linear-gradient(transparent, transparent), 
url('../images/add.png');
+       background-image: -webkit-linear-gradient(transparent, transparent), 
url('../images/add.png');
 }
\ No newline at end of file
diff --git a/resources/js/ext.translate.special.pagemigration.js 
b/resources/js/ext.translate.special.pagemigration.js
index 0915b63..5d56e55 100644
--- a/resources/js/ext.translate.special.pagemigration.js
+++ b/resources/js/ext.translate.special.pagemigration.js
@@ -158,11 +158,28 @@
        }
 
        /**
+        * Update the IDs of translation divs and action divs. This function is 
called
+        * when a unit is deleted or a new unit is added for manual splitting
+        */
+       function updateIDs() {
+               var divNumber = 1;
+               $( '#translationunits div' ).each( function() {
+                       $( this ).attr( 'id', 't' + divNumber );
+                       divNumber += 1;
+               } );
+               divNumber = 1;
+               $( '#actions div' ).each( function() {
+                       $( this ).attr( 'id', 'a' + divNumber );
+                       divNumber += 1;
+               } );
+       }
+
+       /**
         * Add empty RHS blocks to always match with the number of source units
         */
        function addEmptyUnits() {
                var difference, i, divActions,
-                       divTranslations, previousID;
+                       divTranslations;
 
                divActions = $( '#actions' );
                divTranslations = $( '#translationunits' );
@@ -170,16 +187,13 @@
                        return;
                } else {
                        difference = noOfSourceUnits - noOfTranslationUnits;
-                       previousID = Number( $( '#translationunits div:last' 
).attr( 'id' ).replace( 't', '' ) );
                        for ( i = 1; i <= difference; i++ ) {
-                               $( '<div>' ).attr( 'id', 't' + ( previousID + 1 
) )
-                                       .appendTo( divTranslations );
-                               $( '<div>' ).attr( 'id', 'a' + ( previousID + 1 
) )
-                                       .append( $( '<span>' ).attr( 'class', 
'edit' ),
-                                               $( '<span>' ).attr( 'class', 
'delete' ),
-                                               $( '<span>' ).attr( 'class', 
'swap' ) )
-                                       .appendTo( divActions );
-                               previousID += 1;
+                               $( '<div>' ).appendTo( divTranslations );
+                               $( '<div>' ).append( $( '<span>' ).attr( 
'class', 'edit' ),
+                                       $( '<span>' ).attr( 'class', 'delete' ),
+                                       $( '<span>' ).attr( 'class', 'swap' ),
+                                       $( '<span>' ).attr( 'class', 'add' ) )
+                               .appendTo( divActions );
                        }
                        noOfTranslationUnits = noOfSourceUnits;
                }
@@ -199,7 +213,8 @@
                        $( '<div>' ).attr( 'id', 'a' + ( i + 1 ) )
                                .append( $( '<span>' ).attr( 'class', 'edit' ),
                                        $( '<span>' ).attr( 'class', 'delete' ),
-                                       $( '<span>' ).attr( 'class', 'swap' ) )
+                                       $( '<span>' ).attr( 'class', 'swap' ),
+                                       $( '<span>' ).attr( 'class', 'add' ) )
                                .appendTo( divActions );
                }
        }
@@ -276,6 +291,20 @@
                $( '#sourceunits, #translationunits, #actions' ).html( '' );
        } );
 
+       $( document ).on( 'click', '.add', function() {
+               var parentID, translationID;
+               parentID = $( this ).parent().attr( 'id' );
+               translationID = 't' + parentID.replace( 'a' , '' );
+               $( '<div>' ).insertAfter( '#' + translationID );
+               $( '<div>' ).append( $( '<span>' ).attr( 'class', 'edit' ),
+                       $( '<span>' ).attr( 'class', 'delete' ),
+                       $( '<span>' ).attr( 'class', 'swap' ),
+                       $( '<span>' ).attr( 'class', 'add' ) )
+               .insertAfter( '#' + parentID );
+               noOfTranslationUnits += 1;
+               updateIDs();
+       } );
+
        $( document ).on( 'click', '.delete', function() {
                var parentID, translationID;
                parentID = $( this ).parent().attr( 'id' );
@@ -284,6 +313,7 @@
                $( this ).parent().remove();
                noOfTranslationUnits -= 1;
                addEmptyUnits();
+               updateIDs();
        } );
 
        $( document ).on( 'click', '.save-edit', function() {
@@ -336,6 +366,7 @@
                                        showTranslationUnits( translations );
                                        showActionIcons( noOfTranslationUnits );
                                        addEmptyUnits();
+                                       updateIDs();
                                        $( '#buttonSavePages, 
#buttonCancel').show();
                                        $( '#buttonImport' ).hide();
                                } );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2e794483665e7666117d410c33058550c7dd92cc
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: BPositive <[email protected]>
Gerrit-Reviewer: BPositive <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to