From 4e32a23d969d6ba1b54836bfc09be1eb6ee4f3c0 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 14 Nov 2017 13:49:38 +0100 Subject: [PATCH] [FIX] web_editor: restore selected images display In the media dialog, when an image is selected, it has a colored border to indicate it. Commit https://github.com/odoo/odoo/commit/e011d58bee140411ccfb1ef9115dddc090d573c3 made changes, part of them designed to "Improve the image dialog to be able to select/unselect". While this commit was indeed doing that, it was also breaking stuff: when selecting image(s) then performing a search, the colored border disappeared while the images were in fact still selected. Fortunately, this stuff breaking is only due to code modification that was made for no reason (so reverting part of the commit is enough to restore the features while keeping the commit's improvements). --- addons/web_editor/static/src/js/widgets/widgets.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js index f8626e33390..8214754cd6b 100644 --- a/addons/web_editor/static/src/js/widgets/widgets.js +++ b/addons/web_editor/static/src/js/widgets/widgets.js @@ -229,7 +229,6 @@ var ImageDialog = Widget.extend({ this.push(attachment); this.$('input.url').val(''); this.search(); - this.images = []; }, form_submit: function (event) { var self = this; @@ -342,24 +341,20 @@ var ImageDialog = Widget.extend({ }, select_existing: function (e) { var $img = $(e.currentTarget); - if (!this.options.select_images) { - this.$('.o_existing_attachment_cell.o_selected').removeClass("o_selected"); - $img.closest('.o_existing_attachment_cell').addClass('o_selected'); - } else { - $img.closest('.o_existing_attachment_cell').toggleClass('o_selected'); - } var attachment = _.find(this.records, function (record) { return record.id === $img.data('id'); }); this.push(attachment); this.selected_existing(); }, selected_existing: function () { var self = this; + this.$('.o_existing_attachment_cell.o_selected').removeClass("o_selected"); var $select = this.$('.o_existing_attachment_cell [data-src]').filter(function () { var $img = $(this); return !!_.find(self.images, function (v) { return (v.url === $img.data("src") || ($img.data("url") && v.url === $img.data("url")) || v.id === $img.data("id")); }); }); + $select.closest('.o_existing_attachment_cell').addClass("o_selected"); return $select; }, try_remove: function (e) {