From e2893ce3863ddf858ebee00096e06bbf010ddbc2 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 16 Jul 2019 13:11:13 +0000 Subject: [PATCH] [REF] web: factorize no content helper Different templates were defined for graph, pivot and cohort views for the no content helper. Those templates were similar (only the message sometimes slighlty changed). This rev. creates one generic template used by those three views. closes odoo/odoo#34916 Signed-off-by: Mathieu Duckerts-Antoine --- .../src/js/views/graph/graph_renderer.js | 10 ++---- .../src/js/views/pivot/pivot_renderer.js | 5 ++- addons/web/static/src/xml/base.xml | 32 ++++++++----------- addons/web/static/tests/views/graph_tests.js | 2 +- 4 files changed, 22 insertions(+), 27 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 02fdb102358..3cc8ce80eba 100644 --- a/addons/web/static/src/js/views/graph/graph_renderer.js +++ b/addons/web/static/src/js/views/graph/graph_renderer.js @@ -621,11 +621,7 @@ return AbstractRenderer.extend({ } var dataPoints = this._filterDataPoints(); if (!dataPoints.length && this.state.mode !== 'pie') { - this.$el.append(qweb.render('GraphView.error', { - title: _t("No data to display"), - description: _t("Try to add some records, or make sure that " + - "there is no active filter in the search bar."), - })); + this.$el.append(qweb.render('View.NoContentHelper')); } else if (this.isInDOM) { // only render the graph if the widget is already in the DOM (this // happens typically after an update), otherwise, it will be @@ -758,7 +754,7 @@ return AbstractRenderer.extend({ }); if (someNegative && !allNegative) { this.$el.empty(); - this.$el.append(qweb.render('GraphView.error', { + this.$el.append(qweb.render('View.NoContentHelper', { title: _t("Invalid data"), description: _t("Pie chart cannot mix positive and negative numbers. " + "Try to change your domain to only display positive results"), @@ -767,7 +763,7 @@ return AbstractRenderer.extend({ } if (allZero && !this.isEmbedded && this.state.origins.length === 1) { this.$el.empty(); - this.$el.append(qweb.render('GraphView.error', { + this.$el.append(qweb.render('View.NoContentHelper', { title: _t("Invalid data"), description: _t("Pie chart cannot display all zero numbers.. " + "Try to change your domain to display positive results"), diff --git a/addons/web/static/src/js/views/pivot/pivot_renderer.js b/addons/web/static/src/js/views/pivot/pivot_renderer.js index 29c3424e141..f2d2d24bea8 100644 --- a/addons/web/static/src/js/views/pivot/pivot_renderer.js +++ b/addons/web/static/src/js/views/pivot/pivot_renderer.js @@ -77,7 +77,10 @@ var PivotRenderer = AbstractRenderer.extend({ _render: function () { if (!this._hasContent()) { // display the nocontent helper - this._replaceElement(QWeb.render('PivotView.nodata')); + this._replaceElement(QWeb.render('View.NoContentHelper', { + description: _t("Try to add some records, or make sure that there is at least " + + "one measure and no active filter in the search bar."), + })); return this._super.apply(this, arguments); } diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index d214e2e692e..f9564dbe228 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -244,6 +244,20 @@ + + -
@@ -436,18 +444,6 @@
-
- -
diff --git a/addons/web/static/tests/views/graph_tests.js b/addons/web/static/tests/views/graph_tests.js index ca969fb9ac9..4db8f77feb4 100644 --- a/addons/web/static/tests/views/graph_tests.js +++ b/addons/web/static/tests/views/graph_tests.js @@ -979,7 +979,7 @@ QUnit.module('Views', { var graph = self.actionManager.getCurrentController().widget; if (self.combinationsToCheck[combination].errorMessage) { assert.strictEqual( - graph.$('.o_nocontent_help p').eq(1).text(), + graph.$('.o_nocontent_help p').eq(1).text().trim(), self.combinationsToCheck[combination].errorMessage ); } else {