From 31374c2eeffe824188b1a43768bc216a86d29b03 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 28 Jan 2014 12:10:22 +0100 Subject: [PATCH 1/5] [IMP] this commit translates the hardcoded strings that appears in graph view (addon web_graph) bzr revid: ged@openerp.com-20140128111022-ghoxwvlmywzr2yke --- .../web_graph/static/src/js/graph_widget.js | 31 ++++++++++--------- addons/web_graph/static/src/js/pivot_table.js | 9 ++++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index 454af202593..c17fd0bcf43 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -4,6 +4,9 @@ (function () { 'use strict'; var QWeb = openerp.web.qweb; +var _lt = openerp.web._lt; +var _t = openerp.web._t; + nv.dev = false; // sets nvd3 library in production mode openerp.web_graph.Graph = openerp.web.Widget.extend({ @@ -39,7 +42,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return this.model.call('fields_get', []).then(function (f) { self.fields = f; - self.fields.__count = {field:'__count', type: 'integer', string:'Quantity'}; + self.fields.__count = {field:'__count', type: 'integer', string:_t('Quantity')}; self.important_fields = self.get_search_fields(); self.measure_list = self.get_measures(); self.add_measures_to_options(); @@ -381,11 +384,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Drawing the table // ---------------------------------------------------------------------- draw_table: function () { - this.pivot.main_row().title = 'Total'; + this.pivot.main_row().title = _t('Total'); if (this.pivot.measures.length == 1) { this.pivot.main_col().title = this.pivot.measures[0].string; } else { - this.pivot.main_col().title = this.title; + this.pivot.main_col().title = _t(this.title); } this.draw_top_headers(); _.each(this.pivot.rows.headers, this.proxy('draw_row')); @@ -449,7 +452,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ } else { make_cells(pivot.main_col().children, 1); if (pivot.get_cols_leaves().length > 1) { - header_cells[0].push(self.make_border_cell(pivot.measures.length, height, true).text('Total').css('font-weight', 'bold')); + header_cells[0].push(self.make_border_cell(pivot.measures.length, height, true).text(_t('Total')).css('font-weight', 'bold')); } } @@ -554,8 +557,8 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // No groupby if ((dim_x === 0) && (dim_y === 0)) { - data = [{key: 'Total', values:[{ - x: 'Total', + data = [{key: _t('Total'), values:[{ + x: _t('Total'), y: this.pivot.get_total(), }]}]; // Only column groupbys @@ -570,7 +573,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ } else if ((dim_x === 1) && (dim_y === 0)) { data = _.map(this.pivot.main_row().children, function (pt) { var value = self.pivot.get_total(pt), - title = (pt.title !== undefined) ? pt.title : 'Undefined'; + title = (pt.title !== undefined) ? pt.title : _t('Undefined'); return {x: title, y: value}; }); data = [{key: self.pivot.measures[0].string, values:data}]; @@ -579,24 +582,24 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ data = _.map(this.pivot.get_cols_with_depth(1), function (colhdr) { var values = _.map(self.pivot.get_rows_with_depth(1), function (header) { return { - x: header.title || 'Undefined', + x: header.title || _t('Undefined'), y: self.pivot.get_values(header.id, colhdr.id)[0] || 0 }; }); - return {key: colhdr.title || 'Undefined', values: values}; + return {key: colhdr.title || _t('Undefined'), values: values}; }); // At least two row groupby } else { var keys = _.uniq(_.map(this.pivot.get_rows_with_depth(2), function (hdr) { - return hdr.title || 'Undefined'; + return hdr.title || _t('Undefined'); })); data = _.map(keys, function (key) { var values = _.map(self.pivot.get_rows_with_depth(1), function (hdr) { var subhdr = _.find(hdr.children, function (child) { - return ((child.title === key) || ((child.title === undefined) && (key === 'Undefined'))); + return ((child.title === key) || ((child.title === undefined) && (key === _t('Undefined')))); }); return { - x: hdr.title || 'Undefined', + x: hdr.title || _t('Undefined'), y: (subhdr) ? self.pivot.get_total(subhdr)[0] : 0 }; }); @@ -640,7 +643,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return {x: row.title, y: self.pivot.get_values(row.id,col.id)[0] || 0}; }); var title = _.map(col.path, function (p) { - return p || 'Undefined'; + return p || _t('Undefined'); }).join('/'); if (dim_y === 0) { title = self.pivot.measures[0].string; @@ -670,7 +673,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ dim_x = this.pivot.rows.groupby.length; var data = _.map(this.pivot.get_rows_leaves(), function (row) { var title = _.map(row.path, function (p) { - return p || 'Undefined'; + return p || _t('Undefined'); }).join('/'); if (dim_x === 0) { title = self.measure_label; diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js index a5bfba3c09a..89ca36f3b61 100644 --- a/addons/web_graph/static/src/js/pivot_table.js +++ b/addons/web_graph/static/src/js/pivot_table.js @@ -4,6 +4,9 @@ (function () { 'use strict'; +var _lt = openerp.web._lt; +var _t = openerp.web._t; + // PivotTable requires a call to update_data after initialization openerp.web_graph.PivotTable = openerp.web.Class.extend({ @@ -13,7 +16,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ this.no_data = true; this.model = model; this.fields = fields; - this.fields.__count = {type: 'integer', string:'Quantity'}; + this.fields.__count = {type: 'integer', string:_t('Quantity')}; this.measures = options.measures || []; this.rows = { groupby: options.row_groupby, headers: null }; this.cols = { groupby: options.col_groupby, headers: null }; @@ -397,11 +400,11 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ grouped_on = attrs.grouped_on ? this.raw_field(attrs.grouped_on) : false; if (value === false) { - group.attributes.value = 'undefined'; + group.attributes.value = _t('undefined'); } else if (grouped_on && this.fields[grouped_on].type === 'selection') { var selection = this.fields[grouped_on].selection, value_lookup = _.where(selection, {0:value}); - group.attributes.value = value_lookup ? value_lookup[0][1] : 'undefined'; + group.attributes.value = value_lookup ? value_lookup[0][1] : _t('undefined'); } else if (value instanceof Array) { group.attributes.value = value[1]; } From ad76309fbe29f6d4d2d26393bc8d2b1c595a124f Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 28 Jan 2014 14:26:25 +0100 Subject: [PATCH 2/5] [IMP] makes the graph view in pivot table mode always display 'Total' instead of the current measure/title (addon web_graph) bzr revid: ged@openerp.com-20140128132625-pk21iuhuffvx6814 --- addons/web_graph/static/src/js/graph_widget.js | 7 ------- addons/web_graph/static/src/js/pivot_table.js | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index c17fd0bcf43..100ae21acce 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -21,7 +21,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ this.domain = domain; this.mode = options.mode || 'pivot'; // pivot, bar, pie, line this.heatmap_mode = options.heatmap_mode || 'none'; - this.title = options.title || 'Graph'; this.visible_ui = options.visible_ui || true; this.bar_ui = options.bar_ui || 'group'; this.graph_view = options.graph_view || null; @@ -384,12 +383,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Drawing the table // ---------------------------------------------------------------------- draw_table: function () { - this.pivot.main_row().title = _t('Total'); - if (this.pivot.measures.length == 1) { - this.pivot.main_col().title = this.pivot.measures[0].string; - } else { - this.pivot.main_col().title = _t(this.title); - } this.draw_top_headers(); _.each(this.pivot.rows.headers, this.proxy('draw_row')); }, diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js index 89ca36f3b61..fccb1e4bffa 100644 --- a/addons/web_graph/static/src/js/pivot_table.js +++ b/addons/web_graph/static/src/js/pivot_table.js @@ -238,7 +238,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ }, make_header: function (group, parent) { - var title = parent ? group.attributes.value : ''; + var title = parent ? group.attributes.value : _t('Total'); return { id: _.uniqueId(), path: parent ? parent.path.concat(title) : [], From f27c1df4d2d8c1fe809b4b7c61d4ddfedc6de569 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 28 Jan 2014 16:11:13 +0100 Subject: [PATCH 3/5] [IMP] css changes to improve look and usability of pivot table view (addon web_graph) bzr revid: ged@openerp.com-20140128151113-g8yxl3lphpht4d89 --- addons/web_graph/static/src/css/graph.css | 45 ++++++++++++++----- .../web_graph/static/src/js/graph_widget.js | 1 + 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/addons/web_graph/static/src/css/graph.css b/addons/web_graph/static/src/css/graph.css index 09e86c1de6b..b7d82597c4c 100644 --- a/addons/web_graph/static/src/css/graph.css +++ b/addons/web_graph/static/src/css/graph.css @@ -6,6 +6,15 @@ border-bottom: 1px solid #ccc; padding: 6px 8px; text-align: right; + color: black; +} + +.graph_main_content td:first-child { + background-color: rgb(240, 238, 238); +} + +.graph_main_content table { + margin-top: 10px; } .graph_measure_selection .oe_selected { @@ -26,30 +35,44 @@ .graph_main_content th { font-size: 13px; font-weight: normal; - color: #039; padding: 10px 8px; vertical-align: top; -} - -.graph_main_content thead { - border: 1px solid #6678b1; - border-bottom: 2px solid #6678b1; + color: black; } .graph_main_content tbody td{ - border: 1px solid #ccc; + border: 1px solid #b8b8b8; +} + +.graph_main_content tbody { + border-top: 1px solid black; +} + +.graph_main_content thead { + background-color: rgb(240, 238, 238); + border: 1px solid #b8b8b8; +} + +.graph_main_content thead th { + border-left: 1px solid #b8b8b8; +} + +div.graph_widget { + padding:10px; +} + +.oe_dashboard div.graph_widget { + padding:0; } td.graph_border { - color: #039; text-align: left; - border-right: 1px solid #6678b1; white-space: nowrap; } -.graph_main_content tbody tr:hover td +.graph_main_content table:not(.heatmap) tr:hover td:not(:first-child) { - color: #009; + background-color: rgb(245, 245, 245); } span.field-selection { diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index 100ae21acce..ef547e22632 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -362,6 +362,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ this.$('.graph_main_content svg').remove(); this.$('.graph_main_content div').remove(); this.table.empty(); + this.table.toggleClass('heatmap', this.heatmap_mode !== 'none') this.width = this.$el.width(); this.height = Math.min(Math.max(document.documentElement.clientHeight - 116 - 60, 250), Math.round(0.8*this.$el.width())); From 9344f2f851823624793359c366fb6beeb1ab0242 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 28 Jan 2014 16:11:57 +0100 Subject: [PATCH 4/5] [FIX] changes the hardcoded string 'undefined' into 'Undefined' in pivot table (addon web_graph) bzr revid: ged@openerp.com-20140128151157-3opcfcockwrgr3kx --- addons/web_graph/static/src/js/pivot_table.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js index fccb1e4bffa..770519e52c2 100644 --- a/addons/web_graph/static/src/js/pivot_table.js +++ b/addons/web_graph/static/src/js/pivot_table.js @@ -400,11 +400,11 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ grouped_on = attrs.grouped_on ? this.raw_field(attrs.grouped_on) : false; if (value === false) { - group.attributes.value = _t('undefined'); + group.attributes.value = _t('Undefined'); } else if (grouped_on && this.fields[grouped_on].type === 'selection') { var selection = this.fields[grouped_on].selection, value_lookup = _.where(selection, {0:value}); - group.attributes.value = value_lookup ? value_lookup[0][1] : _t('undefined'); + group.attributes.value = value_lookup ? value_lookup[0][1] : _t('Undefined'); } else if (value instanceof Array) { group.attributes.value = value[1]; } From a482809cf90f35b00f420e30829ed1c06769649d Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 10:23:59 +0100 Subject: [PATCH 5/5] [FIX] correctly compute the attribute 'length' in a query_group so that the list view properly display groups when grouped by 'date:interval' (addon web) bzr revid: ged@openerp.com-20140129092359-20kw6n3sxqobiqu5 --- addons/web/static/src/js/data.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index a2e3e53db3e..4a0807a727a 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -234,9 +234,9 @@ instance.web.QueryGroup = instance.web.Class.extend({ this.model = new instance.web.Model( model, fixed_group.__context, fixed_group.__domain); - var group_size = fixed_group[grouping_field + '_count'] || fixed_group.__count || 0; + var raw_field = grouping_field && grouping_field.split(':')[0]; + var group_size = fixed_group[raw_field + '_count'] || fixed_group.__count || 0; var leaf_group = fixed_group.__context.group_by.length === 0; - var raw_field = (_.contains(grouping_field, ':')) ? grouping_field.split(':')[0] : grouping_field; this.attributes = { folded: !!(fixed_group.__fold),