summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/graph/graph_model.js
diff options
context:
space:
mode:
authorMathieu Duckerts-Antoine <dam@odoo.com>2018-06-11 15:45:30 +0200
committerGéry Debongnie <ged@odoo.com>2018-06-12 09:22:20 +0200
commite1aac71769c8d07a358b2d8717efa28248e18a34 (patch)
treeba63c14ad7aee42fc1e5fbd9b9b25f31ef1e69cc /addons/web/static/src/js/views/graph/graph_model.js
parent7bf5dd687be3919f6add10b1ac59a9cdee824632 (diff)
[IMP] web: add support for interval selection in groupbys
In this commit, we extend the search view to allow the selection of some intervals for date or datetime fields in groupby menu. The valid intervals are day, week, month, quarter, and year. It is also possible to add a button 'Group By' in the control panel owned by a graph view in case it is declared 'embedded' (e.g. in a dashboard view). Note that have three new generic reusable widgets have been introduced in this commit: DropdownMenu, GroupByMenu, and FiltersMenu.
Diffstat (limited to 'addons/web/static/src/js/views/graph/graph_model.js')
-rw-r--r--addons/web/static/src/js/views/graph/graph_model.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_model.js b/addons/web/static/src/js/views/graph/graph_model.js
index 2ffbd4c4cf8..dd7d0efa28f 100644
--- a/addons/web/static/src/js/views/graph/graph_model.js
+++ b/addons/web/static/src/js/views/graph/graph_model.js
@@ -51,6 +51,8 @@ return AbstractModel.extend({
* @param {string[]} params.groupBys a list of valid field names
* @param {Object} params.context
* @param {string[]} params.domain
+ * @param {Object} params.intervalMapping object linking fieldNames with intervals.
+ * this could be useful to simplify the code. For now this parameter is not used.
* @returns {Deferred} The deferred does not return a handle, we don't need
* to keep track of various entities.
*/
@@ -62,6 +64,12 @@ return AbstractModel.extend({
this.chart = {
data: [],
groupedBy: params.groupedBy.length ? params.groupedBy : groupBys,
+ // this parameter is not used anywhere for now.
+ // the idea would be to seperate intervals from
+ // fieldnames in groupbys. This could be done
+ // in graph view only or everywhere but this is
+ // a big refactoring.
+ intervalMapping: params.intervalMapping,
measure: params.context.graph_measure || params.measure,
mode: params.context.graph_mode || params.mode,
domain: params.domain,
@@ -97,6 +105,9 @@ return AbstractModel.extend({
if ('groupBy' in params) {
this.chart.groupedBy = params.groupBy.length ? params.groupBy : this.initialGroupBys;
}
+ if ('intervalMapping' in params) {
+ this.chart.intervalMapping = params.intervalMapping;
+ }
if ('measure' in params) {
this.chart.measure = params.measure;
}