[MIG] Migrate web_widget_mermaid to 12.0

pull/1442/head
Jan Verbeek 2019-10-22 18:02:46 +02:00 committed by Dennis Sluijk
parent 6d984024af
commit 41cc599d92
8 changed files with 89 additions and 112 deletions

View File

@ -14,13 +14,13 @@ Mermaid flowchart widget
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/10.0/web_widget_mermaid
:target: https://github.com/OCA/web/tree/12.0/web_widget_mermaid
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-10-0/web-10-0-web_widget_mermaid
:target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_mermaid
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/10.0
:target: https://runbot.odoo-community.org/runbot/162/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -60,7 +60,7 @@ As an example, this text::
Produces this flowchart:
.. image:: https://raw.githubusercontent.com/OCA/web/10.0/web_widget_mermaid/static/description/flowchart_example.png
.. image:: https://raw.githubusercontent.com/OCA/web/12.0/web_widget_mermaid/static/description/flowchart_example.png
:alt: Flowchart
Demonstration
@ -101,7 +101,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_mermaid%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_mermaid%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -131,6 +131,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/10.0/web_widget_mermaid>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/12.0/web_widget_mermaid>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1 +1 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
@ -6,7 +5,7 @@
"name": "Mermaid flowchart widget",
"category": "Web",
"author": "Therp BV,Odoo Community Association (OCA)",
"version": "10.0.8.4.0",
"version": "12.0.8.4.0",
"license": "AGPL-3",
"summary": "Render mermaid markdown flowcharts",
"website": "https://github.com/OCA/web",
@ -14,13 +13,6 @@
"data": [
"view/web_widget_mermaid_view.xml",
],
"js": [
"static/lib/mermaid/mermaid.js",
"static/src/js/web_widget_mermaid.js",
],
"qweb": [
"static/src/xml/web_widget_mermaid.xml",
],
"demo": [
"demo/res_users_flowchart.xml",
],

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/10.0/web_widget_mermaid"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-10-0/web-10-0-web_widget_mermaid"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/10.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_widget_mermaid"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_mermaid"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds a basic widget for rendering text fields as flowcharts using
<a class="reference external" href="https://mermaidjs.github.io">mermaid</a>.</p>
<p><strong>Table of contents</strong></p>
@ -409,7 +409,7 @@ graph LR
12.0 -.-&gt; 13.0
</pre>
<p>Produces this flowchart:</p>
<img alt="Flowchart" src="https://raw.githubusercontent.com/OCA/web/10.0/web_widget_mermaid/static/description/flowchart_example.png" />
<img alt="Flowchart" src="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_mermaid/static/description/flowchart_example.png" />
</div>
<div class="section" id="demonstration">
<h1><a class="toc-backref" href="#id2">Demonstration</a></h1>
@ -455,7 +455,7 @@ targets: {
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_mermaid%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_mermaid%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -479,7 +479,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/10.0/web_widget_mermaid">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_widget_mermaid">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -2,7 +2,8 @@ odoo.define('web.web_widget_mermaid', function(require) {
"use strict";
var core = require('web.core');
var form_widgets = require('web.form_widgets');
var basic_fields = require('web.basic_fields');
var field_registry = require('web.field_registry');
// Calling mermaid.initialize() multiple times is ok.
// But there's a catch: it will keep the config of previous calls unless
@ -53,35 +54,31 @@ odoo.define('web.web_widget_mermaid', function(require) {
fontFamily: '"Lucida Grande", Helvetica, Verdana, Arial, '
+ 'sans-serif', // Match Odoo's font choices
numberSectionStyles: 4,
// Match configured date format
axisFormat: core._t.database.parameters.date_format,
}
};
var MermaidField = form_widgets.FieldChar.extend({
var MermaidField = basic_fields.FieldText.extend({
init: function() {
this._super.apply(this, arguments);
this.chartId = _.uniqueId('mermaid_chart_');
},
template: "MermaidField",
widget_class: 'o_form_field_mermaid',
render_value: function() {
if (!this.get('effective_readonly')) {
return this._super();
}
var value = this.get('value');
if (!value) {
className: 'o_form_field_mermaid',
_renderReadonly: function() {
if (!this.value) {
return;
}
var config = _.extend(
{},
defaultConfig,
this.options
this.attrs.options
);
mermaid.mermaidAPI.initialize(config);
try {
mermaid.mermaidAPI.render(
this.chartId,
value,
this.value,
this.$el.html.bind(this.$el)
);
} catch (e) {
@ -92,9 +89,9 @@ odoo.define('web.web_widget_mermaid', function(require) {
// rid of it if it's still around. The id is based on the chartId.
$('#d' + this.chartId).remove();
}
})
});
core.form_widget_registry.add('mermaid', MermaidField);
field_registry.add('mermaid', MermaidField);
return {
MermaidField: MermaidField,

View File

@ -8,43 +8,43 @@
.o_form_field_mermaid .node .label {
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
color: @label-color; }
color: $o-tooltip-color; }
.o_form_field_mermaid .cluster .label {
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
color: @odoo-main-text-color; }
color: $o-main-text-color; }
.o_form_field_mermaid .label text {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid .node rect,
.o_form_field_mermaid .node circle,
.o_form_field_mermaid .node ellipse,
.o_form_field_mermaid .node polygon {
fill: @odoo-brand-primary;
stroke: @odoo-brand-optional;
fill: $o-brand-primary;
stroke: $o-brand-primary;
stroke-width: 1px; }
.o_form_field_mermaid .node.clickable {
cursor: pointer; }
.o_form_field_mermaid .arrowheadPath {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid .edgePath .path {
stroke: @odoo-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1.5px; }
.o_form_field_mermaid .edgeLabel {
background-color: #e8e8e8; }
.o_form_field_mermaid .cluster rect {
fill: @odoo-brand-secondary;
stroke: @odoo-main-color-muted;
fill: $o-brand-secondary;
stroke: $o-main-color-muted;
stroke-width: 1px; }
.o_form_field_mermaid .cluster text {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid div.mermaidTooltip {
position: absolute;
@ -53,15 +53,15 @@
padding: 2px;
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
font-size: 12px;
background: @odoo-brand-secondary;
border: 1px solid @odoo-main-color-muted;
background: $o-brand-secondary;
border: 1px solid $o-main-color-muted;
border-radius: 2px;
pointer-events: none;
z-index: 100; }
.o_form_field_mermaid .actor {
stroke: @odoo-brand-optional;
fill: @odoo-brand-primary; }
stroke: $o-brand-primary;
fill: $o-brand-primary; }
.o_form_field_mermaid text.actor {
fill: white;
@ -73,33 +73,33 @@
.o_form_field_mermaid .messageLine0 {
stroke-width: 1.5;
stroke-dasharray: '2 2';
stroke: @odoo-main-text-color; }
stroke: $o-main-text-color; }
.o_form_field_mermaid .messageLine1 {
stroke-width: 1.5;
stroke-dasharray: '2 2';
stroke: @odoo-main-text-color; }
stroke: $o-main-text-color; }
.o_form_field_mermaid #arrowhead {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid .sequenceNumber {
fill: white; }
.o_form_field_mermaid #sequencenumber {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid #crosshead path {
fill: @odoo-main-text-color !important;
stroke: @odoo-main-text-color !important; }
fill: $o-main-text-color !important;
stroke: $o-main-text-color !important; }
.o_form_field_mermaid .messageText {
fill: @odoo-main-text-color;
fill: $o-main-text-color;
stroke: none; }
.o_form_field_mermaid .labelBox {
stroke: @odoo-brand-optional;
fill: @odoo-brand-primary; }
stroke: $o-brand-primary;
fill: $o-brand-primary; }
.o_form_field_mermaid .labelText {
fill: white;
@ -112,10 +112,10 @@
.o_form_field_mermaid .loopLine {
stroke-width: 2;
stroke-dasharray: '2 2';
stroke: @odoo-brand-optional; }
stroke: $o-brand-primary; }
.o_form_field_mermaid .note {
stroke: @odoo-main-color-muted;
stroke: $o-main-color-muted;
fill: #fff5ad; }
.o_form_field_mermaid .noteText {
@ -153,16 +153,16 @@
opacity: 0.2; }
.o_form_field_mermaid .sectionTitle0 {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid .sectionTitle1 {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid .sectionTitle2 {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid .sectionTitle3 {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid .sectionTitle {
text-anchor: start;
@ -194,12 +194,12 @@
font-size: 11px; }
.o_form_field_mermaid .taskTextOutsideRight {
fill: @odoo-main-text-color;
fill: $o-main-text-color;
text-anchor: start;
font-size: 11px; }
.o_form_field_mermaid .taskTextOutsideLeft {
fill: @odoo-main-text-color;
fill: $o-main-text-color;
text-anchor: end;
font-size: 11px; }
@ -233,16 +233,16 @@
.o_form_field_mermaid .task1,
.o_form_field_mermaid .task2,
.o_form_field_mermaid .task3 {
fill: @odoo-brand-primary;
stroke: @odoo-brand-primary; }
fill: $o-brand-primary;
stroke: $o-brand-primary; }
.o_form_field_mermaid .taskTextOutside0,
.o_form_field_mermaid .taskTextOutside2 {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid .taskTextOutside1,
.o_form_field_mermaid .taskTextOutside3 {
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
/* Active task */
.o_form_field_mermaid .active0,
@ -250,13 +250,13 @@
.o_form_field_mermaid .active2,
.o_form_field_mermaid .active3 {
fill: #bfc7ff;
stroke: @odoo-brand-primary; }
stroke: $o-brand-primary; }
.o_form_field_mermaid .activeText0,
.o_form_field_mermaid .activeText1,
.o_form_field_mermaid .activeText2,
.o_form_field_mermaid .activeText3 {
fill: @odoo-main-text-color !important; }
fill: $o-main-text-color !important; }
/* Completed task */
.o_form_field_mermaid .done0,
@ -271,7 +271,7 @@
.o_form_field_mermaid .doneText1,
.o_form_field_mermaid .doneText2,
.o_form_field_mermaid .doneText3 {
fill: @odoo-main-text-color !important; }
fill: $o-main-text-color !important; }
/* Tasks on the critical line */
.o_form_field_mermaid .crit0,
@ -310,18 +310,18 @@
.o_form_field_mermaid .doneCritText1,
.o_form_field_mermaid .doneCritText2,
.o_form_field_mermaid .doneCritText3 {
fill: @odoo-main-text-color !important; }
fill: $o-main-text-color !important; }
.o_form_field_mermaid .activeCritText0,
.o_form_field_mermaid .activeCritText1,
.o_form_field_mermaid .activeCritText2,
.o_form_field_mermaid .activeCritText3 {
fill: @odoo-main-text-color !important; }
fill: $o-main-text-color !important; }
.o_form_field_mermaid .titleText {
text-anchor: middle;
font-size: 18px;
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }
.o_form_field_mermaid g.classGroup text {
fill: white;
@ -330,74 +330,74 @@
font-size: 10px; }
.o_form_field_mermaid g.classGroup rect {
fill: @odoo-brand-primary;
stroke: @odoo-main-text-color; }
fill: $o-brand-primary;
stroke: $o-main-text-color; }
.o_form_field_mermaid g.classGroup line {
stroke: @odoo-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid .classLabel .box {
stroke: none;
stroke-width: 0;
fill: @odoo-brand-primary;
fill: $o-brand-primary;
opacity: 0.5; }
.o_form_field_mermaid .classLabel .label {
fill: @odoo-main-text-color;
fill: $o-main-text-color;
font-size: 10px;
font-weight: normal; }
.o_form_field_mermaid .relation {
stroke: @odoo-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1;
fill: none; }
.o_form_field_mermaid #compositionStart {
fill: @odoo-main-text-color;
stroke: @odoo-main-text-color;
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #compositionEnd {
fill: @odoo-main-text-color;
stroke: @odoo-main-text-color;
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #aggregationStart {
fill: @odoo-brand-primary;
stroke: @odoo-main-text-color;
fill: $o-brand-primary;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #aggregationEnd {
fill: @odoo-brand-primary;
stroke: @odoo-main-text-color;
fill: $o-brand-primary;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #dependencyStart {
fill: @odoo-main-text-color;
stroke: @odoo-main-text-color;
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #dependencyEnd {
fill: @odoo-main-text-color;
stroke: @odoo-main-text-color;
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #extensionStart {
fill: @odoo-main-text-color;
stroke: @odoo-main-text-color;
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #extensionEnd {
fill: @odoo-main-text-color;
stroke: @odoo-main-text-color;
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid .commit-id,
.o_form_field_mermaid .commit-msg,
.o_form_field_mermaid .branch-label {
fill: lightgrey;
color: @odoo-main-text-color; }
color: $o-main-text-color; }
.o_form_field_mermaid .node-label p {
margin-top: 9px; }
@ -405,4 +405,4 @@
.o_form_field_mermaid .pieTitleText {
text-anchor: middle;
font-size: 25px;
fill: @odoo-main-text-color; }
fill: $o-main-text-color; }

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="MermaidField">
<t t-if="widget.get('effective_readonly')">
<span t-att-class="'o_form_field '+widget.widget_class" t-att-style="widget.node.attrs.style" />
</t>
<t t-if="!widget.get('effective_readonly')">
<t t-call="FieldText"/>
</t>
</t>
</templates>

View File

@ -4,7 +4,7 @@
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_widget_mermaid/static/lib/mermaid/mermaid.js"></script>
<script type="text/javascript" src="/web_widget_mermaid/static/src/js/web_widget_mermaid.js"></script>
<link rel="stylesheet" type="text/less" href="/web_widget_mermaid/static/src/less/web_widget_mermaid_default_theme.less"/>
<link rel="stylesheet" type="text/scss" href="/web_widget_mermaid/static/src/scss/web_widget_mermaid_default_theme.scss"/>
</xpath>
</template>
</odoo>