mirror of https://github.com/OCA/web.git
[FIX] Travis
parent
69f9a96da8
commit
b20692c320
|
@ -4,7 +4,7 @@
|
||||||
{
|
{
|
||||||
"name": "Web timeline",
|
"name": "Web timeline",
|
||||||
"summary": "Interactive visualization chart to show events in time",
|
"summary": "Interactive visualization chart to show events in time",
|
||||||
"version": "13.0.1.1.1",
|
"version": "14.0.1.0.0",
|
||||||
"development_status": "Production/Stable",
|
"development_status": "Production/Stable",
|
||||||
"author": "ACSONE SA/NV, "
|
"author": "ACSONE SA/NV, "
|
||||||
"Tecnativa, "
|
"Tecnativa, "
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* Copyright 2018 Onestein
|
/* Copyright 2018 Onestein
|
||||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
odoo.define("web_timeline.TimelineCanvas", function(require) {
|
odoo.define("web_timeline.TimelineCanvas", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
const Widget = require("web.Widget");
|
const Widget = require("web.Widget");
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ odoo.define("web_timeline.TimelineCanvas", function(require) {
|
||||||
/**
|
/**
|
||||||
* Clears all drawings (svg elements) from the canvas.
|
* Clears all drawings (svg elements) from the canvas.
|
||||||
*/
|
*/
|
||||||
clear: function() {
|
clear: function () {
|
||||||
this.$(" > :not(defs)").remove();
|
this.$(" > :not(defs)").remove();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ odoo.define("web_timeline.TimelineCanvas", function(require) {
|
||||||
* @param {Number} breakAt The space between the line turns
|
* @param {Number} breakAt The space between the line turns
|
||||||
* @returns {Array} Each item represents a coordinate
|
* @returns {Array} Each item represents a coordinate
|
||||||
*/
|
*/
|
||||||
get_polyline_points: function(rectFrom, rectTo, widthMarker, breakAt) {
|
get_polyline_points: function (rectFrom, rectTo, widthMarker, breakAt) {
|
||||||
let fromX = 0,
|
let fromX = 0,
|
||||||
toX = 0;
|
toX = 0;
|
||||||
if (rectFrom.x < rectTo.x + rectTo.w) {
|
if (rectFrom.x < rectTo.x + rectTo.w) {
|
||||||
|
@ -91,7 +91,7 @@ odoo.define("web_timeline.TimelineCanvas", function(require) {
|
||||||
* @param {Number} width Width of the line
|
* @param {Number} width Width of the line
|
||||||
* @returns {HTMLElement} The created SVG polyline
|
* @returns {HTMLElement} The created SVG polyline
|
||||||
*/
|
*/
|
||||||
draw_arrow: function(from, to, color, width) {
|
draw_arrow: function (from, to, color, width) {
|
||||||
return this.draw_line(from, to, color, width, "#arrowhead", 10, 12);
|
return this.draw_line(from, to, color, width, "#arrowhead", 10, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ odoo.define("web_timeline.TimelineCanvas", function(require) {
|
||||||
* @param {Number} breakLineAt The space between the line turns
|
* @param {Number} breakLineAt The space between the line turns
|
||||||
* @returns {HTMLElement} The created SVG polyline
|
* @returns {HTMLElement} The created SVG polyline
|
||||||
*/
|
*/
|
||||||
draw_line: function(
|
draw_line: function (
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
color,
|
color,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
odoo.define("web_timeline.TimelineController", function(require) {
|
odoo.define("web_timeline.TimelineController", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const AbstractController = require("web.AbstractController");
|
const AbstractController = require("web.AbstractController");
|
||||||
|
@ -21,7 +21,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
init: function(parent, model, renderer, params) {
|
init: function (parent, model, renderer, params) {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.open_popup_action = params.open_popup_action;
|
this.open_popup_action = params.open_popup_action;
|
||||||
this.date_start = params.date_start;
|
this.date_start = params.date_start;
|
||||||
|
@ -35,7 +35,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
update: function(params, options) {
|
update: function (params, options) {
|
||||||
const res = this._super.apply(this, arguments);
|
const res = this._super.apply(this, arguments);
|
||||||
if (_.isEmpty(params)) {
|
if (_.isEmpty(params)) {
|
||||||
return res;
|
return res;
|
||||||
|
@ -68,7 +68,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
domain: domains,
|
domain: domains,
|
||||||
},
|
},
|
||||||
context: this.getSession().user_context,
|
context: this.getSession().user_context,
|
||||||
}).then(data =>
|
}).then((data) =>
|
||||||
this.renderer.on_data_loaded(
|
this.renderer.on_data_loaded(
|
||||||
data,
|
data,
|
||||||
n_group_bys,
|
n_group_bys,
|
||||||
|
@ -86,7 +86,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
* @param {EventObject} event
|
* @param {EventObject} event
|
||||||
* @returns {jQuery.Deferred}
|
* @returns {jQuery.Deferred}
|
||||||
*/
|
*/
|
||||||
_onGroupClick: function(event) {
|
_onGroupClick: function (event) {
|
||||||
const groupField = this.renderer.last_group_bys[0];
|
const groupField = this.renderer.last_group_bys[0];
|
||||||
return this.do_action({
|
return this.do_action({
|
||||||
type: "ir.actions.act_window",
|
type: "ir.actions.act_window",
|
||||||
|
@ -104,7 +104,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @param {EventObject} event
|
* @param {EventObject} event
|
||||||
*/
|
*/
|
||||||
_onUpdate: function(event) {
|
_onUpdate: function (event) {
|
||||||
this.renderer = event.data.renderer;
|
this.renderer = event.data.renderer;
|
||||||
const rights = event.data.rights;
|
const rights = event.data.rights;
|
||||||
const item = event.data.item;
|
const item = event.data.item;
|
||||||
|
@ -142,7 +142,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @param {EventObject} event
|
* @param {EventObject} event
|
||||||
*/
|
*/
|
||||||
_onMove: function(event) {
|
_onMove: function (event) {
|
||||||
const item = event.data.item;
|
const item = event.data.item;
|
||||||
const fields = this.renderer.fields;
|
const fields = this.renderer.fields;
|
||||||
const event_start = item.start;
|
const event_start = item.start;
|
||||||
|
@ -198,7 +198,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
*
|
*
|
||||||
* @returns {jQuery.Deferred}
|
* @returns {jQuery.Deferred}
|
||||||
*/
|
*/
|
||||||
internalMove: function() {
|
internalMove: function () {
|
||||||
const queues = this.moveQueue.slice();
|
const queues = this.moveQueue.slice();
|
||||||
this.moveQueue = [];
|
this.moveQueue = [];
|
||||||
const defers = [];
|
const defers = [];
|
||||||
|
@ -229,7 +229,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
* @param {EventObject} event
|
* @param {EventObject} event
|
||||||
* @returns {jQuery.Deferred}
|
* @returns {jQuery.Deferred}
|
||||||
*/
|
*/
|
||||||
_onRemove: function(event) {
|
_onRemove: function (event) {
|
||||||
var def = $.Deferred();
|
var def = $.Deferred();
|
||||||
|
|
||||||
Dialog.confirm(this, _t("Are you sure you want to delete this record?"), {
|
Dialog.confirm(this, _t("Are you sure you want to delete this record?"), {
|
||||||
|
@ -250,7 +250,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
* @param {EventObject} event
|
* @param {EventObject} event
|
||||||
* @returns {dialogs.FormViewDialog}
|
* @returns {dialogs.FormViewDialog}
|
||||||
*/
|
*/
|
||||||
_onAdd: function(event) {
|
_onAdd: function (event) {
|
||||||
const item = event.data.item;
|
const item = event.data.item;
|
||||||
// Initialize default values for creation
|
// Initialize default values for creation
|
||||||
const default_context = {};
|
const default_context = {};
|
||||||
|
@ -278,7 +278,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
res_id: null,
|
res_id: null,
|
||||||
context: _.extend(default_context, this.context),
|
context: _.extend(default_context, this.context),
|
||||||
view_id: Number(this.open_popup_action),
|
view_id: Number(this.open_popup_action),
|
||||||
on_saved: record => {
|
on_saved: (record) => {
|
||||||
this.create_completed([record.res_id]);
|
this.create_completed([record.res_id]);
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -297,13 +297,13 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
* @param {RecordId} id
|
* @param {RecordId} id
|
||||||
* @returns {jQuery.Deferred}
|
* @returns {jQuery.Deferred}
|
||||||
*/
|
*/
|
||||||
create_completed: function(id) {
|
create_completed: function (id) {
|
||||||
return this._rpc({
|
return this._rpc({
|
||||||
model: this.model.modelName,
|
model: this.model.modelName,
|
||||||
method: "read",
|
method: "read",
|
||||||
args: [id, this.model.fieldNames],
|
args: [id, this.model.fieldNames],
|
||||||
context: this.context,
|
context: this.context,
|
||||||
}).then(records => {
|
}).then((records) => {
|
||||||
var new_event = this.renderer.event_data_transform(records[0]);
|
var new_event = this.renderer.event_data_transform(records[0]);
|
||||||
var items = this.renderer.timeline.itemsData;
|
var items = this.renderer.timeline.itemsData;
|
||||||
items.add(new_event);
|
items.add(new_event);
|
||||||
|
@ -316,7 +316,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
* Triggered upon completion of writing a record.
|
* Triggered upon completion of writing a record.
|
||||||
* @param {ControllerOptions} options
|
* @param {ControllerOptions} options
|
||||||
*/
|
*/
|
||||||
write_completed: function(options) {
|
write_completed: function (options) {
|
||||||
const params = {
|
const params = {
|
||||||
domain: this.renderer.last_domains,
|
domain: this.renderer.last_domains,
|
||||||
context: this.context,
|
context: this.context,
|
||||||
|
@ -330,7 +330,7 @@ odoo.define("web_timeline.TimelineController", function(require) {
|
||||||
* @param {EventObject} event
|
* @param {EventObject} event
|
||||||
* @returns {jQuery.Deferred}
|
* @returns {jQuery.Deferred}
|
||||||
*/
|
*/
|
||||||
remove_completed: function(event) {
|
remove_completed: function (event) {
|
||||||
return this._rpc({
|
return this._rpc({
|
||||||
model: this.modelName,
|
model: this.modelName,
|
||||||
method: "unlink",
|
method: "unlink",
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
odoo.define("web_timeline.TimelineModel", function(require) {
|
odoo.define("web_timeline.TimelineModel", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const AbstractModel = require("web.AbstractModel");
|
const AbstractModel = require("web.AbstractModel");
|
||||||
|
|
||||||
const TimelineModel = AbstractModel.extend({
|
const TimelineModel = AbstractModel.extend({
|
||||||
init: function() {
|
init: function () {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
load: function(params) {
|
load: function (params) {
|
||||||
this.modelName = params.modelName;
|
this.modelName = params.modelName;
|
||||||
this.fieldNames = params.fieldNames;
|
this.fieldNames = params.fieldNames;
|
||||||
if (!this.preload_def) {
|
if (!this.preload_def) {
|
||||||
|
@ -51,14 +51,14 @@ odoo.define("web_timeline.TimelineModel", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {jQuery.Deferred}
|
* @returns {jQuery.Deferred}
|
||||||
*/
|
*/
|
||||||
_loadTimeline: function() {
|
_loadTimeline: function () {
|
||||||
return this._rpc({
|
return this._rpc({
|
||||||
model: this.modelName,
|
model: this.modelName,
|
||||||
method: "search_read",
|
method: "search_read",
|
||||||
context: this.data.context,
|
context: this.data.context,
|
||||||
fields: this.fieldNames,
|
fields: this.fieldNames,
|
||||||
domain: this.data.domain,
|
domain: this.data.domain,
|
||||||
}).then(events => {
|
}).then((events) => {
|
||||||
this.data.data = events;
|
this.data.data = events;
|
||||||
this.data.rights = {
|
this.data.rights = {
|
||||||
unlink: this.unlink_right,
|
unlink: this.unlink_right,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* global vis, py */
|
/* global vis, py */
|
||||||
odoo.define("web_timeline.TimelineRenderer", function(require) {
|
odoo.define("web_timeline.TimelineRenderer", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const AbstractRenderer = require("web.AbstractRenderer");
|
const AbstractRenderer = require("web.AbstractRenderer");
|
||||||
|
@ -24,7 +24,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
"click .oe_timeline_button_scale_year": "_onScaleYearClicked",
|
"click .oe_timeline_button_scale_year": "_onScaleYearClicked",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
init: function(parent, state, params) {
|
init: function (parent, state, params) {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.modelName = params.model;
|
this.modelName = params.model;
|
||||||
this.mode = params.mode;
|
this.mode = params.mode;
|
||||||
|
@ -45,7 +45,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
start: function() {
|
start: function () {
|
||||||
const attrs = this.arch.attrs;
|
const attrs = this.arch.attrs;
|
||||||
this.current_window = {
|
this.current_window = {
|
||||||
start: new moment(),
|
start: new moment(),
|
||||||
|
@ -66,7 +66,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
/**
|
/**
|
||||||
* Triggered when the timeline is attached to the DOM.
|
* Triggered when the timeline is attached to the DOM.
|
||||||
*/
|
*/
|
||||||
on_attach_callback: function() {
|
on_attach_callback: function () {
|
||||||
const height =
|
const height =
|
||||||
this.$el.parent().height() - this.$(".oe_timeline_buttons").height();
|
this.$el.parent().height() - this.$(".oe_timeline_buttons").height();
|
||||||
if (height > this.min_height && this.timeline) {
|
if (height > this.min_height && this.timeline) {
|
||||||
|
@ -79,7 +79,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
_render: function() {
|
_render: function () {
|
||||||
return Promise.resolve().then(() => {
|
return Promise.resolve().then(() => {
|
||||||
// Prevent Double Rendering on Updates
|
// Prevent Double Rendering on Updates
|
||||||
if (!this.timeline) {
|
if (!this.timeline) {
|
||||||
|
@ -94,7 +94,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onTodayClicked: function() {
|
_onTodayClicked: function () {
|
||||||
this.current_window = {
|
this.current_window = {
|
||||||
start: new moment(),
|
start: new moment(),
|
||||||
end: new moment().add(24, "hours"),
|
end: new moment().add(24, "hours"),
|
||||||
|
@ -110,7 +110,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onScaleDayClicked: function() {
|
_onScaleDayClicked: function () {
|
||||||
this._scaleCurrentWindow(24);
|
this._scaleCurrentWindow(24);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onScaleWeekClicked: function() {
|
_onScaleWeekClicked: function () {
|
||||||
this._scaleCurrentWindow(24 * 7);
|
this._scaleCurrentWindow(24 * 7);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onScaleMonthClicked: function() {
|
_onScaleMonthClicked: function () {
|
||||||
this._scaleCurrentWindow(
|
this._scaleCurrentWindow(
|
||||||
24 * moment(this.current_window.start).daysInMonth()
|
24 * moment(this.current_window.start).daysInMonth()
|
||||||
);
|
);
|
||||||
|
@ -139,7 +139,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onScaleYearClicked: function() {
|
_onScaleYearClicked: function () {
|
||||||
this._scaleCurrentWindow(
|
this._scaleCurrentWindow(
|
||||||
24 * (moment(this.current_window.start).isLeapYear() ? 366 : 365)
|
24 * (moment(this.current_window.start).isLeapYear() ? 366 : 365)
|
||||||
);
|
);
|
||||||
|
@ -151,7 +151,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {Integer} factor The timespan (in hours) the window must be scaled to.
|
* @param {Integer} factor The timespan (in hours) the window must be scaled to.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_scaleCurrentWindow: function(factor) {
|
_scaleCurrentWindow: function (factor) {
|
||||||
if (this.timeline) {
|
if (this.timeline) {
|
||||||
this.current_window = this.timeline.getWindow();
|
this.current_window = this.timeline.getWindow();
|
||||||
this.current_window.end = moment(this.current_window.start).add(
|
this.current_window.end = moment(this.current_window.start).add(
|
||||||
|
@ -167,7 +167,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_computeMode: function() {
|
_computeMode: function () {
|
||||||
if (this.mode) {
|
if (this.mode) {
|
||||||
let start = false,
|
let start = false,
|
||||||
end = false;
|
end = false;
|
||||||
|
@ -200,7 +200,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
init_timeline: function() {
|
init_timeline: function () {
|
||||||
this._computeMode();
|
this._computeMode();
|
||||||
this.options.editable = {
|
this.options.editable = {
|
||||||
// Add new items by double tapping
|
// Add new items by double tapping
|
||||||
|
@ -221,7 +221,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
this.qweb = new QWeb(session.debug, {_s: session.origin}, false);
|
this.qweb = new QWeb(session.debug, {_s: session.origin}, false);
|
||||||
if (this.arch.children.length) {
|
if (this.arch.children.length) {
|
||||||
const tmpl = utils.json_node_to_xml(
|
const tmpl = utils.json_node_to_xml(
|
||||||
_.filter(this.arch.children, item => item.tag === "templates")[0]
|
_.filter(this.arch.children, (item) => item.tag === "templates")[0]
|
||||||
);
|
);
|
||||||
this.qweb.add_template(tmpl);
|
this.qweb.add_template(tmpl);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
draw_canvas: function() {
|
draw_canvas: function () {
|
||||||
this.canvas.clear();
|
this.canvas.clear();
|
||||||
if (this.dependency_arrow) {
|
if (this.dependency_arrow) {
|
||||||
this.draw_dependencies();
|
this.draw_dependencies();
|
||||||
|
@ -261,7 +261,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
draw_dependencies: function() {
|
draw_dependencies: function () {
|
||||||
const items = this.timeline.itemSet.items;
|
const items = this.timeline.itemSet.items;
|
||||||
const datas = this.timeline.itemsData;
|
const datas = this.timeline.itemsData;
|
||||||
if (!items || !datas) {
|
if (!items || !datas) {
|
||||||
|
@ -292,7 +292,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {Object} options.line_width The width of the line
|
* @param {Object} options.line_width The width of the line
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
draw_dependency: function(from, to, options) {
|
draw_dependency: function (from, to, options) {
|
||||||
if (!from.displayed || !to.displayed) {
|
if (!from.displayed || !to.displayed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -317,18 +317,18 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {jQuery.Deferred}
|
* @returns {jQuery.Deferred}
|
||||||
*/
|
*/
|
||||||
on_data_loaded: function(events, group_bys, adjust_window) {
|
on_data_loaded: function (events, group_bys, adjust_window) {
|
||||||
const ids = _.pluck(events, "id");
|
const ids = _.pluck(events, "id");
|
||||||
return this._rpc({
|
return this._rpc({
|
||||||
model: this.modelName,
|
model: this.modelName,
|
||||||
method: "name_get",
|
method: "name_get",
|
||||||
args: [ids],
|
args: [ids],
|
||||||
context: this.getSession().user_context,
|
context: this.getSession().user_context,
|
||||||
}).then(names => {
|
}).then((names) => {
|
||||||
const nevents = _.map(events, event =>
|
const nevents = _.map(events, (event) =>
|
||||||
_.extend(
|
_.extend(
|
||||||
{
|
{
|
||||||
__name: _.detect(names, name => name[0] === event.id)[1],
|
__name: _.detect(names, (name) => name[0] === event.id)[1],
|
||||||
},
|
},
|
||||||
event
|
event
|
||||||
)
|
)
|
||||||
|
@ -345,7 +345,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {Boolean} adjust_window
|
* @param {Boolean} adjust_window
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
on_data_loaded_2: function(events, group_bys, adjust_window) {
|
on_data_loaded_2: function (events, group_bys, adjust_window) {
|
||||||
const data = [];
|
const data = [];
|
||||||
this.grouped_by = group_bys;
|
this.grouped_by = group_bys;
|
||||||
for (const evt of events) {
|
for (const evt of events) {
|
||||||
|
@ -371,7 +371,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
split_groups: function(events, group_bys) {
|
split_groups: function (events, group_bys) {
|
||||||
if (group_bys.length === 0) {
|
if (group_bys.length === 0) {
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
if (group_name instanceof Array) {
|
if (group_name instanceof Array) {
|
||||||
const group = _.find(
|
const group = _.find(
|
||||||
groups,
|
groups,
|
||||||
existing_group => existing_group.id === group_name[0]
|
(existing_group) => existing_group.id === group_name[0]
|
||||||
);
|
);
|
||||||
if (_.isUndefined(group)) {
|
if (_.isUndefined(group)) {
|
||||||
groups.push({
|
groups.push({
|
||||||
|
@ -403,7 +403,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {TransformEvent} evt
|
* @param {TransformEvent} evt
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
_get_event_dates: function(evt) {
|
_get_event_dates: function (evt) {
|
||||||
let date_start = new moment();
|
let date_start = new moment();
|
||||||
let date_stop = null;
|
let date_stop = null;
|
||||||
|
|
||||||
|
@ -433,10 +433,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!date_stop && date_delay) {
|
if (!date_stop && date_delay) {
|
||||||
date_stop = date_start
|
date_stop = date_start.clone().add(date_delay, "hours").toDate();
|
||||||
.clone()
|
|
||||||
.add(date_delay, "hours")
|
|
||||||
.toDate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [date_start, date_stop];
|
return [date_start, date_stop];
|
||||||
|
@ -449,7 +446,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
event_data_transform: function(evt) {
|
event_data_transform: function (evt) {
|
||||||
const [date_start, date_stop] = this._get_event_dates(evt);
|
const [date_start, date_stop] = this._get_event_dates(evt);
|
||||||
let group = evt[this.last_group_bys[0]];
|
let group = evt[this.last_group_bys[0]];
|
||||||
if (group && group instanceof Array) {
|
if (group && group instanceof Array) {
|
||||||
|
@ -493,7 +490,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {String} Rendered template
|
* @returns {String} Rendered template
|
||||||
*/
|
*/
|
||||||
render_timeline_item: function(evt) {
|
render_timeline_item: function (evt) {
|
||||||
if (this.qweb.has_template("timeline-item")) {
|
if (this.qweb.has_template("timeline-item")) {
|
||||||
return this.qweb.render("timeline-item", {
|
return this.qweb.render("timeline-item", {
|
||||||
record: evt,
|
record: evt,
|
||||||
|
@ -512,7 +509,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {ClickEvent} e
|
* @param {ClickEvent} e
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
on_group_click: function(e) {
|
on_group_click: function (e) {
|
||||||
if (e.what === "group-label" && e.group !== -1) {
|
if (e.what === "group-label" && e.group !== -1) {
|
||||||
this._trigger(
|
this._trigger(
|
||||||
e,
|
e,
|
||||||
|
@ -531,7 +528,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
on_update: function(item, callback) {
|
on_update: function (item, callback) {
|
||||||
this._trigger(item, callback, "onUpdate");
|
this._trigger(item, callback, "onUpdate");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -542,7 +539,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
on_move: function(item, callback) {
|
on_move: function (item, callback) {
|
||||||
this._trigger(item, callback, "onMove");
|
this._trigger(item, callback, "onMove");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -553,7 +550,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
on_remove: function(item, callback) {
|
on_remove: function (item, callback) {
|
||||||
this._trigger(item, callback, "onRemove");
|
this._trigger(item, callback, "onRemove");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -564,7 +561,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
on_add: function(item, callback) {
|
on_add: function (item, callback) {
|
||||||
this._trigger(item, callback, "onAdd");
|
this._trigger(item, callback, "onAdd");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -576,7 +573,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) {
|
||||||
* @param {String} trigger
|
* @param {String} trigger
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_trigger: function(item, callback, trigger) {
|
_trigger: function (item, callback, trigger) {
|
||||||
this.trigger_up(trigger, {
|
this.trigger_up(trigger, {
|
||||||
item: item,
|
item: item,
|
||||||
callback: callback,
|
callback: callback,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
* Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
odoo.define("web_timeline.TimelineView", function(require) {
|
odoo.define("web_timeline.TimelineView", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const core = require("web.core");
|
const core = require("web.core");
|
||||||
|
@ -35,7 +35,7 @@ odoo.define("web_timeline.TimelineView", function(require) {
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
init: function(viewInfo, params) {
|
init: function (viewInfo, params) {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.modelName = this.controllerParams.modelName;
|
this.modelName = this.controllerParams.modelName;
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ odoo.define("web_timeline.TimelineView", function(require) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const archFieldNames = _.map(
|
const archFieldNames = _.map(
|
||||||
_.filter(this.arch.children, item => item.tag === "field"),
|
_.filter(this.arch.children, (item) => item.tag === "field"),
|
||||||
item => item.attrs.name
|
(item) => item.attrs.name
|
||||||
);
|
);
|
||||||
fieldNames = _.union(fieldNames, archFieldNames);
|
fieldNames = _.union(fieldNames, archFieldNames);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ odoo.define("web_timeline.TimelineView", function(require) {
|
||||||
this.withSearchPanel = false;
|
this.withSearchPanel = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_preapre_vis_timeline_options: function(attrs) {
|
_preapre_vis_timeline_options: function (attrs) {
|
||||||
return {
|
return {
|
||||||
groupOrder: this.group_order,
|
groupOrder: this.group_order,
|
||||||
orientation: "both",
|
orientation: "both",
|
||||||
|
@ -140,7 +140,7 @@ odoo.define("web_timeline.TimelineView", function(require) {
|
||||||
* @param {Object} grp2
|
* @param {Object} grp2
|
||||||
* @returns {Integer}
|
* @returns {Integer}
|
||||||
*/
|
*/
|
||||||
group_order: function(grp1, grp2) {
|
group_order: function (grp1, grp2) {
|
||||||
// Display non grouped elements first
|
// Display non grouped elements first
|
||||||
if (grp1.id === -1) {
|
if (grp1.id === -1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -158,12 +158,12 @@ odoo.define("web_timeline.TimelineView", function(require) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
parse_colors: function() {
|
parse_colors: function () {
|
||||||
if (this.arch.attrs.colors) {
|
if (this.arch.attrs.colors) {
|
||||||
return _(this.arch.attrs.colors.split(";"))
|
return _(this.arch.attrs.colors.split(";"))
|
||||||
.chain()
|
.chain()
|
||||||
.compact()
|
.compact()
|
||||||
.map(color_pair => {
|
.map((color_pair) => {
|
||||||
const pair = color_pair.split(":");
|
const pair = color_pair.split(":");
|
||||||
const color = pair[0];
|
const color = pair[0];
|
||||||
const expr = pair[1];
|
const expr = pair[1];
|
||||||
|
|
Loading…
Reference in New Issue