[IMP] website_sale: migrate video_preview field to owl

This commit migrates the `video_preview` field to owl.

closes odoo/odoo#98819

Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
William Braeckman
2022-08-25 04:21:17 +02:00
parent 719e028640
commit e1b32bcc8b
2 changed files with 9 additions and 28 deletions
@@ -1,29 +1,10 @@
odoo.define('website_sale.video_field_preview', function (require) {
"use strict";
/** @odoo-module **/
import { registry } from "@web/core/registry";
var AbstractField = require('web.AbstractField');
var core = require('web.core');
const {Markup} = require('web.utils');
var fieldRegistry = require('web.field_registry');
const { Component } = owl;
var QWeb = core.qweb;
export class FieldVideoPreview extends Component {}
FieldVideoPreview.template = 'website_sale.FieldVideoPreview';
/**
* Displays preview of the video showcasing product.
*/
var FieldVideoPreview = AbstractField.extend({
className: 'd-block o_field_video_preview',
_render: function () {
this.$el.html(QWeb.render('productVideo', {
embedCode: Markup(this.value),
}));
},
});
fieldRegistry.add('video_preview', FieldVideoPreview);
return FieldVideoPreview;
});
registry.category("fields").add("video_preview", FieldVideoPreview);
@@ -2,9 +2,9 @@
<templates xml:space="preserve">
<t t-name="productVideo">
<div class="ratio ratio-16x9 mt-2" t-if="embedCode">
<t t-out="embedCode"/>
<t t-name="website_sale.FieldVideoPreview" owl="1">
<div class="ratio ratio-16x9 mt-2" t-if="props.value">
<t t-out="props.value"/>
</div>
</t>