[REF] some more simplifications, using the symetry between cols and rows in addon web_graph
bzr revid: ged@openerp.com-20131124214809-k08p4x4h0wm4owmq
This commit is contained in:
parent
5227f89396
commit
2ff7dd16fe
|
@ -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)) {
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue