From 711e2a534a922ebed1c5ae9851beefdd57db285b Mon Sep 17 00:00:00 2001 From: "Mahdi Cheikh Rouhou (macr)" Date: Wed, 13 Mar 2024 09:46:40 +0100 Subject: [PATCH] [FIX] web_editor: move columns left/right correctly Issue: ====== The icons does match the direction of the move but it doesn't match the label in the ltr language. Steps to reproduce the issue: ============================= - Install arabic - Go to notes and insert a table - write something in a column in the middle - Click on the top of the column on the 3 points. - The first item of the dropdown have the label in arabic meaning `Move to left` but the direction of the icon and clicking on it will move it to the right. Origin of the issue: ==================== - The icon is being flipped because we are in rtl but in realtity left is the same for rtl or ltr direction. - We need to call `_onTableMoveLeftClick` when we are moving to the right in rtl because the left of rtl direction is the visible right. task-3721794 X-original-commit: 58cdfb8c80ecfb305ecdb84398508bd2fc180fb3 Part-of: odoo/odoo#159087 --- .../js/editor/odoo-editor/src/OdooEditor.js | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index 4591670f29f..53bdf4301ad 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -408,6 +408,7 @@ export class OdooEditor extends EventTarget { this._tableUiContainer = this.document.createElement('div'); this._tableUiContainer.classList.add('o_table_ui_container'); const parser = new DOMParser(); + const isRTL = this.options.direction === "rtl"; for (const direction of ['row', 'column']) { // Create the containers and the menu toggler. const iconClass = (direction === 'row') ? 'fa-ellipsis-v' : 'fa-ellipsis-h'; @@ -418,13 +419,19 @@ export class OdooEditor extends EventTarget { `, 'text/html').body.firstElementChild; const uiMenu = ui.querySelector('.o_table_ui_menu'); - // Create the move buttons. if (direction === 'column') { - uiMenu.append(...parser.parseFromString(` -
` + this.options._t('Move left') + `
-
` + this.options._t('Move right') + `
- `, 'text/html').body.children); + if (isRTL) { + uiMenu.append(...parser.parseFromString(` +
` + this.options._t('Move left') + `
+
` + this.options._t('Move right') + `
+ `, 'text/html').body.children); + } else { + uiMenu.append(...parser.parseFromString(` +
` + this.options._t('Move left') + `
+
` + this.options._t('Move right') + `
+ `, 'text/html').body.children); + } this.addDomListener(uiMenu.querySelector('.o_move_left'), 'click', this._onTableMoveLeftClick); this.addDomListener(uiMenu.querySelector('.o_move_right'), 'click', this._onTableMoveRightClick); } else { @@ -438,10 +445,17 @@ export class OdooEditor extends EventTarget { // Create the add buttons. if (direction === 'column') { - uiMenu.append(...parser.parseFromString(` -
` + this.options._t('Insert left') + `
-
` + this.options._t('Insert right') +`
- `, 'text/html').body.children); + if (isRTL) { + uiMenu.append(...parser.parseFromString(` +
` + this.options._t('Insert left') + `
+
` + this.options._t('Insert right') + `
+ `, 'text/html').body.children); + } else { + uiMenu.append(...parser.parseFromString(` +
` + this.options._t('Insert left') + `
+
` + this.options._t('Insert right') + `
+ `, 'text/html').body.children); + } this.addDomListener(uiMenu.querySelector('.o_insert_left'), 'click', () => this.execCommand('addColumn', 'before', this._columnUiTarget)); this.addDomListener(uiMenu.querySelector('.o_insert_right'), 'click', () => this.execCommand('addColumn', 'after', this._columnUiTarget)); } else {