Browse Source

[8.0] render axis values in received order

pull/495/head
Cédric Pigeon 8 years ago
parent
commit
62539e36f9
  1. 1
      web_widget_x2many_2d_matrix/README.rst
  2. 12
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

1
web_widget_x2many_2d_matrix/README.rst

@ -28,6 +28,7 @@ result could look like this:
The beauty of this is that you have an arbitrary amount of columns with this The beauty of this is that you have an arbitrary amount of columns with this
widget, trying to get this in standard x2many lists involves some quite ugly widget, trying to get this in standard x2many lists involves some quite ugly
hacks. hacks.
Note: The order of axis values depends on their order in the matrix you provide.
Usage Usage
===== =====

12
web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

@ -14,6 +14,8 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
// those will be filled with rows from the dataset // those will be filled with rows from the dataset
by_x_axis: {}, by_x_axis: {},
by_y_axis: {}, by_y_axis: {},
by_x_axis_sorted: [],
by_y_axis_sorted: [],
by_id: {}, by_id: {},
// configuration values // configuration values
field_x_axis: 'x', field_x_axis: 'x',
@ -76,6 +78,8 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
var self = this, var self = this,
result = this._super.apply(this, arguments); result = this._super.apply(this, arguments);
self.by_x_axis_sorted = []
self.by_y_axis_sorted = []
self.by_x_axis = {}; self.by_x_axis = {};
self.by_y_axis = {}; self.by_y_axis = {};
self.by_id = {}; self.by_id = {};
@ -206,6 +210,10 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
} }
return true; return true;
}); });
if(this.by_x_axis_sorted.indexOf(x) == -1)
this.by_x_axis_sorted.push(x)
if(this.by_y_axis_sorted.indexOf(y) == -1)
this.by_y_axis_sorted.push(y)
this.by_x_axis[x] = this.by_x_axis[x] || {}; this.by_x_axis[x] = this.by_x_axis[x] || {};
this.by_y_axis[y] = this.by_y_axis[y] || {}; this.by_y_axis[y] = this.by_y_axis[y] || {};
this.by_x_axis[x][y] = row; this.by_x_axis[x][y] = row;
@ -216,13 +224,13 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
// get x axis values in the correct order // get x axis values in the correct order
get_x_axis_values: function() get_x_axis_values: function()
{ {
return _.keys(this.by_x_axis);
return this.by_x_axis_sorted
}, },
// get y axis values in the correct order // get y axis values in the correct order
get_y_axis_values: function() get_y_axis_values: function()
{ {
return _.keys(this.by_y_axis);
return this.by_y_axis_sorted
}, },
// get the label for a value on the x axis // get the label for a value on the x axis

Loading…
Cancel
Save