Skip to content

Commit 92803f4

Browse files
committed
[16.0][IMP] web_timeline: implementing readonly_field: a boolean field to mark the event as not editable in vis-timeline
1 parent 91a9800 commit 92803f4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

web_timeline/static/src/js/timeline_renderer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
3737
this.date_stop = params.date_stop;
3838
this.date_delay = params.date_delay;
3939
this.colors = params.colors;
40+
this.readonly_field = params.readonly_field;
41+
4042
this.fieldNames = params.fieldNames;
4143
this.default_group_by = params.default_group_by;
4244
this.dependency_arrow = params.dependency_arrow;
@@ -538,6 +540,9 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
538540
if (date_stop && moment(date_start).isBefore(date_stop)) {
539541
r.end = date_stop;
540542
}
543+
if (this.readonly_field && evt[this.readonly_field]) {
544+
r.editable = false;
545+
}
541546
this.color = null;
542547
return r;
543548
},

web_timeline/static/src/js/timeline_view.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ odoo.define("web_timeline.TimelineView", function (require) {
7575
(item) => item.attrs.name
7676
);
7777
fieldNames = _.union(fieldNames, archFieldNames);
78+
if (attrs.readonly_field) {
79+
fieldNames.push(attrs.readonly_field);
80+
}
81+
const readonly_field = attrs.readonly_field;
7882

7983
const colors = this.parse_colors();
8084
for (const color of colors) {
@@ -111,6 +115,7 @@ odoo.define("web_timeline.TimelineView", function (require) {
111115
this.rendererParams.date_stop = date_stop;
112116
this.rendererParams.date_delay = date_delay;
113117
this.rendererParams.colors = colors;
118+
this.rendererParams.readonly_field = readonly_field;
114119
this.rendererParams.fieldNames = fieldNames;
115120
this.rendererParams.default_group_by = attrs.default_group_by;
116121
this.rendererParams.min_height = min_height;

0 commit comments

Comments
 (0)