diff options
| author | Adrien Dieudonne <adr@odoo.com> | 2018-08-17 15:34:04 +0200 |
|---|---|---|
| committer | Adrien Dieudonne <adr@odoo.com> | 2018-08-20 16:10:25 +0200 |
| commit | 634de21b76b925f2c2624a8c5c8ec9d3e9d9540b (patch) | |
| tree | 5ba3d31dbcb6a7423afc206d5f631bcde49e4b67 /addons/web | |
| parent | 21430a4d027f9b3e5a83b078477a77bdb17e61a0 (diff) | |
[FIX] web: graph_renderer: check graph data before rendering
Before this commit, we had two different errors when data was
unavailable:
The first one is generated by Odoo: "No data to display, try to[...]"
The second one is generated by nvd3: "No Data Available".
We always want the same message.
So now, we always make some checks before rendering
the graph by calling _render.
Diffstat (limited to 'addons/web')
| -rw-r--r-- | addons/web/static/src/js/views/graph/graph_renderer.js | 2 | ||||
| -rw-r--r-- | addons/web/static/tests/views/graph_tests.js | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_renderer.js b/addons/web/static/src/js/views/graph/graph_renderer.js index 1fbd6572a9a..da5709a6261 100644 --- a/addons/web/static/src/js/views/graph/graph_renderer.js +++ b/addons/web/static/src/js/views/graph/graph_renderer.js @@ -56,7 +56,7 @@ return AbstractRenderer.extend({ on_attach_callback: function () { this._super.apply(this, arguments); this.isInDOM = true; - this._renderGraph(); + this._render(); }, /** * @override diff --git a/addons/web/static/tests/views/graph_tests.js b/addons/web/static/tests/views/graph_tests.js index 028eb4cb3a3..7bb2fce78b5 100644 --- a/addons/web/static/tests/views/graph_tests.js +++ b/addons/web/static/tests/views/graph_tests.js @@ -190,6 +190,25 @@ QUnit.module('Views', { }); QUnit.test('no content helper', function (assert) { + assert.expect(2); + this.data.foo.records = []; + + var graph = createView({ + View: GraphView, + model: "foo", + data: this.data, + arch: '<graph string="Gloups">' + + '<field name="product_id"/>' + + '</graph>', + }); + assert.strictEqual(graph.$('div.o_graph_svg_container svg.nvd3-svg').length, 0, + "should not contain a div with a svg element"); + assert.strictEqual(graph.$('div.o_view_nocontent').length, 1, + "should display the no content helper"); + graph.destroy(); + }); + + QUnit.test('no content helper after update', function (assert) { var done = assert.async(); assert.expect(4); |
