diff options
| author | Gery Debongnie <ged@openerp.com> | 2013-11-24 22:48:09 +0100 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2013-11-24 22:48:09 +0100 |
| commit | 2ff7dd16fe8446493efcb5aad6df06ce858de229 (patch) | |
| tree | bcc97a33fee2d039f8d8a4dfdb4cbd1117560690 /addons/web_graph/static/src | |
| parent | 5227f89396de7527906e7708d3559cc6576cabfe (diff) | |
[REF] some more simplifications, using the symetry between cols and rows in addon web_graph
bzr revid: ged@openerp.com-20131124214809-k08p4x4h0wm4owmq
Diffstat (limited to 'addons/web_graph/static/src')
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 38 | ||||
| -rw-r--r-- | addons/web_graph/static/src/xml/web_graph.xml | 21 |
2 files changed, 15 insertions, 44 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 0ab02ccb51b..146a9d3e865 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -32,30 +32,17 @@ instance.web_graph.GraphView = instance.web.View.extend({ 'click .web_graph_click' : function (event) { event.preventDefault(); - if (event.target.attributes['data-row-id'] !== undefined) { - this.handle_header_event({type:'row', event:event}); - - } - if (event.target.attributes['data-col-id'] !== undefined) { - this.handle_header_event({type:'col', event:event}); - } + var id = event.target.attributes['data-id'].nodeValue; + this.handle_header_event({id:id, event:event}); }, 'click a.field-selection' : function (event) { - var id, + var id = event.target.attributes['data-id'].nodeValue, field_id = event.target.attributes['data-field-id'].nodeValue; event.preventDefault(); this.dropdown.remove(); - if (event.target.attributes['data-row-id'] !== undefined) { - id = event.target.attributes['data-row-id'].nodeValue; - this.pivot_table.expand(id, field_id) - .then(this.proxy('draw_table')); - } - if (event.target.attributes['data-col-id'] !== undefined) { - id = event.target.attributes['data-col-id'].nodeValue; - this.pivot_table.expand(id, field_id) - .then(this.proxy('draw_table')); - } + this.pivot_table.expand(id, field_id) + .then(this.proxy('draw_table')); }, 'click label.graph_swap_axis' : function (event) { @@ -194,7 +181,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ handle_header_event: function (options) { var pivot = this.pivot_table, - id = options.event.target.attributes['data-' + options.type + '-id'].nodeValue, + id = options.id, header = pivot.get_header(id); if (header.is_expanded) { @@ -206,10 +193,9 @@ instance.web_graph.GraphView = instance.web.View.extend({ pivot.expand(id, field).then(this.proxy('draw_table')); } else { this.display_dropdown({id:header.id, - type: options.type, - target: $(event.target), - x: event.pageX, - y: event.pageY}); + target: $(options.event.target), + x: options.event.pageX, + y: options.event.pageY}); } } }, @@ -220,10 +206,10 @@ instance.web_graph.GraphView = instance.web.View.extend({ already_grouped = pivot.rows.groupby.concat(pivot.cols.groupby), possible_groups = _.difference(self.data.important_fields, already_grouped), dropdown_options = { + header_id: options.id, fields: _.map(possible_groups, function (field) { return {id: field, value: self.data.fields[field].string}; })}; - dropdown_options[options.type + '_id'] = options.id; this.dropdown = $(QWeb.render('field_selection', dropdown_options)); options.target.after(this.dropdown); @@ -272,7 +258,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ function make_col_header (col) { var cell = self.make_border_cell(col.width, col.height); - return cell.append(self.make_header_title(col).attr('data-col-id', col.id)); + return cell.append(self.make_header_title(col).attr('data-id', col.id)); } function make_cells (queue, level) { @@ -306,7 +292,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ pivot = this.pivot_table, html_row = $('<tr></tr>'), row_header = this.make_border_cell(1,1) - .append(this.make_header_title(row).attr('data-row-id', row.id)) + .append(this.make_header_title(row).attr('data-id', row.id)) .addClass('graph_border'); for (var i in _.range(row.path.length)) { diff --git a/addons/web_graph/static/src/xml/web_graph.xml b/addons/web_graph/static/src/xml/web_graph.xml index 4881514a8a1..d9353778bcf 100644 --- a/addons/web_graph/static/src/xml/web_graph.xml +++ b/addons/web_graph/static/src/xml/web_graph.xml @@ -22,30 +22,15 @@ <div class="graph_main_content"></div> </t> - <t t-name="pivot_table"> - <table></table> - </t> - - <t t-name="chart_view"> - <div class="graph_chart"></div> - </t> - <t t-name="field_selection"> <div class="btn-group"> <span class="btn btn-default field-selection dropdown-toggle" data-toggle="dropdown"></span> <ul class="dropdown-menu" role="menu"> <t t-foreach="fields" t-as="field"> <li> - <t t-if="row_id"> - <a class="field-selection" t-att-data-field-id="field.id" t-att-data-row-id="row_id" href="#"> - <t t-esc="field.value"/> - </a> - </t> - <t t-if="col_id"> - <a class="field-selection" t-att-data-field-id="field.id" t-att-data-col-id="col_id" href="#"> - <t t-esc="field.value"/> - </a> - </t> + <a class="field-selection" t-att-data-field-id="field.id" t-att-data-id="header_id" href="#"> + <t t-esc="field.value"/> + </a> </li> </t> <li class="divider"></li> |
