From 92f8a3c9ef4a22d906b8df3795ad2ab55f672979 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 20 Mar 2019 10:15:49 +0000 Subject: [PATCH] [FIX] web_editor: review drag and drop in the editor Forward-port of https://github.com/odoo/odoo/commit/be689c53c13330832510c8cef332ac862d4ed5e8 was missed from 11.0. closes odoo/odoo#31971 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/editor/snippets.editor.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 2e9975014e3..11a96897fa6 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -370,6 +370,7 @@ var SnippetEditor = Widget.extend({ */ _onDragAndDropStart: function () { var self = this; + this.dropped = false; self.size = { width: self.$target.width(), height: self.$target.height() @@ -415,10 +416,21 @@ var SnippetEditor = Widget.extend({ * 'move' button. * * @private + * @param {Event} ev + * @param {Object} ui */ - _onDragAndDropStop: function () { + _onDragAndDropStop: function (ev, ui) { var self = this; + // TODO lot of this is duplicated code of the d&d feature of snippets + if (!this.dropped) { + var $el = $.nearest({x: ui.position.left, y: ui.position.top}, '.oe_drop_zone').first(); + if ($el.length) { + $el.after(this.$target); + this.dropped = true; + } + } + $('.oe_drop_zone').droppable('destroy').remove(); var prev = this.$target.first()[0].previousSibling;