diff options
| author | Frederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com> | 2014-08-25 16:42:57 +0200 |
|---|---|---|
| committer | Frederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com> | 2014-08-25 16:42:57 +0200 |
| commit | d7f93defb899b2b48a14d679e5dffffdb4a00eff (patch) | |
| tree | f8572183b480477622917a1f504cf49a8e202f6e /addons/web_graph/static/src | |
| parent | 2b67528fe9e366829d44d8aba756bc6e359b4c61 (diff) | |
| parent | 36146b3fadc47543f4b696ab75c31b3459afb15b (diff) | |
Merge branch 'master' into master-pos-new-payment-screen-fva
Conflicts:
addons/point_of_sale/point_of_sale.py
addons/point_of_sale/point_of_sale_view.xml
Diffstat (limited to 'addons/web_graph/static/src')
| -rw-r--r-- | addons/web_graph/static/src/css/graph.css | 39 | ||||
| -rw-r--r-- | addons/web_graph/static/src/js/graph_widget.js | 42 | ||||
| -rw-r--r-- | addons/web_graph/static/src/xml/web_graph.xml | 37 |
3 files changed, 81 insertions, 37 deletions
diff --git a/addons/web_graph/static/src/css/graph.css b/addons/web_graph/static/src/css/graph.css index 6bc628f2eb7..fd6735961e1 100644 --- a/addons/web_graph/static/src/css/graph.css +++ b/addons/web_graph/static/src/css/graph.css @@ -113,6 +113,7 @@ span.field-selection { border-radius: 3px; } + .graph_widget .dropdown-menu li a, .graph_widget .dropdown-menu li a:hover, .graph_widget .dropdown-menu li a:focus { color: black; text-decoration: none; @@ -124,3 +125,41 @@ th.measure_row { padding:0px 5px 0px 5px ; margin:0; } + + +.graph-dropdown-submenu { + position: relative; +} + +.graph-dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + -webkit-border-radius: 0 6px 6px 6px; + -moz-border-radius: 0 6px 6px; + border-radius: 0 6px 6px 6px; +} + +.graph-dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.graph-dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #ccc; + margin-top: 5px; + margin-right: -10px; +} + +.graph-dropdown-submenu:hover>a:after { + border-left-color: #fff; +} + diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index 59f0af95882..db33e567b42 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -57,7 +57,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return this.model.call('fields_get', []).then(function (f) { self.fields = f; self.fields.__count = {field:'__count', type: 'integer', string:_t('Quantity')}; - self.important_fields = self.get_search_fields(); + self.groupby_fields = self.get_groupby_fields(); self.measure_list = self.get_measures(); self.add_measures_to_options(); self.pivot_options.row_groupby = self.create_field_values(self.pivot_options.row_groupby || []); @@ -81,6 +81,25 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ }); }, + get_groupby_fields: function () { + var search_fields = this.get_search_fields(), + search_field_names = _.pluck(search_fields, 'field'), + other_fields = [], + groupable_types = ['many2one', 'char', 'boolean', 'selection', 'date', 'datetime']; + + _.each(this.fields, function (val, key) { + if (!_.contains(search_field_names, key) && + _.contains(groupable_types, val.type) && + val.store === true) { + other_fields.push({ + field: key, + string: val.string, + }); + } + }); + return search_fields.concat(other_fields); + }, + // this method gets the fields that appear in the search view, under the // 'Groupby' heading get_search_fields: function () { @@ -196,7 +215,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ create_field_value: function (f) { var field = (_.contains(f, ':')) ? f.split(':')[0] : f, - groupby_field = _.findWhere(this.important_fields, {field:field}), + groupby_field = _.findWhere(this.groupby_fields, {field:field}), string = groupby_field ? groupby_field.string : this.fields[field].string, result = {field: f, string: string, type: this.fields[field].type }; @@ -309,11 +328,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ this.expand(id); return; } - if (!this.important_fields.length) { + if (!this.groupby_fields.length) { return; } - var fields = _.map(this.important_fields, function (field) { + var fields = _.map(this.groupby_fields, function (field) { return {id: field.field, value: field.string, type:self.fields[field.field.split(':')[0]].type}; }); if (this.dropdown) { @@ -324,7 +343,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ this.dropdown.css({position:'absolute', left:event.originalEvent.layerX, top:event.originalEvent.layerY}); - this.$('.field-selection').next('.dropdown-menu').toggle(); + this.$('.field-selection').next('.dropdown-menu').first().toggle(); }, @@ -423,23 +442,22 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ build_headers: function () { var pivot = this.pivot, nbr_measures = pivot.measures.length, - height = _.max(_.map(pivot.cols.headers, function(g) {return g.path.length;})), + height = _.max(_.map(pivot.cols.headers, function(g) {return g.path.length;})) + 1, rows = []; _.each(pivot.cols.headers, function (col) { - if (col.path.length === 0) { return;} var cell_width = nbr_measures * (col.expanded ? pivot.get_ancestor_leaves(col).length : 1), - cell_height = col.expanded ? 1 : height - col.path.length + 1, + cell_height = col.expanded ? 1 : height - col.path.length, cell = {width: cell_width, height: cell_height, title: col.title, id: col.id, expanded: col.expanded}; - if (rows[col.path.length - 1]) { - rows[col.path.length - 1].push(cell); + if (rows[col.path.length]) { + rows[col.path.length].push(cell); } else { - rows[col.path.length - 1] = [cell]; + rows[col.path.length] = [cell]; } }); if (pivot.get_cols_leaves().length > 1) { - rows[0].push({width: nbr_measures, height: height, title: _t('Total'), id: pivot.main_col().id }); + rows[0].push({width: nbr_measures, height: height, title: ' ', id: pivot.main_col().id }); } if (pivot.cols.headers.length === 1) { rows = [[{width: nbr_measures, height: 1, title: _t('Total'), id: pivot.main_col().id, expanded: false}]]; diff --git a/addons/web_graph/static/src/xml/web_graph.xml b/addons/web_graph/static/src/xml/web_graph.xml index 81804e5a9b1..828d184dc24 100644 --- a/addons/web_graph/static/src/xml/web_graph.xml +++ b/addons/web_graph/static/src/xml/web_graph.xml @@ -57,35 +57,22 @@ <div class="graph_main_content"></div> </div> - <div t-name="field_selection" class="btn-group"> + <div t-name="field_selection" class="dropdown"> <span class="btn btn-default field-selection dropdown-toggle" data-toggle="dropdown"></span> - <ul class="dropdown-menu" role="menu"> + <ul class="dropdown-menu multi-level" role="menu"> <t t-foreach="fields" t-as="field"> <t t-if="(field.type === 'date') || (field.type === 'datetime')"> - <li> - <a class="field-selection" t-att-data-field-id="field.id" t-att-data-interval="'day'" t-att-data-id="header_id" href="#"> - <t t-esc="field.value + ' (day)'"/> - </a> - </li> - <li> - <a class="field-selection" t-att-data-field-id="field.id" t-att-data-interval="'week'" t-att-data-id="header_id" href="#"> - <t t-esc="field.value + ' (week)'"/> - </a> - </li> - <li> - <a class="field-selection" t-att-data-field-id="field.id" t-att-data-interval="'month'" t-att-data-id="header_id" href="#"> - <t t-esc="field.value + ' (month)'"/> - </a> - </li> - <li> - <a class="field-selection" t-att-data-field-id="field.id" t-att-data-interval="'quarter'" t-att-data-id="header_id" href="#"> - <t t-esc="field.value + ' (quarter)'"/> - </a> - </li> - <li> - <a class="field-selection" t-att-data-field-id="field.id" t-att-data-interval="'year'" t-att-data-id="header_id" href="#"> - <t t-esc="field.value + ' (year)'"/> + <li class="graph-dropdown-submenu"> + <a class="field-selection" t-att-data-field-id="field.id" t-att-data-id="header_id" t-att-data-interval="'month'" href="#"> + <t t-esc="field.value"/> </a> + <ul class="dropdown-menu"> + <li><a href="#" class="field-selection" t-att-data-field-id="field.id" t-att-data-id="header_id" t-att-data-interval="'day'">Day</a></li> + <li><a href="#" class="field-selection" t-att-data-field-id="field.id" t-att-data-id="header_id" t-att-data-interval="'week'">Week</a></li> + <li><a href="#" class="field-selection" t-att-data-field-id="field.id" t-att-data-id="header_id" t-att-data-interval="'month'">Month</a></li> + <li><a href="#" class="field-selection" t-att-data-field-id="field.id" t-att-data-id="header_id" t-att-data-interval="'quarter'">Quarter</a></li> + <li><a href="#" class="field-selection" t-att-data-field-id="field.id" t-att-data-id="header_id" t-att-data-interval="'year'">Year</a></li> + </ul> </li> </t> |
