Skip to content

Commit

Permalink
[16.0][IMP] web_timeline: implementing readonly_field: a boolean fiel…
Browse files Browse the repository at this point in the history
…d to mark the event as not editable in vis-timeline
  • Loading branch information
IJOL committed Nov 7, 2024
1 parent a73351b commit e589df7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web_timeline/static/src/js/timeline_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
this.date_stop = params.date_stop;
this.date_delay = params.date_delay;
this.colors = params.colors;
this.readonly_field = params.readonly_field;

this.fieldNames = params.fieldNames;
this.default_group_by = params.default_group_by;
this.dependency_arrow = params.dependency_arrow;
Expand Down Expand Up @@ -538,6 +540,9 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
if (date_stop && moment(date_start).isBefore(date_stop)) {
r.end = date_stop;
}
if (this.readonly_field && evt[this.readonly_field]) {
r.editable = false;
}
this.color = null;
return r;
},
Expand Down
5 changes: 5 additions & 0 deletions web_timeline/static/src/js/timeline_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ odoo.define("web_timeline.TimelineView", function (require) {
(item) => item.attrs.name
);
fieldNames = _.union(fieldNames, archFieldNames);
if (attrs.readonly_field) {
fieldNames.push(attrs.readonly_field);
}
const readonly_field = attrs.readonly_field;

const colors = this.parse_colors();
for (const color of colors) {
Expand Down Expand Up @@ -111,6 +115,7 @@ odoo.define("web_timeline.TimelineView", function (require) {
this.rendererParams.date_stop = date_stop;
this.rendererParams.date_delay = date_delay;
this.rendererParams.colors = colors;
this.rendererParams.readonly_field = readonly_field;
this.rendererParams.fieldNames = fieldNames;
this.rendererParams.default_group_by = attrs.default_group_by;
this.rendererParams.min_height = min_height;
Expand Down

0 comments on commit e589df7

Please sign in to comment.