[FIX] web_editor: do not delete empty .oe_structure element

If a snippet contains a .oe_structure element inside of it, it allows
the user to drop other snippets in that location. The web_editor
contains code which removes all empty parent of an element being
deleted. This is done so that, for example, when the last col of a
3-col snippet is removed, the whole snippet is removed.

However, there was an exception to this rule which was not considered,
if one of these empty parent is an .oe_structure, it should not be
removed.

Note: the only snippet which does this is the parallax snippet.
This commit is contained in:
qsm-odoo
2016-11-03 16:45:27 +01:00
parent 76314f0a3b
commit 229fab5fa0
@@ -1076,12 +1076,12 @@ data.Editor = Class.extend({
if($parent.closest(":data(\"snippet-editor\")").length) {
while (!$parent.data("snippet-editor")) {
var $nextParent = $parent.parent();
if ($parent.children().length === 0 && $parent.text().trim() === "") {
if ($parent.children().length === 0 && $parent.text().trim() === "" && !$parent.hasClass("oe_structure")) {
$parent.remove();
}
$parent = $nextParent;
}
if ($parent.children().length === 0 && $parent.text().trim() === "") {
if ($parent.children().length === 0 && $parent.text().trim() === "" && !$parent.hasClass("oe_structure")) {
_.defer(function () {
$parent.data("snippet-editor").on_remove();
});