Skip to content

Commit d84aced

Browse files
[MIG] web_timeline: Migration to 18.0
1 parent d2bca99 commit d84aced

16 files changed

+108
-85
lines changed

web_timeline/README.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Web timeline
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
20-
:target: https://github.com/OCA/web/tree/17.0/web_timeline
20+
:target: https://github.com/OCA/web/tree/18.0/web_timeline
2121
:alt: OCA/web
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_timeline
23+
:target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_timeline
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -202,7 +202,7 @@ More evolved example, from ``project_timeline``:
202202
<record id="project.action_view_task" model="ir.actions.act_window">
203203
<field
204204
name="view_mode"
205-
>kanban,tree,form,calendar,timeline,pivot,graph,activity</field>
205+
>kanban,list,form,calendar,timeline,pivot,graph,activity</field>
206206
</record>
207207
</odoo>
208208
@@ -264,7 +264,7 @@ Bug Tracker
264264
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
265265
In case of trouble, please check there if your issue has already been reported.
266266
If you spotted it first, help us to smash it by providing a detailed and welcomed
267-
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_timeline%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
267+
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_timeline%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
268268

269269
Do not contact contributors directly about support or help with technical issues.
270270

@@ -327,6 +327,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
327327

328328
|maintainer-tarteo|
329329

330-
This module is part of the `OCA/web <https://github.com/OCA/web/tree/17.0/web_timeline>`_ project on GitHub.
330+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_timeline>`_ project on GitHub.
331331

332332
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

web_timeline/__manifest__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "Web timeline",
77
"summary": "Interactive visualization chart to show events in time",
8-
"version": "17.0.1.0.1",
8+
"version": "18.0.1.0.0",
99
"development_status": "Production/Stable",
1010
"author": "ACSONE SA/NV, "
1111
"Tecnativa, "
@@ -34,7 +34,6 @@
3434
"web_timeline/static/src/views/timeline/timeline_controller.xml",
3535
"web_timeline/static/src/views/timeline/timeline_model.esm.js",
3636
"web_timeline/static/src/views/timeline/timeline_canvas.esm.js",
37-
"web_timeline/static/src/views/timeline/timeline_view.xml",
3837
],
3938
"web_timeline.vis-timeline_lib": [
4039
"/web_timeline/static/lib/vis-timeline/vis-timeline-graph2d.js",

web_timeline/demo/ir_cron_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
</field>
1010
</record>
1111
<record id="base.ir_cron_act" model="ir.actions.act_window">
12-
<field name="view_mode">tree,form,calendar,timeline</field>
12+
<field name="view_mode">list,form,calendar,timeline</field>
1313
</record>
1414
</odoo>

web_timeline/models/ir_ui_view.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ class IrUIView(models.Model):
1414

1515
def _is_qweb_based_view(self, view_type):
1616
return view_type == TIMELINE_VIEW[0] or super()._is_qweb_based_view(view_type)
17+
18+
def _get_view_info(self):
19+
return {"timeline": {"icon": "fa fa-tasks"}} | super()._get_view_info()

web_timeline/readme/CONFIGURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ More evolved example, from `project_timeline`:
8585
<record id="project.action_view_task" model="ir.actions.act_window">
8686
<field
8787
name="view_mode"
88-
>kanban,tree,form,calendar,timeline,pivot,graph,activity</field>
88+
>kanban,list,form,calendar,timeline,pivot,graph,activity</field>
8989
</record>
9090
</odoo>
9191
```

web_timeline/static/description/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ <h1 class="title">Web timeline</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:2fb5b8c01ee5f36a21f88358b673738a05282e9cf75f10aa33d38565ecfac956
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" 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 image-reference" href="https://github.com/OCA/web/tree/17.0/web_timeline"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_timeline"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" 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 image-reference" href="https://github.com/OCA/web/tree/18.0/web_timeline"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_timeline"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>Define a new view displaying events in an interactive visualization
374374
chart.</p>
375375
<p>The widget is based on the external library
@@ -579,7 +579,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
579579
</span><span class="nt">&lt;record</span><span class="w"> </span><span class="na">id=</span><span class="s">&quot;project.action_view_task&quot;</span><span class="w"> </span><span class="na">model=</span><span class="s">&quot;ir.actions.act_window&quot;</span><span class="nt">&gt;</span><span class="w">
580580
</span><span class="nt">&lt;field</span><span class="w">
581581
</span><span class="na">name=</span><span class="s">&quot;view_mode&quot;</span><span class="w">
582-
</span><span class="nt">&gt;</span>kanban,tree,form,calendar,timeline,pivot,graph,activity<span class="nt">&lt;/field&gt;</span><span class="w">
582+
</span><span class="nt">&gt;</span>kanban,list,form,calendar,timeline,pivot,graph,activity<span class="nt">&lt;/field&gt;</span><span class="w">
583583
</span><span class="nt">&lt;/record&gt;</span><span class="w">
584584
</span><span class="nt">&lt;/odoo&gt;</span>
585585
</pre>
@@ -636,7 +636,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
636636
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
637637
In case of trouble, please check there if your issue has already been reported.
638638
If you spotted it first, help us to smash it by providing a detailed and welcomed
639-
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_timeline%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
639+
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_timeline%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
640640
<p>Do not contact contributors directly about support or help with technical issues.</p>
641641
</div>
642642
<div class="section" id="credits">
@@ -690,7 +690,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
690690
promote its widespread use.</p>
691691
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
692692
<p><a class="reference external image-reference" href="https://github.com/tarteo"><img alt="tarteo" src="https://github.com/tarteo.png?size=40px" /></a></p>
693-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/17.0/web_timeline">OCA/web</a> project on GitHub.</p>
693+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/18.0/web_timeline">OCA/web</a> project on GitHub.</p>
694694
<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>
695695
</div>
696696
</div>

web_timeline/static/src/views/timeline/timeline_arch_parser.esm.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/** @odoo-module **/
21
/**
32
* Copyright 2024 Tecnativa - Carlos López
43
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
54
*/
65
import {_t} from "@web/core/l10n/translation";
7-
import {archParseBoolean} from "@web/views/utils";
6+
import {exprToBoolean} from "@web/core/utils/strings";
87
import {parseExpr} from "@web/core/py_js/py";
98
import {visitXML} from "@web/core/utils/xml";
109

@@ -71,7 +70,7 @@ export class TimelineArchParser {
7170
node.getAttribute("dependency_arrow");
7271
}
7372
if (node.hasAttribute("stack")) {
74-
archInfo.options.stack = archParseBoolean(
73+
archInfo.options.stack = exprToBoolean(
7574
node.getAttribute("stack"),
7675
true
7776
);
@@ -97,24 +96,24 @@ export class TimelineArchParser {
9796
}
9897
}
9998
if (node.hasAttribute("event_open_popup")) {
100-
archInfo.open_popup_action = archParseBoolean(
99+
archInfo.open_popup_action = exprToBoolean(
101100
node.getAttribute("event_open_popup")
102101
);
103102
}
104103
if (node.hasAttribute("create")) {
105-
archInfo.canCreate = archParseBoolean(
104+
archInfo.canCreate = exprToBoolean(
106105
node.getAttribute("create"),
107106
true
108107
);
109108
}
110109
if (node.hasAttribute("edit")) {
111-
archInfo.canUpdate = archParseBoolean(
110+
archInfo.canUpdate = exprToBoolean(
112111
node.getAttribute("edit"),
113112
true
114113
);
115114
}
116115
if (node.hasAttribute("delete")) {
117-
archInfo.canDelete = archParseBoolean(
116+
archInfo.canDelete = exprToBoolean(
118117
node.getAttribute("delete"),
119118
true
120119
);

web_timeline/static/src/views/timeline/timeline_canvas.esm.js

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** @odoo-module **/
21
/* Copyright 2018 Onestein
32
Copyright 2024 Tecnativa - Carlos López
43
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
@@ -15,7 +14,16 @@ export class TimelineCanvas {
1514
* Clears all drawings (svg elements) from the canvas.
1615
*/
1716
clear() {
18-
$(this.canvas_ref).find(" > :not(defs)").remove();
17+
if (this.canvas_ref) {
18+
const tempElement = document.createElement("div");
19+
tempElement.innerHTML = this.canvas_ref;
20+
Array.from(tempElement.children).forEach((child) => {
21+
if (child.tagName.toLowerCase() !== "defs") {
22+
child.remove();
23+
}
24+
});
25+
this.canvas_ref = tempElement.innerHTML;
26+
}
1927
}
2028

2129
/**
@@ -107,24 +115,34 @@ export class TimelineCanvas {
107115
* @param {Number} breakLineAt The space between the line turns
108116
* @returns {HTMLElement} The created SVG polyline
109117
*/
110-
draw_line(from, to, color, width, markerStart, widthMarker, breakLineAt) {
111-
const $from = $(from);
112-
const childPosFrom = $from.offset();
113-
const parentPosFrom = $from.closest(".vis-center").offset();
118+
draw_line(
119+
from,
120+
to,
121+
color = "#000",
122+
width = 1,
123+
markerStart,
124+
widthMarker,
125+
breakLineAt
126+
) {
127+
const fromElement =
128+
typeof from === "string" ? document.querySelector(from) : from;
129+
const toElement = typeof to === "string" ? document.querySelector(to) : to;
130+
if (!fromElement || !toElement) return;
131+
const childPosFrom = fromElement.getBoundingClientRect();
132+
const parentFrom = fromElement.closest(".vis-center")?.getBoundingClientRect();
114133
const rectFrom = {
115-
x: childPosFrom.left - parentPosFrom.left,
116-
y: childPosFrom.top - parentPosFrom.top,
117-
w: $from.width(),
118-
h: $from.height(),
134+
x: childPosFrom.left - (parentFrom?.left || 0),
135+
y: childPosFrom.top - (parentFrom?.top || 0),
136+
w: fromElement.offsetWidth,
137+
h: fromElement.offsetHeight,
119138
};
120-
const $to = $(to);
121-
const childPosTo = $to.offset();
122-
const parentPosTo = $to.closest(".vis-center").offset();
139+
const childPosTo = toElement.getBoundingClientRect();
140+
const parentTo = toElement.closest(".vis-center")?.getBoundingClientRect();
123141
const rectTo = {
124-
x: childPosTo.left - parentPosTo.left,
125-
y: childPosTo.top - parentPosTo.top,
126-
w: $to.width(),
127-
h: $to.height(),
142+
x: childPosTo.left - (parentTo?.left || 0),
143+
y: childPosTo.top - (parentTo?.top || 0),
144+
w: toElement.offsetWidth,
145+
h: toElement.offsetHeight,
128146
};
129147
const points = this.get_polyline_points(
130148
rectFrom,
@@ -134,13 +152,15 @@ export class TimelineCanvas {
134152
);
135153
const line = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
136154
line.setAttribute("points", points.flat().join(","));
137-
line.setAttribute("stroke", color || "#000");
138-
line.setAttribute("stroke-width", width || 1);
155+
line.setAttribute("stroke", color);
156+
line.setAttribute("stroke-width", width);
139157
line.setAttribute("fill", "none");
140158
if (markerStart) {
141-
line.setAttribute("marker-start", "url(" + markerStart + ")");
159+
line.setAttribute("marker-start", `url(${markerStart})`);
160+
}
161+
if (this.canvas_ref instanceof HTMLElement) {
162+
this.canvas_ref.appendChild(line);
142163
}
143-
this.canvas_ref.append(line);
144164
return line;
145165
}
146166
}

web_timeline/static/src/views/timeline/timeline_controller.esm.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@ import {useDebounced} from "@web/core/utils/timing";
1616
import {useModel} from "@web/model/model";
1717
import {useSearchBarToggler} from "@web/search/search_bar/search_bar_toggler";
1818
import {useService} from "@web/core/utils/hooks";
19-
import {useSetupView} from "@web/views/view_hook";
19+
import {useSetupAction} from "@web/search/action_hook";
2020

2121
const {DateTime} = luxon;
2222

23-
// Import time from "web.time";
24-
2523
export class TimelineController extends Component {
2624
/**
2725
* @override
2826
*/
2927
setup() {
3028
this.rootRef = useRef("root");
3129
this.model = useModel(this.props.Model, this.props.modelParams);
32-
useSetupView({rootRef: useRef("root")});
30+
useSetupAction({rootRef: useRef("root")});
3331
this.searchBarToggler = useSearchBarToggler();
3432
this.date_start = this.props.modelParams.date_start;
3533
this.date_stop = this.props.modelParams.date_stop;

web_timeline/static/src/views/timeline/timeline_model.esm.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** @odoo-module **/
21
/**
32
* Copyright 2024 Tecnativa - Carlos López
43
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

0 commit comments

Comments
 (0)