Santhosh has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/350408 )

Change subject: Fix the container calculaiton for template editor
......................................................................

Fix the container calculaiton for template editor

For inline templates, it was possible to have a container
for editor evaluated as a child of a section. Since anything
under section is saved, the whole editor code may get saved.

Also the previous code might give more than one match for the container
resulting multiple editors.

This fix corrects this behavior.

Testplan:
Translate Варна from ru to ba. Click on the section under Климат, it has
two big tables, both are templates. Double click to open the editor.

Without this template, the editor's position will be wrong and sometimes
the target column of editor won't even appear. Also the whole section
alignment will go wrong.

With this patch the editors should appear aligned and in correct position.

Note that there is a delay in getting this template editor rendered since
it has lot of fields.

Bug: T163105
Change-Id: I4094c81c08a0f6674664787ae90d2eb446c36c6e
---
M modules/tools/ext.cx.tools.template.js
1 file changed, 8 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/08/350408/1

diff --git a/modules/tools/ext.cx.tools.template.js 
b/modules/tools/ext.cx.tools.template.js
index 1e900a4..3f36082 100644
--- a/modules/tools/ext.cx.tools.template.js
+++ b/modules/tools/ext.cx.tools.template.js
@@ -283,16 +283,18 @@
         * @return {jQuery}
         */
        Template.prototype.getEditorContainer = function () {
-               var $container;
+               var $container, $visibleFragment;
 
-               $container = this.$template;
-
+               $visibleFragment = this.getFirstVisibleFragment() || 
this.$template;
                if ( this.options.inline ) {
-                       this.$parentSection = this.$parentSection ||
-                               this.$template.closest( 
mw.cx.getSectionSelector() );
+                       this.$parentSection = this.$parentSection || 
$visibleFragment.parent( mw.cx.getSectionSelector() );
                        $container = this.$parentSection;
                } else {
-                       $container = this.getFirstVisibleFragment() || 
this.$template;
+                       $container = $visibleFragment;
+               }
+
+               if ( $container.length !== 1 ) {
+                       mw.log.error( '[CX] Attaching template editor to a non 
section' );
                }
 
                return $container;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4094c81c08a0f6674664787ae90d2eb446c36c6e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>

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

Reply via email to