Skip to content
Snippets Groups Projects
Commit e59b86e6 authored by Florent Lejoly's avatar Florent Lejoly Committed by Thibault Delavallée
Browse files

[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#40895

Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent 157e3fe4
Branches
Tags
No related merge requests found
......@@ -359,6 +359,15 @@ var SlideUploadDialog = Dialog.extend({
this.$('#o_wslides_js_slide_upload_preview_column').removeClass('d-none');
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
*/
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment