Skip to content

Commit

Permalink
[MIG] web_widget_mpld3_chart: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lef-adhoc committed Nov 23, 2024
1 parent f0bf43a commit 6b61e16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion web_widget_mpld3_chart/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"category": "Hidden",
"summary": "This widget allows to display charts using MPLD3 library.",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"data": [],
Expand Down
16 changes: 10 additions & 6 deletions web_widget_mpld3_chart/static/src/js/web_widget_mpld3_chart.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import {loadBundle} from "@web/core/assets";
import {registry} from "@web/core/registry";
const {onWillStart, markup, Component, onMounted, onPatched, useRef} = owl;
import { onWillStart, markup, Component, onMounted, onPatched, useRef } from "@odoo/owl";

class Mpld3ChartJsonWidget extends Component {
export default class Mpld3ChartJsonWidget extends Component {
setup() {
this.widget = useRef("widget");
onPatched(() => {
var script = document.createElement("script");
script.text = this.props.value.script;
script.text = this.props.record.data[this.props.name].script;
this.widget.el.append(script);
});
onMounted(() => {
var script = document.createElement("script");
script.text = this.props.value.script;
script.text = this.props.record.data[this.props.name].script;
this.widget.el.append(script);
});
onWillStart(() =>
Expand All @@ -31,7 +31,11 @@ class Mpld3ChartJsonWidget extends Component {
return markup(value);
}
}

Mpld3ChartJsonWidget.template = "web_widget_mpld3_chart.Mpld3ChartJsonWidget";
registry.category("fields").add("mpld3_chart", Mpld3ChartJsonWidget);

export default Mpld3ChartJsonWidget;
export const mpld3ChartJsonWidget = {
component: Mpld3ChartJsonWidget,
};

registry.category("fields").add("mpld3_chart", mpld3ChartJsonWidget);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<div t-ref="widget" t-name="web_widget_mpld3_chart.Mpld3ChartJsonWidget" owl="1">
<t t-if="props.value.div" t-out="markup(props.value.div)" />
<div t-ref="widget" t-name="web_widget_mpld3_chart.Mpld3ChartJsonWidget">
<t t-if="this.props.record.data[this.props.name].div" t-out="markup(this.props.record.data[this.props.name].div)" />
</div>
</templates>

0 comments on commit 6b61e16

Please sign in to comment.