[MIG] web_widget_bokeh_chart: Migration to 16.0

This commit is contained in:
OriolMForgeFlow
2023-06-06 13:48:46 +02:00
parent c6e2c390dd
commit 4639a13698
18 changed files with 1451 additions and 1334 deletions

View File

@@ -1,32 +1,32 @@
/** @odoo-module **/
import basicFields from "web.basic_fields";
import fieldRegistry from "web.field_registry";
const BokehChartWidget = basicFields.FieldChar.extend({
jsLibs: [
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-2.4.2.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-api-2.4.2.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-widgets-2.4.2.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-tables-2.4.2.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-mathjax-2.4.2.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-gl-2.4.2.min.js",
],
_renderReadonly: function () {
try {
const val = JSON.parse(this.value);
this.$el.html(val.div);
const script = document.createElement("script");
script.setAttribute("type", "text/javascript");
if ("textContent" in script) script.textContent = val.script;
else script.text = val.script;
this.$el.append(script);
} catch (error) {
return this._super(...arguments);
}
},
});
fieldRegistry.add("bokeh_chart", BokehChartWidget);
import {CharField} from "@web/views/fields/char/char_field";
import {registry} from "@web/core/registry";
import {loadBundle} from "@web/core/assets";
const {onWillStart, markup} = owl;
class BokehChartWidget extends CharField {
setup() {
super.setup();
onWillStart(() =>
loadBundle({
jsLibs: [
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-3.1.1.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-api-3.1.1.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-widgets-3.1.1.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-tables-3.1.1.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-mathjax-3.1.1.min.js",
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-gl-3.1.1.min.js",
],
})
);
}
get json_value() {
var value = JSON.parse(this.props.value);
value.div = markup(value.div.trim());
return value;
}
}
BokehChartWidget.template = "web_widget_bokeh_chart.BokehChartField";
registry.category("fields").add("bokeh_chart", BokehChartWidget);
export default BokehChartWidget;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="web_widget_bokeh_chart.BokehChartField" owl="1">
<t t-out="json_value.div" />
<script type="text/javascript" t-out="json_value.script" />
</t>
</templates>