From ef7eef619720e0d5abaf6bea60fc4c59262ba083 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 11 Dec 2013 17:23:05 +0100 Subject: [PATCH] [IMP] website snippet: remove parent snippet when user delete the last child colmd snippet bzr revid: chm@openerp.com-20131211162305-wxzvmwsb91e4prlb --- .../static/src/js/website.snippets.editor.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 55a920eab28..4cf49bb962b 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -673,7 +673,7 @@ }); - website.snippet.styleRegistry['size'] = website.snippet.StyleEditor.extend({ + website.snippet.styleRegistry.size = website.snippet.StyleEditor.extend({ select: function(event, np) { this._super(event, np); this.parent.parent.cover_target(this.$overlay, this.$target); @@ -1115,7 +1115,8 @@ this._super(); }, hide_remove_button: function() { - this.$overlay.find('.oe_snippet_remove').toggleClass("hidden", !this.$target.siblings().length); + this.$overlay.find('.oe_snippet_remove').toggleClass("hidden", + !this.$target.siblings().length && this.$target.parents("[data-snippet-id]:first").find("[data-snippet-id='colmd']").length > 1); }, onFocus : function () { this._super(); @@ -1131,8 +1132,13 @@ return false; }, on_remove: function () { - if (!this.$target.siblings().length){ - return false; + if (!this.$target.siblings().length) { + var $parent = this.$target.parents("[data-snippet-id]:first"); + if($parent.find("[data-snippet-id='colmd']").length > 1) { + return false; + } else { + $parent.data("snippet-editor").on_remove(); + } } this._super(); this.hide_remove_button();