From ccda9edc825115769eef99a21d72d36fed37ccfb Mon Sep 17 00:00:00 2001 From: Cyril VINH-TUNG Date: Mon, 7 Jan 2019 22:40:02 -1000 Subject: [PATCH] [web_timeline][IMP] Add margin support in web_timeline (#1135) --- web_timeline/README.rst | 5 +++++ web_timeline/__manifest__.py | 2 +- web_timeline/readme/CONFIGURE.rst | 4 ++++ web_timeline/static/src/js/timeline_view.js | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/web_timeline/README.rst b/web_timeline/README.rst index eaaf4eef..c88d1ee4 100755 --- a/web_timeline/README.rst +++ b/web_timeline/README.rst @@ -56,6 +56,10 @@ the possible attributes for the tag: +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | mode | No | Specifies the initial visible window. Available values are: 'day' to display the current day, 'week', 'month' and 'fit'. Default value is 'fit' to adjust the visible window such that it fits all items. | +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| margin | No | Specifies the margins around the items. It should respect the JSON format. For example '{"item":{"horizontal":-10}}'. Available values are: '{"axis":}' (The minimal margin in pixels between items and the time axis) | +| | | '{"item":}' (The minimal margin in pixels between items in both horizontal and vertical direction), '{"item":{"horizontal":}}' (The minimal horizontal margin in pixels between items), | +| | | '{"item":{"vertical":}}' (The minimal vertical margin in pixels between items), '{"item":{"horizontal":,"vertical":}}' (Combination between horizontal and vertical margins in pixels between items). | ++--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | event_open_popup | No | When set to true, it allows to edit the events in a popup. If not (default value), the record is edited changing to form view. | +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | stack | No | When set to false, items will not be stacked on top of each other such that they do overlap. | @@ -89,6 +93,7 @@ Example: string="Tasks" default_group_by="user_id" event_open_popup="true" + margin='{"item":{"horizontal":-10}}' zoomKey="ctrlKey" colors="#ec7063:user_id == false;#2ecb71:kanban_state=='done';" dependency_arrow="task_dependency_ids"> diff --git a/web_timeline/__manifest__.py b/web_timeline/__manifest__.py index 302c6d2b..e376f9af 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": "12.0.1.0.1", + "version": "12.0.1.0.2", "development_status": "Production/Stable", 'author': 'ACSONE SA/NV, ' 'Tecnativa, ' diff --git a/web_timeline/readme/CONFIGURE.rst b/web_timeline/readme/CONFIGURE.rst index 0d1435fa..09bf110b 100644 --- a/web_timeline/readme/CONFIGURE.rst +++ b/web_timeline/readme/CONFIGURE.rst @@ -16,6 +16,10 @@ the possible attributes for the tag: +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | mode | No | Specifies the initial visible window. Available values are: 'day' to display the current day, 'week', 'month' and 'fit'. Default value is 'fit' to adjust the visible window such that it fits all items. | +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| margin | No | Specifies the margins around the items. It should respect the JSON format. For example '{"item":{"horizontal":-10}}'. Available values are: '{"axis":}' (The minimal margin in pixels between items and the time axis) | +| | | '{"item":}' (The minimal margin in pixels between items in both horizontal and vertical direction), '{"item":{"horizontal":}}' (The minimal horizontal margin in pixels between items), | +| | | '{"item":{"vertical":}}' (The minimal vertical margin in pixels between items), '{"item":{"horizontal":,"vertical":}}' (Combination between horizontal and vertical margins in pixels between items). | ++--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | event_open_popup | No | When set to true, it allows to edit the events in a popup. If not (default value), the record is edited changing to form view. | +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | stack | No | When set to false, items will not be stacked on top of each other such that they do overlap. | diff --git a/web_timeline/static/src/js/timeline_view.js b/web_timeline/static/src/js/timeline_view.js index d61afa3c..a2bff7a1 100644 --- a/web_timeline/static/src/js/timeline_view.js +++ b/web_timeline/static/src/js/timeline_view.js @@ -101,6 +101,7 @@ odoo.define('web_timeline.TimelineView', function (require) { this.no_period = this.date_start === this.date_stop; this.zoomKey = attrs.zoomKey || ''; + this.margin = attrs.margin || '{}'; this.mode = attrs.mode || attrs.default_window || 'fit'; this.min_height = attrs.min_height || 300; @@ -122,6 +123,7 @@ odoo.define('web_timeline.TimelineView', function (require) { multiselect: true, showCurrentTime: true, stack: this.stack, + margin: JSON.parse(this.margin), zoomKey: this.zoomKey }; if (isNullOrUndef(attrs.event_open_popup) || !_.str.toBoolElse(attrs.event_open_popup, true)) {