Browse Source

Merge d6d92744d2 into 154ae149f4

pull/1206/merge
InfernalLV 5 years ago
committed by GitHub
parent
commit
4eb29abd47
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      web_timeline/README.rst
  2. 2
      web_timeline/__manifest__.py
  3. 3
      web_timeline/static/src/js/timeline_renderer.js
  4. 18
      web_timeline/static/src/js/timeline_view.js

4
web_timeline/README.rst

@ -38,7 +38,7 @@ the possible attributes for the tag:
in a popup. If not (default value), the record is edited changing to form
view.
* colors (optional): it allows to set certain specific colors if the expressed
condition (JS syntax) is met.
condition (Python syntax) is met.
* dependency_arrow (optional): set this attribute to a x2many field to draw
arrows between the records referenced in the x2many field.
@ -67,7 +67,7 @@ Example:
default_group_by="user_id"
event_open_popup="true"
zoomKey="ctrlKey"
colors="#ec7063:user_id == false;#2ecb71:kanban_state=='done';"
colors="#ec7063:user_id == False;#2ecb71:kanban_state=='done';#f6d5d5:date_end > date_deadline"
dependency_arrow="task_dependency_ids">
<field name="user_id"/>
<templates>

2
web_timeline/__manifest__.py

@ -4,7 +4,7 @@
{
'name': "Web timeline",
'summary': "Interactive visualization chart to show events in time",
"version": "11.0.1.4.1",
"version": "11.0.2.0.0",
'author': 'ACSONE SA/NV, '
'Tecnativa, '
'Monk Software, '

3
web_timeline/static/src/js/timeline_renderer.js

@ -10,7 +10,6 @@ odoo.define('web_timeline.TimelineRenderer', function (require) {
var field_utils = require('web.field_utils');
var TimelineCanvas = require('web_timeline.TimelineCanvas');
var _t = core._t;
var TimelineRenderer = AbstractRenderer.extend({
@ -422,7 +421,7 @@ odoo.define('web_timeline.TimelineRenderer', function (require) {
group = -1;
}
_.each(self.colors, function (color) {
if (eval("'" + evt[color.field] + "' " + color.opt + " '" + color.value + "'")) {
if (py.PY_isTrue(py.evaluate(color.ast, evt))) {
self.color = color.color;
}
});

18
web_timeline/static/src/js/timeline_view.js

@ -85,7 +85,11 @@ odoo.define('web_timeline.TimelineView', function (require) {
this.parse_colors();
for (var i=0; i<this.colors.length; i++) {
fieldNames.push(this.colors[i].field);
for (var j=0; j<this.colors[i].tokens.length; j++) {
if (this.colors[i].tokens[j].id === '(name)') {
fieldNames.push(this.colors[i].tokens[j].value);
}
}
}
if (attrs.dependency_arrow) {
@ -171,13 +175,15 @@ odoo.define('web_timeline.TimelineView', function (require) {
parse_colors: function () {
if (this.arch.attrs.colors) {
this.colors = _(this.arch.attrs.colors.split(';')).chain().compact().map(function (color_pair) {
var pair = color_pair.split(':'), color = pair[0], expr = pair[1];
var temp = py.parse(py.tokenize(expr));
var temp = color_pair.split(':');
var color = temp[0];
var expr = temp.slice(1).join(':');
var tokens = py.tokenize(expr);
var ast = py.parse(tokens);
return {
'color': color,
'field': temp.expressions[0].value,
'opt': temp.operators[0],
'value': temp.expressions[1].value
'tokens': tokens,
'ast': ast,
};
}).value();
} else {

Loading…
Cancel
Save