From b20692c320ffeb1c92c11a915562c91b30f6759a Mon Sep 17 00:00:00 2001 From: Murtaza Mithaiwala Date: Mon, 15 Mar 2021 18:01:47 +0530 Subject: [PATCH] [FIX] Travis --- web_timeline/__manifest__.py | 2 +- web_timeline/static/src/js/timeline_canvas.js | 10 +-- .../static/src/js/timeline_controller.js | 30 ++++---- web_timeline/static/src/js/timeline_model.js | 10 +-- .../static/src/js/timeline_renderer.js | 71 +++++++++---------- web_timeline/static/src/js/timeline_view.js | 16 ++--- 6 files changed, 68 insertions(+), 71 deletions(-) diff --git a/web_timeline/__manifest__.py b/web_timeline/__manifest__.py index 988443ab2..4c317de3d 100644 --- a/web_timeline/__manifest__.py +++ b/web_timeline/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Web timeline", "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", "author": "ACSONE SA/NV, " "Tecnativa, " diff --git a/web_timeline/static/src/js/timeline_canvas.js b/web_timeline/static/src/js/timeline_canvas.js index 886717ad9..018908ef4 100644 --- a/web_timeline/static/src/js/timeline_canvas.js +++ b/web_timeline/static/src/js/timeline_canvas.js @@ -1,7 +1,7 @@ /* Copyright 2018 Onestein * 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"; const Widget = require("web.Widget"); @@ -14,7 +14,7 @@ odoo.define("web_timeline.TimelineCanvas", function(require) { /** * Clears all drawings (svg elements) from the canvas. */ - clear: function() { + clear: function () { this.$(" > :not(defs)").remove(); }, @@ -27,7 +27,7 @@ odoo.define("web_timeline.TimelineCanvas", function(require) { * @param {Number} breakAt The space between the line turns * @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, toX = 0; 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 * @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); }, @@ -107,7 +107,7 @@ odoo.define("web_timeline.TimelineCanvas", function(require) { * @param {Number} breakLineAt The space between the line turns * @returns {HTMLElement} The created SVG polyline */ - draw_line: function( + draw_line: function ( from, to, color, diff --git a/web_timeline/static/src/js/timeline_controller.js b/web_timeline/static/src/js/timeline_controller.js index 22271112b..dbb78de47 100644 --- a/web_timeline/static/src/js/timeline_controller.js +++ b/web_timeline/static/src/js/timeline_controller.js @@ -1,4 +1,4 @@ -odoo.define("web_timeline.TimelineController", function(require) { +odoo.define("web_timeline.TimelineController", function (require) { "use strict"; const AbstractController = require("web.AbstractController"); @@ -21,7 +21,7 @@ odoo.define("web_timeline.TimelineController", function(require) { /** * @override */ - init: function(parent, model, renderer, params) { + init: function (parent, model, renderer, params) { this._super.apply(this, arguments); this.open_popup_action = params.open_popup_action; this.date_start = params.date_start; @@ -35,7 +35,7 @@ odoo.define("web_timeline.TimelineController", function(require) { /** * @override */ - update: function(params, options) { + update: function (params, options) { const res = this._super.apply(this, arguments); if (_.isEmpty(params)) { return res; @@ -68,7 +68,7 @@ odoo.define("web_timeline.TimelineController", function(require) { domain: domains, }, context: this.getSession().user_context, - }).then(data => + }).then((data) => this.renderer.on_data_loaded( data, n_group_bys, @@ -86,7 +86,7 @@ odoo.define("web_timeline.TimelineController", function(require) { * @param {EventObject} event * @returns {jQuery.Deferred} */ - _onGroupClick: function(event) { + _onGroupClick: function (event) { const groupField = this.renderer.last_group_bys[0]; return this.do_action({ type: "ir.actions.act_window", @@ -104,7 +104,7 @@ odoo.define("web_timeline.TimelineController", function(require) { * @private * @param {EventObject} event */ - _onUpdate: function(event) { + _onUpdate: function (event) { this.renderer = event.data.renderer; const rights = event.data.rights; const item = event.data.item; @@ -142,7 +142,7 @@ odoo.define("web_timeline.TimelineController", function(require) { * @private * @param {EventObject} event */ - _onMove: function(event) { + _onMove: function (event) { const item = event.data.item; const fields = this.renderer.fields; const event_start = item.start; @@ -198,7 +198,7 @@ odoo.define("web_timeline.TimelineController", function(require) { * * @returns {jQuery.Deferred} */ - internalMove: function() { + internalMove: function () { const queues = this.moveQueue.slice(); this.moveQueue = []; const defers = []; @@ -229,7 +229,7 @@ odoo.define("web_timeline.TimelineController", function(require) { * @param {EventObject} event * @returns {jQuery.Deferred} */ - _onRemove: function(event) { + _onRemove: function (event) { var def = $.Deferred(); 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 * @returns {dialogs.FormViewDialog} */ - _onAdd: function(event) { + _onAdd: function (event) { const item = event.data.item; // Initialize default values for creation const default_context = {}; @@ -278,7 +278,7 @@ odoo.define("web_timeline.TimelineController", function(require) { res_id: null, context: _.extend(default_context, this.context), view_id: Number(this.open_popup_action), - on_saved: record => { + on_saved: (record) => { this.create_completed([record.res_id]); }, }) @@ -297,13 +297,13 @@ odoo.define("web_timeline.TimelineController", function(require) { * @param {RecordId} id * @returns {jQuery.Deferred} */ - create_completed: function(id) { + create_completed: function (id) { return this._rpc({ model: this.model.modelName, method: "read", args: [id, this.model.fieldNames], context: this.context, - }).then(records => { + }).then((records) => { var new_event = this.renderer.event_data_transform(records[0]); var items = this.renderer.timeline.itemsData; items.add(new_event); @@ -316,7 +316,7 @@ odoo.define("web_timeline.TimelineController", function(require) { * Triggered upon completion of writing a record. * @param {ControllerOptions} options */ - write_completed: function(options) { + write_completed: function (options) { const params = { domain: this.renderer.last_domains, context: this.context, @@ -330,7 +330,7 @@ odoo.define("web_timeline.TimelineController", function(require) { * @param {EventObject} event * @returns {jQuery.Deferred} */ - remove_completed: function(event) { + remove_completed: function (event) { return this._rpc({ model: this.modelName, method: "unlink", diff --git a/web_timeline/static/src/js/timeline_model.js b/web_timeline/static/src/js/timeline_model.js index 1bcbb36e8..c71749c42 100644 --- a/web_timeline/static/src/js/timeline_model.js +++ b/web_timeline/static/src/js/timeline_model.js @@ -1,14 +1,14 @@ -odoo.define("web_timeline.TimelineModel", function(require) { +odoo.define("web_timeline.TimelineModel", function (require) { "use strict"; const AbstractModel = require("web.AbstractModel"); const TimelineModel = AbstractModel.extend({ - init: function() { + init: function () { this._super.apply(this, arguments); }, - load: function(params) { + load: function (params) { this.modelName = params.modelName; this.fieldNames = params.fieldNames; if (!this.preload_def) { @@ -51,14 +51,14 @@ odoo.define("web_timeline.TimelineModel", function(require) { * @private * @returns {jQuery.Deferred} */ - _loadTimeline: function() { + _loadTimeline: function () { return this._rpc({ model: this.modelName, method: "search_read", context: this.data.context, fields: this.fieldNames, domain: this.data.domain, - }).then(events => { + }).then((events) => { this.data.data = events; this.data.rights = { unlink: this.unlink_right, diff --git a/web_timeline/static/src/js/timeline_renderer.js b/web_timeline/static/src/js/timeline_renderer.js index e773986c7..e2dcddb48 100644 --- a/web_timeline/static/src/js/timeline_renderer.js +++ b/web_timeline/static/src/js/timeline_renderer.js @@ -1,5 +1,5 @@ /* global vis, py */ -odoo.define("web_timeline.TimelineRenderer", function(require) { +odoo.define("web_timeline.TimelineRenderer", function (require) { "use strict"; const AbstractRenderer = require("web.AbstractRenderer"); @@ -24,7 +24,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { "click .oe_timeline_button_scale_year": "_onScaleYearClicked", }), - init: function(parent, state, params) { + init: function (parent, state, params) { this._super.apply(this, arguments); this.modelName = params.model; this.mode = params.mode; @@ -45,7 +45,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { /** * @override */ - start: function() { + start: function () { const attrs = this.arch.attrs; this.current_window = { start: new moment(), @@ -66,7 +66,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { /** * Triggered when the timeline is attached to the DOM. */ - on_attach_callback: function() { + on_attach_callback: function () { const height = this.$el.parent().height() - this.$(".oe_timeline_buttons").height(); if (height > this.min_height && this.timeline) { @@ -79,7 +79,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { /** * @override */ - _render: function() { + _render: function () { return Promise.resolve().then(() => { // Prevent Double Rendering on Updates if (!this.timeline) { @@ -94,7 +94,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - _onTodayClicked: function() { + _onTodayClicked: function () { this.current_window = { start: new moment(), end: new moment().add(24, "hours"), @@ -110,7 +110,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - _onScaleDayClicked: function() { + _onScaleDayClicked: function () { this._scaleCurrentWindow(24); }, @@ -119,7 +119,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - _onScaleWeekClicked: function() { + _onScaleWeekClicked: function () { this._scaleCurrentWindow(24 * 7); }, @@ -128,7 +128,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - _onScaleMonthClicked: function() { + _onScaleMonthClicked: function () { this._scaleCurrentWindow( 24 * moment(this.current_window.start).daysInMonth() ); @@ -139,7 +139,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - _onScaleYearClicked: function() { + _onScaleYearClicked: function () { this._scaleCurrentWindow( 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. * @private */ - _scaleCurrentWindow: function(factor) { + _scaleCurrentWindow: function (factor) { if (this.timeline) { this.current_window = this.timeline.getWindow(); this.current_window.end = moment(this.current_window.start).add( @@ -167,7 +167,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - _computeMode: function() { + _computeMode: function () { if (this.mode) { let start = false, end = false; @@ -200,7 +200,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - init_timeline: function() { + init_timeline: function () { this._computeMode(); this.options.editable = { // 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); if (this.arch.children.length) { 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); } @@ -249,7 +249,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - draw_canvas: function() { + draw_canvas: function () { this.canvas.clear(); if (this.dependency_arrow) { this.draw_dependencies(); @@ -261,7 +261,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * * @private */ - draw_dependencies: function() { + draw_dependencies: function () { const items = this.timeline.itemSet.items; const datas = this.timeline.itemsData; if (!items || !datas) { @@ -292,7 +292,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {Object} options.line_width The width of the line * @private */ - draw_dependency: function(from, to, options) { + draw_dependency: function (from, to, options) { if (!from.displayed || !to.displayed) { return; } @@ -317,18 +317,18 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @private * @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"); return this._rpc({ model: this.modelName, method: "name_get", args: [ids], context: this.getSession().user_context, - }).then(names => { - const nevents = _.map(events, event => + }).then((names) => { + const nevents = _.map(events, (event) => _.extend( { - __name: _.detect(names, name => name[0] === event.id)[1], + __name: _.detect(names, (name) => name[0] === event.id)[1], }, event ) @@ -345,7 +345,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {Boolean} adjust_window * @private */ - on_data_loaded_2: function(events, group_bys, adjust_window) { + on_data_loaded_2: function (events, group_bys, adjust_window) { const data = []; this.grouped_by = group_bys; for (const evt of events) { @@ -371,7 +371,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @private * @returns {Array} */ - split_groups: function(events, group_bys) { + split_groups: function (events, group_bys) { if (group_bys.length === 0) { return events; } @@ -383,7 +383,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { if (group_name instanceof Array) { const group = _.find( groups, - existing_group => existing_group.id === group_name[0] + (existing_group) => existing_group.id === group_name[0] ); if (_.isUndefined(group)) { groups.push({ @@ -403,7 +403,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {TransformEvent} evt * @returns {Object} */ - _get_event_dates: function(evt) { + _get_event_dates: function (evt) { let date_start = new moment(); let date_stop = null; @@ -433,10 +433,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { } if (!date_stop && date_delay) { - date_stop = date_start - .clone() - .add(date_delay, "hours") - .toDate(); + date_stop = date_start.clone().add(date_delay, "hours").toDate(); } return [date_start, date_stop]; @@ -449,7 +446,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @private * @returns {Object} */ - event_data_transform: function(evt) { + event_data_transform: function (evt) { const [date_start, date_stop] = this._get_event_dates(evt); let group = evt[this.last_group_bys[0]]; if (group && group instanceof Array) { @@ -493,7 +490,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @private * @returns {String} Rendered template */ - render_timeline_item: function(evt) { + render_timeline_item: function (evt) { if (this.qweb.has_template("timeline-item")) { return this.qweb.render("timeline-item", { record: evt, @@ -512,7 +509,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {ClickEvent} e * @private */ - on_group_click: function(e) { + on_group_click: function (e) { if (e.what === "group-label" && e.group !== -1) { this._trigger( e, @@ -531,7 +528,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {Function} callback * @private */ - on_update: function(item, callback) { + on_update: function (item, callback) { this._trigger(item, callback, "onUpdate"); }, @@ -542,7 +539,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {Function} callback * @private */ - on_move: function(item, callback) { + on_move: function (item, callback) { this._trigger(item, callback, "onMove"); }, @@ -553,7 +550,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {Function} callback * @private */ - on_remove: function(item, callback) { + on_remove: function (item, callback) { this._trigger(item, callback, "onRemove"); }, @@ -564,7 +561,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {Function} callback * @private */ - on_add: function(item, callback) { + on_add: function (item, callback) { this._trigger(item, callback, "onAdd"); }, @@ -576,7 +573,7 @@ odoo.define("web_timeline.TimelineRenderer", function(require) { * @param {String} trigger * @private */ - _trigger: function(item, callback, trigger) { + _trigger: function (item, callback, trigger) { this.trigger_up(trigger, { item: item, callback: callback, diff --git a/web_timeline/static/src/js/timeline_view.js b/web_timeline/static/src/js/timeline_view.js index f69d34397..24b9b4955 100644 --- a/web_timeline/static/src/js/timeline_view.js +++ b/web_timeline/static/src/js/timeline_view.js @@ -4,7 +4,7 @@ * Copyright 2016 Pedro M. Baeza * 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"; const core = require("web.core"); @@ -35,7 +35,7 @@ odoo.define("web_timeline.TimelineView", function(require) { /** * @override */ - init: function(viewInfo, params) { + init: function (viewInfo, params) { this._super.apply(this, arguments); this.modelName = this.controllerParams.modelName; @@ -65,8 +65,8 @@ odoo.define("web_timeline.TimelineView", function(require) { } const archFieldNames = _.map( - _.filter(this.arch.children, item => item.tag === "field"), - item => item.attrs.name + _.filter(this.arch.children, (item) => item.tag === "field"), + (item) => item.attrs.name ); fieldNames = _.union(fieldNames, archFieldNames); @@ -119,7 +119,7 @@ odoo.define("web_timeline.TimelineView", function(require) { this.withSearchPanel = false; }, - _preapre_vis_timeline_options: function(attrs) { + _preapre_vis_timeline_options: function (attrs) { return { groupOrder: this.group_order, orientation: "both", @@ -140,7 +140,7 @@ odoo.define("web_timeline.TimelineView", function(require) { * @param {Object} grp2 * @returns {Integer} */ - group_order: function(grp1, grp2) { + group_order: function (grp1, grp2) { // Display non grouped elements first if (grp1.id === -1) { return -1; @@ -158,12 +158,12 @@ odoo.define("web_timeline.TimelineView", function(require) { * @private * @returns {Array} */ - parse_colors: function() { + parse_colors: function () { if (this.arch.attrs.colors) { return _(this.arch.attrs.colors.split(";")) .chain() .compact() - .map(color_pair => { + .map((color_pair) => { const pair = color_pair.split(":"); const color = pair[0]; const expr = pair[1];