[IMP] website_slides: allow to set cover image for webpage slide
Before this commit, the user can only create a webpage slide by setting its name, category and tags. On the channel grid, no tumbnail was shown. This commit allow the user to upload a cover image from the slide upload modal and to modify it from form view. the mimetype of webpage slide is now 'forced' through the modal to 'text/html' to avoid conflit with 'image/png' when setting the cover image. Task-1902304
This commit is contained in:
@@ -144,6 +144,11 @@ var SlideUploadDialog = Dialog.extend({
|
||||
'mime_type': this.file.type,
|
||||
'datas': this.file.data
|
||||
});
|
||||
} else if (values['slide_type'] === 'webpage') {
|
||||
_.extend(values, {
|
||||
'mime_type': 'text/html',
|
||||
'image': this.file.type === 'image/svg+xml' ? this._svgToPng() : this.file.data,
|
||||
});
|
||||
} else if (/^image\/.*/.test(this.file.type)) {
|
||||
_.extend(values, {
|
||||
'slide_type': 'infographic',
|
||||
@@ -347,9 +352,12 @@ var SlideUploadDialog = Dialog.extend({
|
||||
}
|
||||
},
|
||||
_onChangeSlideUpload: function (ev) {
|
||||
var self = this;
|
||||
this._alertRemove();
|
||||
|
||||
var self = this;
|
||||
var $input = $(ev.currentTarget);
|
||||
var preventOnchange = $input.data('preventOnchange');
|
||||
|
||||
var file = ev.target.files[0];
|
||||
var isImage = /^image\/.*/.test(file.type);
|
||||
var loaded = false;
|
||||
@@ -440,9 +448,11 @@ var SlideUploadDialog = Dialog.extend({
|
||||
};
|
||||
}
|
||||
|
||||
var input = file.name;
|
||||
var inputVal = input.substr(0, input.lastIndexOf('.')) || input;
|
||||
this._formSetFieldValue('name', inputVal);
|
||||
if (!preventOnchange) {
|
||||
var input = file.name;
|
||||
var inputVal = input.substr(0, input.lastIndexOf('.')) || input;
|
||||
this._formSetFieldValue('name', inputVal);
|
||||
}
|
||||
},
|
||||
_onChangeSlideUrl: function (ev) {
|
||||
var self = this;
|
||||
|
||||
@@ -103,6 +103,26 @@
|
||||
<div>
|
||||
<form class="clearfix">
|
||||
<t t-call="website.slide.upload.modal.common"/>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-4">
|
||||
<div class="img-thumbnail">
|
||||
<div class="o_slide_preview">
|
||||
<img src="/website_slides/static/src/img/document.png" id="slide-image" title="Content Preview" alt="Content Preview" class="img-fluid"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<h5 class="list-group-item-heading">
|
||||
<label for="upload" class="col-form-label">Cover Image File</label>
|
||||
</h5>
|
||||
<input id="upload" name="file" class="form-control" accept="image/*" type="file" required="required" data-prevent-onchange="1"/>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<canvas id="data_canvas" class="d-none"></canvas>
|
||||
</form>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
|
||||
</button>
|
||||
</div>
|
||||
<field name="image" widget="image" class="oe_avatar" options='{"preview_image": "image_thumb"}' readonly="1"/>
|
||||
<field name="image" widget="image" class="oe_avatar" options='{"preview_image": "image_thumb"}' attrs="{'required': [('slide_type', 'not in', ('document'))], 'readonly': [('slide_type', 'in', ('document', 'presentation', 'video'))]}"/>
|
||||
<div class="oe_title">
|
||||
<div class="oe_edit_only">
|
||||
<label for="name" string="Name"/>
|
||||
@@ -68,8 +68,8 @@
|
||||
</page>
|
||||
<page string="Document">
|
||||
<group>
|
||||
<field name="url" attrs="{'required': [('image', '=', False)]}"/>
|
||||
<field name="slide_type" readonly="1"/>
|
||||
<field name="url" attrs="{'required': [('slide_type', 'in', ('document', 'video'))], 'readonly': [('slide_type', 'in', ('document', 'video'))]}"/>
|
||||
<field name="document_id" readonly="1" attrs="{'invisible': [('document_id', '=', False)]}"/>
|
||||
<field name="mime_type" readonly="1"/>
|
||||
<field name="datas" readonly="1"/>
|
||||
|
||||
Reference in New Issue
Block a user