summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Lejoly <fle@odoo.com>2019-11-26 13:20:39 +0000
committerThibault Delavallée <tde@odoo.com>2019-12-13 09:53:13 +0000
commit39979b75580d8874a3ef9d1e93a122e40545a1d2 (patch)
tree60eede9ac269f1a1021bea94ba2ca88a9ab9c52f
parent7a3316daa686406834f3739a80220ecc44d362f0 (diff)
[FIX] website_slides: fix cancel of uploaded file
Steps to reproduce * connect as any user with right to edit website; * go to website and chose a course; * add content -> chose any of the possibilities; * click on choose file, select a file and open it; * click on choose file again, and then cancel You get a traceback. This is due to the right panel that displays a preview of the selected file. IN this commit we fix that issue by removing the preview panel. Task id 2146217 PR#40895 closes odoo/odoo#41837 X-original-commit: e59b86e6474ae994307952d53f4e5a7571ac1763 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
-rw-r--r--addons/website_slides/static/src/js/slides_upload.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/addons/website_slides/static/src/js/slides_upload.js b/addons/website_slides/static/src/js/slides_upload.js
index 83d24d8a447..52ea4915b6d 100644
--- a/addons/website_slides/static/src/js/slides_upload.js
+++ b/addons/website_slides/static/src/js/slides_upload.js
@@ -360,6 +360,15 @@ var SlideUploadDialog = Dialog.extend({
this.$modal.find('.modal-dialog').addClass('modal-lg');
},
/**
+ * Hide the preview/right column and resize the modal
+ * @private
+ */
+ _hidePreviewColumn: function () {
+ this.$('#o_wslides_js_slide_upload_left_column').addClass('col').removeClass('col-md-6');
+ this.$('#o_wslides_js_slide_upload_preview_column').addClass('d-none');
+ this.$modal.find('.modal-dialog').removeClass('modal-lg');
+ },
+ /**
* @private
*/
// TODO: Remove this part, as now SVG support in image resize tools is included
@@ -416,6 +425,11 @@ var SlideUploadDialog = Dialog.extend({
var preventOnchange = $input.data('preventOnchange');
var file = ev.target.files[0];
+ if (!file) {
+ this.$('#slide-image').attr('src', '/website_slides/static/src/img/document.png');
+ this._hidePreviewColumn();
+ return;
+ }
var isImage = /^image\/.*/.test(file.type);
var loaded = false;
this.file.name = file.name;
@@ -423,11 +437,13 @@ var SlideUploadDialog = Dialog.extend({
if (!(isImage || this.file.type === 'application/pdf')) {
this._alertDisplay(_t("Invalid file type. Please select pdf or image file"));
this._fileReset();
+ this._hidePreviewColumn();
return;
}
if (file.size / 1024 / 1024 > 25) {
this._alertDisplay(_t("File is too big. File size cannot exceed 25MB"));
this._fileReset();
+ this._hidePreviewColumn();
return;
}