[ADD/MIG]Migrated the module web_widget_mermaid in v14.

pull/1944/head
HemanginiPatel 2021-06-04 18:24:56 +05:30 committed by Murtaza Mithaiwala
parent fad16e8bb8
commit b87dec09e4
18 changed files with 1394 additions and 0 deletions

View File

@ -0,0 +1,136 @@
========================
Mermaid flowchart widget
========================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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/14.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-14-0/web-14-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/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module adds a basic widget for rendering text fields as flowcharts using
`mermaid <https://mermaidjs.github.io>`_.
**Table of contents**
.. contents::
:local:
Usage
=====
Put a ``widget="mermaid"`` attribute in relevant field tags in the view
declaration::
<field name="flowchart" widget="mermaid"/>
Optionally, use an ``options`` attribute to pass a JSON object with
`mermaid configuration <https://mermaidjs.github.io/#/mermaidAPI?id=configuration>`_::
<field name="flowchart"
widget="mermaid"
options='{"theme": "forest", "gantt": {"fontSize": 14}}'/>
The syntax for creating diagrams is described in
`mermaid's documentation <https://mermaidjs.github.io/#/flowchart>`_.
As an example, this text::
graph LR
10.0 --> 11.0
11.0 --> 12.0
12.0 -.-> 13.0
Produces this flowchart:
.. image:: https://raw.githubusercontent.com/OCA/web/14.0/web_widget_mermaid/static/description/flowchart_example.png
:alt: Flowchart
Demonstration
=============
In demo mode, the addon adds a flowchart field to users so you can try it. This shows up in Runbot instances.
Upgrading Mermaid
=================
This information is only relevant for the development of this addon, not for users.
This addon uses a slightly tweaked build of Mermaid that works in older browsers. To reproduce it, take the following steps:
- Clone ``https://github.com/knsv/mermaid/``
- Checkout the version you want to upgrade to (e.g. ``git checkout 8.4.0``)
- In ``webpack.config.base.js``, in ``const jsRule = ...``, remove the ``include`` key (so all dependencies are transpiled)
- In ``babel.config.js``, in ``targets``, add some browsers besides ``node: 'current'``. I arbitrarily went with this::
targets: {
node: 'current',
ie: '11',
edge: '20',
firefox: '35',
chrome: '45',
safari: '9',
}
- Run ``yarn install``
- Run ``yarn build``
- The completed file is now in ``dist/mermaid.js``. Try running ``grep 'let ' dist/mermaid.js`` to make sure everything was transpiled. The only output should be from comments.
- Copy ``dist/mermaid.js`` to ``web_widget_mermaid/static/lib/mermaid/mermaid.js``.
- Bump the version number in ``__manifest__.py`` to match the Mermaid version.
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:%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.
Credits
=======
Authors
~~~~~~~
* Therp BV
Contributors
~~~~~~~~~~~~
* Jan Verbeek <jverbeek@therp.nl>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
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/14.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

@ -0,0 +1 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

View File

@ -0,0 +1,19 @@
# Copyright 2019 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
{
"name": "Mermaid flowchart widget",
"category": "Web",
"author": "Therp BV,Odoo Community Association (OCA)",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"summary": "Render mermaid markdown flowcharts",
"website": "https://github.com/OCA/web",
"depends": ['web'],
"data": [
"view/web_widget_mermaid_view.xml",
],
"demo": [
"demo/res_users_flowchart.xml",
],
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="res_users_flowchart" model="ir.model.fields">
<field name="name">x_flowchart</field>
<field name="model_id" ref="base.model_res_users" />
<field name="field_description">Demo mermaid flowchart</field>
<field name="ttype">char</field>
</record>
<record id="view_users_form_flowchart" model="ir.ui.view">
<field name="inherit_id" ref="base.view_users_form" />
<field name="model">res.users</field>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page name="mermaid_page" string="Mermaid flowchart">
<field name="x_flowchart" widget="mermaid" />
</page>
</xpath>
</field>
</record>
<record id="base.user_demo" model="res.users">
<field name="x_flowchart">graph TD
A[This is an example flowchart] --> B{{Edit it}}
B -. save it .-> C(See what happens)</field>
</record>
</odoo>

View File

@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_mermaid
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-02-17 13:45+0000\n"
"Last-Translator: claudiagn <claudia.gargallo@qubiq.es>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_widget_mermaid
#: model:ir.model.fields,field_description:web_widget_mermaid.res_users_flowchart
msgid "Demo mermaid flowchart"
msgstr "Diagrama de flux de sirena de demostració"
#. module: web_widget_mermaid
#: model_terms:ir.ui.view,arch_db:web_widget_mermaid.view_users_form_flowchart
msgid "Mermaid flowchart"
msgstr "Diagrama de flux de sirena"

View File

@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_mermaid
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2020-09-16 14:00+0000\n"
"Last-Translator: claudiagn <claudia.gargallo@qubiq.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.10\n"
#. module: web_widget_mermaid
#: model:ir.model.fields,field_description:web_widget_mermaid.res_users_flowchart
msgid "Demo mermaid flowchart"
msgstr "Diagrama de flujo de sirena de demostración"
#. module: web_widget_mermaid
#: model_terms:ir.ui.view,arch_db:web_widget_mermaid.view_users_form_flowchart
msgid "Mermaid flowchart"
msgstr "Diagrama de flujo de sirena"

View File

@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_mermaid
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-02-01 12:44+0000\n"
"Last-Translator: Yann Papouin <y.papouin@dec-industrie.com>\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_widget_mermaid
#: model:ir.model.fields,field_description:web_widget_mermaid.res_users_flowchart
msgid "Demo mermaid flowchart"
msgstr "Organigramme de démonstration Mermaid"
#. module: web_widget_mermaid
#: model_terms:ir.ui.view,arch_db:web_widget_mermaid.view_users_form_flowchart
msgid "Mermaid flowchart"
msgstr "Organigramme Mermaid"

View File

@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_mermaid
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-03-15 06:45+0000\n"
"Last-Translator: Marcel Savegnago <marcel.savegnago@gmail.com>\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_widget_mermaid
#: model:ir.model.fields,field_description:web_widget_mermaid.res_users_flowchart
msgid "Demo mermaid flowchart"
msgstr "Fluxograma de demonstração do mermaid"
#. module: web_widget_mermaid
#: model_terms:ir.ui.view,arch_db:web_widget_mermaid.view_users_form_flowchart
msgid "Mermaid flowchart"
msgstr "Fluxograma Mermaid"

View File

@ -0,0 +1,25 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_mermaid
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: web_widget_mermaid
#: model:ir.model.fields,field_description:web_widget_mermaid.res_users_flowchart
msgid "Demo mermaid flowchart"
msgstr ""
#. module: web_widget_mermaid
#: model_terms:ir.ui.view,arch_db:web_widget_mermaid.view_users_form_flowchart
msgid "Mermaid flowchart"
msgstr ""

View File

@ -0,0 +1 @@
* Jan Verbeek <jverbeek@therp.nl>

View File

@ -0,0 +1,2 @@
This module adds a basic widget for rendering text fields as flowcharts using
`mermaid <https://mermaidjs.github.io>`_.

View File

@ -0,0 +1,58 @@
Put a ``widget="mermaid"`` attribute in relevant field tags in the view
declaration::
<field name="flowchart" widget="mermaid"/>
Optionally, use an ``options`` attribute to pass a JSON object with
`mermaid configuration <https://mermaidjs.github.io/#/mermaidAPI?id=configuration>`_::
<field name="flowchart"
widget="mermaid"
options='{"theme": "forest", "gantt": {"fontSize": 14}}'/>
The syntax for creating diagrams is described in
`mermaid's documentation <https://mermaidjs.github.io/#/flowchart>`_.
As an example, this text::
graph LR
10.0 --> 11.0
11.0 --> 12.0
12.0 -.-> 13.0
Produces this flowchart:
.. image:: ./static/description/flowchart_example.png
:alt: Flowchart
Demonstration
=============
In demo mode, the addon adds a flowchart field to users so you can try it. This shows up in Runbot instances.
Upgrading Mermaid
=================
This information is only relevant for the development of this addon, not for users.
This addon uses a slightly tweaked build of Mermaid that works in older browsers. To reproduce it, take the following steps:
- Clone ``https://github.com/knsv/mermaid/``
- Checkout the version you want to upgrade to (e.g. ``git checkout 8.4.0``)
- In ``webpack.config.base.js``, in ``const jsRule = ...``, remove the ``include`` key (so all dependencies are transpiled)
- In ``babel.config.js``, in ``targets``, add some browsers besides ``node: 'current'``. I arbitrarily went with this::
targets: {
node: 'current',
ie: '11',
edge: '20',
firefox: '35',
chrome: '45',
safari: '9',
}
- Run ``yarn install``
- Run ``yarn build``
- The completed file is now in ``dist/mermaid.js``. Try running ``grep 'let ' dist/mermaid.js`` to make sure everything was transpiled. The only output should be from comments.
- Copy ``dist/mermaid.js`` to ``web_widget_mermaid/static/lib/mermaid/mermaid.js``.
- Bump the version number in ``__manifest__.py`` to match the Mermaid version.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -0,0 +1,488 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>Mermaid flowchart widget</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="mermaid-flowchart-widget">
<h1 class="title">Mermaid flowchart widget</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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/14.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-14-0/web-14-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/14.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>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#demonstration" id="id2">Demonstration</a></li>
<li><a class="reference internal" href="#upgrading-mermaid" id="id3">Upgrading Mermaid</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>Put a <tt class="docutils literal"><span class="pre">widget=&quot;mermaid&quot;</span></tt> attribute in relevant field tags in the view
declaration:</p>
<pre class="literal-block">
&lt;field name=&quot;flowchart&quot; widget=&quot;mermaid&quot;/&gt;
</pre>
<p>Optionally, use an <tt class="docutils literal">options</tt> attribute to pass a JSON object with
<a class="reference external" href="https://mermaidjs.github.io/#/mermaidAPI?id=configuration">mermaid configuration</a>:</p>
<pre class="literal-block">
&lt;field name=&quot;flowchart&quot;
widget=&quot;mermaid&quot;
options='{&quot;theme&quot;: &quot;forest&quot;, &quot;gantt&quot;: {&quot;fontSize&quot;: 14}}'/&gt;
</pre>
<p>The syntax for creating diagrams is described in
<a class="reference external" href="https://mermaidjs.github.io/#/flowchart">mermaids documentation</a>.</p>
<p>As an example, this text:</p>
<pre class="literal-block">
graph LR
10.0 --&gt; 11.0
11.0 --&gt; 12.0
12.0 -.-&gt; 13.0
</pre>
<p>Produces this flowchart:</p>
<img alt="Flowchart" src="https://raw.githubusercontent.com/OCA/web/14.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>
<p>In demo mode, the addon adds a flowchart field to users so you can try it. This shows up in Runbot instances.</p>
</div>
<div class="section" id="upgrading-mermaid">
<h1><a class="toc-backref" href="#id3">Upgrading Mermaid</a></h1>
<p>This information is only relevant for the development of this addon, not for users.</p>
<p>This addon uses a slightly tweaked build of Mermaid that works in older browsers. To reproduce it, take the following steps:</p>
<ul>
<li><p class="first">Clone <tt class="docutils literal"><span class="pre">https://github.com/knsv/mermaid/</span></tt></p>
</li>
<li><p class="first">Checkout the version you want to upgrade to (e.g. <tt class="docutils literal">git checkout 8.4.0</tt>)</p>
</li>
<li><p class="first">In <tt class="docutils literal">webpack.config.base.js</tt>, in <tt class="docutils literal">const jsRule = ...</tt>, remove the <tt class="docutils literal">include</tt> key (so all dependencies are transpiled)</p>
</li>
<li><p class="first">In <tt class="docutils literal">babel.config.js</tt>, in <tt class="docutils literal">targets</tt>, add some browsers besides <tt class="docutils literal">node: 'current'</tt>. I arbitrarily went with this:</p>
<pre class="literal-block">
targets: {
node: 'current',
ie: '11',
edge: '20',
firefox: '35',
chrome: '45',
safari: '9',
}
</pre>
</li>
<li><p class="first">Run <tt class="docutils literal">yarn install</tt></p>
</li>
<li><p class="first">Run <tt class="docutils literal">yarn build</tt></p>
</li>
<li><p class="first">The completed file is now in <tt class="docutils literal">dist/mermaid.js</tt>. Try running <tt class="docutils literal">grep 'let ' dist/mermaid.js</tt> to make sure everything was transpiled. The only output should be from comments.</p>
</li>
<li><p class="first">Copy <tt class="docutils literal">dist/mermaid.js</tt> to <tt class="docutils literal">web_widget_mermaid/static/lib/mermaid/mermaid.js</tt>.</p>
</li>
<li><p class="first">Bump the version number in <tt class="docutils literal">__manifest__.py</tt> to match the Mermaid version.</p>
</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<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:%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">
<h1><a class="toc-backref" href="#id5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id6">Authors</a></h2>
<ul class="simple">
<li>Therp BV</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id7">Contributors</a></h2>
<ul class="simple">
<li>Jan Verbeek &lt;<a class="reference external" href="mailto:jverbeek&#64;therp.nl">jverbeek&#64;therp.nl</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<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/14.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>
</div>
</body>
</html>

View File

@ -0,0 +1,113 @@
odoo.define('web.web_widget_mermaid', function(require) {
"use strict";
var core = require('web.core');
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
// explicitly overridden, instead of reverting to the default settings.
// Therefore we make the default config explicit. This is taken from
// https://mermaidjs.github.io/#/mermaidAPI?id=mermaidapi-configuration-defaults
// so try copying from there if you update to a new version of mermaid
// with new options/defaults.
// Changes to the original default are marked with comments.
var defaultConfig = {
theme: null, // We define a custom Odoo theme in a stylesheet
logLevel: 'fatal',
securityLevel: 'strict',
startOnLoad: false, // Rendering is initiated manually
arrowMarkerAbsolute: false,
flowchart: {
htmlLabels: true,
curve: 'linear',
},
sequence: {
diagramMarginX: 50,
diagramMarginY: 10,
actorMargin: 50,
width: 150,
height: 65,
boxMargin: 10,
boxTextMargin: 5,
noteMargin: 10,
messageMargin: 35,
mirrorActors: true,
bottomMarginAdj: 1,
useMaxWidth: true,
rightAngles: false,
showSequenceNumbers: false,
},
gantt: {
titleTopMargin: 25,
barHeight: 20,
barGap: 4,
topPadding: 50,
leftPadding: 75,
gridLineStartPadding: 35,
fontSize: 11,
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 = basic_fields.FieldText.extend({
init: function() {
this._super.apply(this, arguments);
this.chartId = _.uniqueId('mermaid_chart_');
},
className: 'o_form_field_mermaid',
_renderReadonly: function() {
if (!this.value) {
return;
}
var config = _.extend(
{},
defaultConfig,
this.attrs.options
);
mermaid.mermaidAPI.initialize(config);
try {
mermaid.mermaidAPI.render(
this.chartId,
this.value,
this.$el.html.bind(this.$el)
);
} catch (e) {
this.$el.html($('<pre/>').text(e.message || e.str));
}
// Mermaid uses a temporary div for rendering. It doesn't remove
// it if an error occurs, and perhaps in other cases too, so get
// rid of it if it's still around. The id is based on the chartId.
$('#d' + this.chartId).remove();
},
_parseValue: function(value) {
if (this.errorMessage) {
this.errorMessage.remove();
}
try {
mermaid.parse(value);
} catch (e) {
this.errorMessage = $('<pre/>').text(e.message || e.str);
this.$el.after(this.errorMessage);
throw e;
}
return value;
},
});
field_registry.add('mermaid', MermaidField);
return {
MermaidField: MermaidField,
defaultConfig: defaultConfig,
};
});

View File

@ -0,0 +1,408 @@
.o_form_field_mermaid .label {
font-size: inherit;
font-weight: inherit;
line-height: inherit;
text-align: inherit;
color: inherit;
}
.o_form_field_mermaid .node .label {
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
color: $o-tooltip-color; }
.o_form_field_mermaid .cluster .label {
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
color: $o-main-text-color; }
.o_form_field_mermaid .label text {
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: $o-brand-primary;
stroke: $o-brand-primary;
stroke-width: 1px; }
.o_form_field_mermaid .node.clickable {
cursor: pointer; }
.o_form_field_mermaid .arrowheadPath {
fill: $o-main-text-color; }
.o_form_field_mermaid .edgePath .path {
stroke: $o-main-text-color;
stroke-width: 1.5px; }
.o_form_field_mermaid .edgeLabel {
background-color: #e8e8e8; }
.o_form_field_mermaid .cluster rect {
fill: $o-brand-secondary;
stroke: $o-main-color-muted;
stroke-width: 1px; }
.o_form_field_mermaid .cluster text {
fill: $o-main-text-color; }
.o_form_field_mermaid div.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
font-size: 12px;
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: $o-brand-primary;
fill: $o-brand-primary; }
.o_form_field_mermaid text.actor {
fill: white;
stroke: none; }
.o_form_field_mermaid .actor-line {
stroke: grey; }
.o_form_field_mermaid .messageLine0 {
stroke-width: 1.5;
stroke-dasharray: '2 2';
stroke: $o-main-text-color; }
.o_form_field_mermaid .messageLine1 {
stroke-width: 1.5;
stroke-dasharray: '2 2';
stroke: $o-main-text-color; }
.o_form_field_mermaid #arrowhead {
fill: $o-main-text-color; }
.o_form_field_mermaid .sequenceNumber {
fill: white; }
.o_form_field_mermaid #sequencenumber {
fill: $o-main-text-color; }
.o_form_field_mermaid #crosshead path {
fill: $o-main-text-color !important;
stroke: $o-main-text-color !important; }
.o_form_field_mermaid .messageText {
fill: $o-main-text-color;
stroke: none; }
.o_form_field_mermaid .labelBox {
stroke: $o-brand-primary;
fill: $o-brand-primary; }
.o_form_field_mermaid .labelText {
fill: white;
stroke: none; }
.o_form_field_mermaid .loopText {
fill: white;
stroke: none; }
.o_form_field_mermaid .loopLine {
stroke-width: 2;
stroke-dasharray: '2 2';
stroke: $o-brand-primary; }
.o_form_field_mermaid .note {
stroke: $o-main-color-muted;
fill: #fff5ad; }
.o_form_field_mermaid .noteText {
fill: black;
stroke: none;
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
font-size: 14px; }
.o_form_field_mermaid .activation0 {
fill: #f4f4f4;
stroke: #666; }
.o_form_field_mermaid .activation1 {
fill: #f4f4f4;
stroke: #666; }
.o_form_field_mermaid .activation2 {
fill: #f4f4f4;
stroke: #666; }
/** Section styling */
.o_form_field_mermaid .section {
stroke: none;
opacity: 0.2; }
.o_form_field_mermaid .section0 {
fill: rgba(102, 102, 255, 0.49); }
.o_form_field_mermaid .section2 {
fill: #fff400; }
.o_form_field_mermaid .section1,
.o_form_field_mermaid .section3 {
fill: white;
opacity: 0.2; }
.o_form_field_mermaid .sectionTitle0 {
fill: $o-main-text-color; }
.o_form_field_mermaid .sectionTitle1 {
fill: $o-main-text-color; }
.o_form_field_mermaid .sectionTitle2 {
fill: $o-main-text-color; }
.o_form_field_mermaid .sectionTitle3 {
fill: $o-main-text-color; }
.o_form_field_mermaid .sectionTitle {
text-anchor: start;
font-size: 11px;
text-height: 14px; }
/* Grid and axis */
.o_form_field_mermaid .grid .tick {
stroke: lightgrey;
opacity: 0.3;
shape-rendering: crispEdges; }
.o_form_field_mermaid .grid path {
stroke-width: 0; }
/* Today line */
.o_form_field_mermaid .today {
fill: none;
stroke: red;
stroke-width: 2px; }
/* Task styling */
/* Default task */
.o_form_field_mermaid .task {
stroke-width: 2; }
.o_form_field_mermaid .taskText {
text-anchor: middle;
font-size: 11px; }
.o_form_field_mermaid .taskTextOutsideRight {
fill: $o-main-text-color;
text-anchor: start;
font-size: 11px; }
.o_form_field_mermaid .taskTextOutsideLeft {
fill: $o-main-text-color;
text-anchor: end;
font-size: 11px; }
/* Special case clickable */
.o_form_field_mermaid .task.clickable {
cursor: pointer; }
.o_form_field_mermaid .taskText.clickable {
cursor: pointer;
fill: #003163 !important;
font-weight: bold; }
.o_form_field_mermaid .taskTextOutsideLeft.clickable {
cursor: pointer;
fill: #003163 !important;
font-weight: bold; }
.o_form_field_mermaid .taskTextOutsideRight.clickable {
cursor: pointer;
fill: #003163 !important;
font-weight: bold; }
/* Specific task settings for the sections*/
.o_form_field_mermaid .taskText0,
.o_form_field_mermaid .taskText1,
.o_form_field_mermaid .taskText2,
.o_form_field_mermaid .taskText3 {
fill: white; }
.o_form_field_mermaid .task0,
.o_form_field_mermaid .task1,
.o_form_field_mermaid .task2,
.o_form_field_mermaid .task3 {
fill: $o-brand-primary;
stroke: $o-brand-primary; }
.o_form_field_mermaid .taskTextOutside0,
.o_form_field_mermaid .taskTextOutside2 {
fill: $o-main-text-color; }
.o_form_field_mermaid .taskTextOutside1,
.o_form_field_mermaid .taskTextOutside3 {
fill: $o-main-text-color; }
/* Active task */
.o_form_field_mermaid .active0,
.o_form_field_mermaid .active1,
.o_form_field_mermaid .active2,
.o_form_field_mermaid .active3 {
fill: #bfc7ff;
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: $o-main-text-color !important; }
/* Completed task */
.o_form_field_mermaid .done0,
.o_form_field_mermaid .done1,
.o_form_field_mermaid .done2,
.o_form_field_mermaid .done3 {
stroke: grey;
fill: lightgrey;
stroke-width: 2; }
.o_form_field_mermaid .doneText0,
.o_form_field_mermaid .doneText1,
.o_form_field_mermaid .doneText2,
.o_form_field_mermaid .doneText3 {
fill: $o-main-text-color !important; }
/* Tasks on the critical line */
.o_form_field_mermaid .crit0,
.o_form_field_mermaid .crit1,
.o_form_field_mermaid .crit2,
.o_form_field_mermaid .crit3 {
stroke: #ff8888;
fill: red;
stroke-width: 2; }
.o_form_field_mermaid .activeCrit0,
.o_form_field_mermaid .activeCrit1,
.o_form_field_mermaid .activeCrit2,
.o_form_field_mermaid .activeCrit3 {
stroke: #ff8888;
fill: #bfc7ff;
stroke-width: 2; }
.o_form_field_mermaid .doneCrit0,
.o_form_field_mermaid .doneCrit1,
.o_form_field_mermaid .doneCrit2,
.o_form_field_mermaid .doneCrit3 {
stroke: #ff8888;
fill: lightgrey;
stroke-width: 2;
cursor: pointer;
shape-rendering: crispEdges; }
.o_form_field_mermaid .milestone {
transform: rotate(45deg) scale(0.8, 0.8); }
.o_form_field_mermaid .milestoneText {
font-style: italic; }
.o_form_field_mermaid .doneCritText0,
.o_form_field_mermaid .doneCritText1,
.o_form_field_mermaid .doneCritText2,
.o_form_field_mermaid .doneCritText3 {
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: $o-main-text-color !important; }
.o_form_field_mermaid .titleText {
text-anchor: middle;
font-size: 18px;
fill: $o-main-text-color; }
.o_form_field_mermaid g.classGroup text {
fill: white;
stroke: none;
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
font-size: 10px; }
.o_form_field_mermaid g.classGroup rect {
fill: $o-brand-primary;
stroke: $o-main-text-color; }
.o_form_field_mermaid g.classGroup line {
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid .classLabel .box {
stroke: none;
stroke-width: 0;
fill: $o-brand-primary;
opacity: 0.5; }
.o_form_field_mermaid .classLabel .label {
fill: $o-main-text-color;
font-size: 10px;
font-weight: normal; }
.o_form_field_mermaid .relation {
stroke: $o-main-text-color;
stroke-width: 1;
fill: none; }
.o_form_field_mermaid #compositionStart {
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #compositionEnd {
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #aggregationStart {
fill: $o-brand-primary;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #aggregationEnd {
fill: $o-brand-primary;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #dependencyStart {
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #dependencyEnd {
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #extensionStart {
fill: $o-main-text-color;
stroke: $o-main-text-color;
stroke-width: 1; }
.o_form_field_mermaid #extensionEnd {
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: $o-main-text-color; }
.o_form_field_mermaid .node-label p {
margin-top: 9px; }
.o_form_field_mermaid .pieTitleText {
text-anchor: middle;
font-size: 25px;
fill: $o-main-text-color; }

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="assets_backend" name="web_widget_mermaid assets" inherit_id="web.assets_backend">
<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/scss" href="/web_widget_mermaid/static/src/scss/web_widget_mermaid_default_theme.scss"/>
</xpath>
</template>
</odoo>