From c6962de141c0e77a76ab1aa1cd8931ab3f23719b Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Mar 2015 17:10:29 +0100 Subject: [PATCH] [IMP] better modularity --- .../src/js/web_widget_x2many_2d_matrix.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js b/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js index 12a56c8c..d4828b47 100644 --- a/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js +++ b/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js @@ -110,12 +110,7 @@ openerp.web_widget_x2many_2d_matrix = function(instance) // setup data structure _.each(rows, function(row) { - var x = self.get_field_value(row, self.field_x_axis), - y = self.get_field_value(row, self.field_y_axis); - self.by_x_axis[x] = self.by_x_axis[x] || {}; - self.by_y_axis[y] = self.by_y_axis[y] || {}; - self.by_x_axis[x][y] = row; - self.by_y_axis[y][x] = row; + self.add_xy_row(row); _.each(read_many2one, function(rows, field) { if(!_.isArray(row[field])) @@ -154,6 +149,17 @@ openerp.web_widget_x2many_2d_matrix = function(instance) }); }, + // to whatever needed to setup internal data structure + add_xy_row: function(row) + { + var x = this.get_field_value(row, this.field_x_axis), + y = this.get_field_value(row, this.field_y_axis); + this.by_x_axis[x] = this.by_x_axis[x] || {}; + this.by_y_axis[y] = this.by_y_axis[y] || {}; + this.by_x_axis[x][y] = row; + this.by_y_axis[y][x] = row; + }, + // get x axis values in the correct order get_x_axis_values: function() {