[IMP] supports columns folding in pivottable (addon web_graph)
authorGery Debongnie <ged@openerp.com>
Wed, 20 Nov 2013 12:46:32 +0000 (13:46 +0100)
committerGery Debongnie <ged@openerp.com>
Wed, 20 Nov 2013 12:46:32 +0000 (13:46 +0100)
bzr revid: ged@openerp.com-20131120124632-ydjuvtcvou14qivo

addons/web_graph/static/src/js/graph.js

index 6e9e20d..d99bffb 100644 (file)
@@ -613,6 +613,55 @@ var PivotTable = instance.web.Widget.extend({
         });
     },
 
+    fold_col: function (col_id) {
+        var self = this;
+        var col = this.get_col(col_id);
+
+        _.each(col.children, function (child_col) {
+            self.remove_col(child_col);
+        });
+        col.children = [];
+
+        _.each(col.cells, function (cell) {
+            cell.td.css('display','table-cell');
+        });
+        col.expanded = false;
+        // row.html.find('.icon-minus-sign')
+        //     .removeClass('icon-minus-sign')
+        //     .addClass('icon-plus-sign');
+
+        var fold_levels = _.map(self.cols, function(g) {return g.path.length;});
+        var new_groupby_length = _.max(fold_levels); 
+
+        this.data.col_groupby.splice(new_groupby_length);
+        this.make_top_headers();
+        this.draw_top_headers();
+
+            
+    },
+    
+    remove_col: function (col_id) {
+        var self = this;
+        var col = this.get_col(col_id);
+
+        _.each(col.children, function (child_col) {
+            self.remove_col(child_col);
+        });
+
+        _.each(col.cells, function (cell) {
+            cell.td.remove();
+        });
+        // row.html.remove();
+        removeFromArray(this.cols, col);
+
+        // _.each(this.cols, function (col) {
+        //     col.cells = _.filter(col.cells, function (cell) {
+        //         return cell.row_id !== row_id;
+        //     });
+        // });
+    },
+
+
 });
 
 };