From 04e9c941479c816d7089c718bd84550f3000f657 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 12 Sep 2016 11:44:08 +0200 Subject: [PATCH] [FIX] web_editor: allow to remove image from gallery thanks to remove button Commit b309f3ab543b5195eedc5b06ad08cfa81f43171a made the snippet remove button always be there by removing the "preventParentEmpty" mixin. Instead of preventing to remove the only child of a snippet, the system was changed to remove the parent if this only child is removed. This also applies on the system which hide the remove button if the child cannot be dropped anywhere in the DOM. Unfortunatly the image gallery snippet relied on the remove button to be hidden for its content images. Indeed, it was implemented so that the "remove" button is hidden but a "remove image from gallery" was there in the customize menu. The solution is to remove this option and copy its behavior on the standard remove button. Note: this probably was not done before because the on_remove feature was broken (fixed with commit 5e9ebcfb01f3250833a543154d072d6c785c9330). --- .../static/src/js/website.snippets.gallery.js | 16 +++++----------- addons/website/views/snippets.xml | 1 - 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/addons/website/static/src/js/website.snippets.gallery.js b/addons/website/static/src/js/website.snippets.gallery.js index ed1293229b8..481ba06e6f3 100644 --- a/addons/website/static/src/js/website.snippets.gallery.js +++ b/addons/website/static/src/js/website.snippets.gallery.js @@ -354,18 +354,12 @@ options.registry.gallery_img = options.Class.extend({ editor.reapply(); },0); }, - remove: function (type) { - if (type !== "click") return; - - var self = this; + on_remove: function () { var $parent = snippet_editor.globalSelector.closest(this.$target.parent()); - this.buildingBlock.make_active(false); - this.$target.remove(); - setTimeout(function () { - self.buildingBlock.make_active($parent); - var gallery = $parent.data('snippet-editor').styles.gallery; - gallery.reapply(); - }, 0); + _.defer((function () { + this.buildingBlock.make_active($parent); + $parent.data('snippet-editor').styles.gallery.reapply(); + }).bind(this)); } }); diff --git a/addons/website/views/snippets.xml b/addons/website/views/snippets.xml index 64e6e8571ae..18000e42e77 100644 --- a/addons/website/views/snippets.xml +++ b/addons/website/views/snippets.xml @@ -840,7 +840,6 @@
  • Move to last
  • -
  • Remove from gallery