[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 <Polymorphe57@users.noreply.github.com>
This commit is contained in:
@@ -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"),
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -244,6 +244,20 @@
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<div t-name="View.NoContentHelper" class="o_view_nocontent" role="alert">
|
||||
<div class="o_nocontent_help">
|
||||
<p class="o_view_nocontent_empty_folder">
|
||||
<t t-if="title" t-esc="title"/>
|
||||
<t t-else="1">No data to display</t>
|
||||
</p>
|
||||
<p>
|
||||
<t t-if="description" t-esc="description"/>
|
||||
<t t-else="1">Try to add some records, or make sure that there is no
|
||||
active filter in the search bar.</t>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<t t-name="ListView.buttons">
|
||||
<div class="o_list_buttons" role="toolbar" aria-label="Main actions">
|
||||
<button type="button" class="btn btn-primary o_list_button_save" accesskey="s">
|
||||
@@ -384,12 +398,6 @@
|
||||
<button class="btn btn-secondary fa fa-database o_graph_button" title="Stacked" aria-label="Stacked" data-mode="stack"/>
|
||||
</div>
|
||||
</t>
|
||||
<div t-name="GraphView.error" class="o_view_nocontent" role="alert">
|
||||
<div class="o_nocontent_help">
|
||||
<p class="o_view_nocontent_empty_folder"><t t-esc="title"/></p>
|
||||
<p><t t-esc="description"/></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div t-name="PivotView" t-attf-class="o_pivot #{widget.enableLinking ? 'o_enable_linking' : ''}">
|
||||
<div class="o_field_selection"/>
|
||||
@@ -436,18 +444,6 @@
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
<div t-name="PivotView.nodata">
|
||||
<div class="o_view_nocontent" role="alert">
|
||||
<div class="o_nocontent_help">
|
||||
<p class="o_view_nocontent_empty_folder">
|
||||
No data to display
|
||||
</p><p>
|
||||
Try to add some records, or make sure
|
||||
that there is at least one measure and no active filter in the search bar.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<t t-name="FormSelection">
|
||||
<div class="btn-group o_selection" aria-atomic="true">
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user