[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).
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user