The image could not be deleted because it is used in the
diff --git a/addons/web_editor/static/tests/field_html_tests.js b/addons/web_editor/static/tests/field_html_tests.js
index 477519d4060..d307706557f 100644
--- a/addons/web_editor/static/tests/field_html_tests.js
+++ b/addons/web_editor/static/tests/field_html_tests.js
@@ -194,6 +194,9 @@ QUnit.module('web_editor', {}, function () {
return Promise.resolve();
}
}
+ if (route.indexOf('/web_editor/static/src/img/') === 0) {
+ return Promise.resolve();
+ }
return this._super(route, args);
},
});
@@ -216,7 +219,7 @@ QUnit.module('web_editor', {}, function () {
// load static xml file (dialog, media dialog, unsplash image widget)
await defMediaDialog;
- await testUtils.dom.click($('.modal #editor-media-image .o_image:first'));
+ await testUtils.dom.click($('.modal #editor-media-image .o_existing_attachment_cell:first'));
await testUtils.dom.click($('.modal .modal-footer button.btn-primary'));
var $editable = form.$('.oe_form_field[name="body"] .note-editable');
diff --git a/addons/web_editor/static/tests/wysiwyg_snippets_tests.js b/addons/web_editor/static/tests/wysiwyg_snippets_tests.js
index bd63364d303..842aeea1f2f 100644
--- a/addons/web_editor/static/tests/wysiwyg_snippets_tests.js
+++ b/addons/web_editor/static/tests/wysiwyg_snippets_tests.js
@@ -330,6 +330,12 @@ QUnit.test('background-image', function (assert) {
'
' +
'',
},
+ mockRPC: function (route, args) {
+ if (route.indexOf('/web_editor/static/src/img/') === 0) {
+ return Promise.resolve();
+ }
+ return this._super(route, args);
+ },
}).then(function (wysiwyg) {
var $editable = wysiwyg.getEditable();
@@ -352,7 +358,7 @@ QUnit.test('background-image', function (assert) {
$('#oe_manipulators .oe_overlay_options a.snippet-option-background[data-choose-image]').click();
defMediaDialogInit.then(function () {
- $('.o_select_media_dialog .existing-attachments .o_image').click();
+ $('.o_select_media_dialog .existing-attachments .o_existing_attachment_cell').click();
$('.o_select_media_dialog .modal-footer .btn-primary').click();
});
diff --git a/addons/web_editor/static/tests/wysiwyg_tests.js b/addons/web_editor/static/tests/wysiwyg_tests.js
index 4312121015b..be62dbb4192 100644
--- a/addons/web_editor/static/tests/wysiwyg_tests.js
+++ b/addons/web_editor/static/tests/wysiwyg_tests.js
@@ -3412,6 +3412,9 @@ QUnit.module('Media', {
if (route.indexOf('youtube') !== -1) {
return Promise.resolve();
}
+ if (route.indexOf('/web_editor/static/src/img/') === 0) {
+ return Promise.resolve();
+ }
return this._super(route, args);
},
};
diff --git a/addons/web_unsplash/controllers/main.py b/addons/web_unsplash/controllers/main.py
index ddebf07e327..c9a2deb631e 100644
--- a/addons/web_unsplash/controllers/main.py
+++ b/addons/web_unsplash/controllers/main.py
@@ -116,7 +116,7 @@ class Web_Unsplash(http.Controller):
'res_model': res_model,
})
attachment.generate_access_token()
- uploads.extend(attachment.read(['name', 'mimetype', 'checksum', 'res_id', 'res_model', 'access_token', 'url']))
+ uploads.extend(attachment.read(['name', 'mimetype', 'checksum', 'url', 'type', 'res_id', 'res_model', 'access_token']))
# Notifies Unsplash from an image download. (API requirement)
self._notify_download(value.get('download_url'))
diff --git a/addons/web_unsplash/static/src/js/unsplash_image_widget.js b/addons/web_unsplash/static/src/js/unsplash_image_widget.js
index 963d31c961a..53259e6278b 100644
--- a/addons/web_unsplash/static/src/js/unsplash_image_widget.js
+++ b/addons/web_unsplash/static/src/js/unsplash_image_widget.js
@@ -76,7 +76,7 @@ widgetsMedia.ImageWidget.include({
/**
* @override
*/
- save: function () {
+ _save: function () {
if (!this._unsplash.query) {
return this._super.apply(this, arguments);
}
@@ -96,7 +96,8 @@ widgetsMedia.ImageWidget.include({
image.src = image.url;
image.isDocument = !(/gif|jpe|jpg|png/.test(image.mimetype));
});
- self.images = images;
+ self.attachments = images;
+ self.selectedAttachments = images;
return _super.apply(self, args);
});
},
@@ -114,10 +115,9 @@ widgetsMedia.ImageWidget.include({
var always = function () {
if (!noRender) {
self._renderImages();
- self._adaptLoadMore();
}
};
- return this.unsplashAPI.getImages(needle, this.IMAGES_DISPLAYED_TOTAL).then(function (res) {
+ return this.unsplashAPI.getImages(needle, this.numberOfAttachmentsToDisplay).then(function (res) {
self._unsplash.isMaxed = res.isMaxed;
self._unsplash.records = res.images;
self._unsplash.error = false;
@@ -130,21 +130,10 @@ widgetsMedia.ImageWidget.include({
// Private
//--------------------------------------------------------------------------
- /**
- * @private
- */
- _adaptLoadMore: function () {
- if (!this._unsplash.isActive) {
- return this._super.apply(this, arguments);
- }
-
- this.$('.o_load_more').toggleClass('d-none', !!this._unsplash.error || this._unsplash.isMaxed);
- this.$('.o_load_done_msg').toggleClass('d-none', !!this._unsplash.error || !this._unsplash.isMaxed);
- },
/**
* @override
*/
- _highlightSelectedImages: function () {
+ _highlightSelected: function () {
var self = this;
if (!this._unsplash.isActive) {
return this._super.apply(this, arguments);
@@ -167,7 +156,6 @@ widgetsMedia.ImageWidget.include({
* @override
*/
_renderImages: function () {
- var self = this;
if (!this._unsplash.isActive) {
return this._super.apply(this, arguments);
}
@@ -181,13 +169,11 @@ widgetsMedia.ImageWidget.include({
return;
}
- var rows = _(this._unsplash.records).chain()
- .groupBy(function (a, index) { return Math.floor(index / self.IMAGES_PER_ROW); })
- .values()
- .value();
+ this.$('.unsplash_img_container').html(core.qweb.render('web_unsplash.dialog.image.content', {records: this._unsplash.records}));
+ this._highlightSelected();
- this.$('.unsplash_img_container').html(core.qweb.render('web_unsplash.dialog.image.content', {rows: rows}));
- this._highlightSelectedImages();
+ this.$('.o_load_more').toggleClass('d-none', !!this._unsplash.error || this._unsplash.isMaxed);
+ this.$('.o_load_done_msg').toggleClass('d-none', !!this._unsplash.error || !this._unsplash.isMaxed);
},
/**
* @private
@@ -248,7 +234,7 @@ widgetsMedia.ImageWidget.include({
} else {
this._unsplash.selectedImages[imgid] = {url: url, download_url: downloadURL};
}
- this._highlightSelectedImages();
+ this._highlightSelected();
},
/**
* @private
diff --git a/addons/web_unsplash/static/src/xml/unsplash_image_widget.xml b/addons/web_unsplash/static/src/xml/unsplash_image_widget.xml
index 6ecf304034b..73593b25e50 100644
--- a/addons/web_unsplash/static/src/xml/unsplash_image_widget.xml
+++ b/addons/web_unsplash/static/src/xml/unsplash_image_widget.xml
@@ -27,15 +27,15 @@