From 1da79c54a1bb7541e4e77e627908147b39087d67 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 28 Oct 2015 15:00:57 +0100 Subject: [PATCH] [FIX] web{site,_editor}: gallery upload image * when getting the src of an uploaded attachment we have to use src which is by default url, * in a MediaDialog the pager is shared between the document and image dialog, but when changing page, it was done for both (even if not displayed), * select the image after uploading it in the ImageDialog. closes #9284 opw-653061 opw-653167 --- addons/web_editor/static/src/js/widgets.js | 6 ++++-- addons/website/static/src/js/website.snippets.gallery.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index 71bd31eaaca..7508ce1c392 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -285,6 +285,9 @@ var ImageDialog = Widget.extend({ o.id = +o.url.match(/\/web\/content\/([0-9]*)/, '')[1]; } this.parent.$(".pager > li").click(function (e) { + if(!self.$el.is(':visible')) { + return; + } e.preventDefault(); var $target = $(e.currentTarget); if ($target.hasClass('disabled')) { @@ -303,7 +306,6 @@ var ImageDialog = Widget.extend({ var img = _.select(this.images, function (v) { return v.id == attachment.id;}); if (img.length) { this.images.splice(this.images.indexOf(img[0]),1); - return; } } else { this.images = []; @@ -421,11 +423,11 @@ var ImageDialog = Widget.extend({ var $button = this.$('button.filepicker'); if (!error) { $button.addClass('btn-success'); + this.set_image(attachment); } else { this.$('form').addClass('has-error') .find('.help-block').text(error); $button.addClass('btn-danger'); - this.set_image(attachment, error); } if (!this.options.select_images) { diff --git a/addons/website/static/src/js/website.snippets.gallery.js b/addons/website/static/src/js/website.snippets.gallery.js index fd6005456e2..a729b8a0c81 100644 --- a/addons/website/static/src/js/website.snippets.gallery.js +++ b/addons/website/static/src/js/website.snippets.gallery.js @@ -232,7 +232,7 @@ options.registry.gallery = options.Class.extend({ editor.on('saved', this, function (attachments) { for (var i = 0 ; i < attachments.length; i++) { var img = $('') - .attr("src", attachments[i].url) + .attr("src", attachments[i].src) .attr('data-index', index+i) .data('index', index+i) .appendTo($container);