summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorHardik Prajapati <hap@odoo.com>2020-07-10 09:18:31 +0000
committerAaron Bohy <aab@odoo.com>2020-07-27 12:54:57 +0000
commit7aafa205090c558d3d52eb893762c00a70ca307f (patch)
tree02b1214ba5fcebf1525bdb22874946fb24fc4c23 /addons/web
parent97425653af800239f2b4175440788d88a54f693a (diff)
[FIX] web: list: hide export button when list empty
Before this commit, at first rendering, the export button was displayed in the list view even if the list was empty. The issue occurred because at first rendering, the buttons aren't moved inside the control panel yet (this is done in the 'mounted' hook of the control panel). As we render in a fragment, the hook is called later on, when everything is ready and inserted into the DOM. We'll get rid of these painful manipulations as soon as everything will be converted to OWL. Task 2294306 closes odoo/odoo#54307 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/static/src/js/views/list/list_controller.js4
-rw-r--r--addons/web/static/tests/views/list_tests.js19
2 files changed, 21 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js
index 12a3e8c75e1..24dbc4683dd 100644
--- a/addons/web/static/src/js/views/list/list_controller.js
+++ b/addons/web/static/src/js/views/list/list_controller.js
@@ -174,9 +174,9 @@ var ListController = BasicController.extend({
this.$buttons.toggleClass('o-editing', mode === 'edit');
const state = this.model.get(this.handle, {raw: true});
if (state.count) {
- this.$('.o_list_export_xlsx').show();
+ this.$buttons.find('.o_list_export_xlsx').show();
} else {
- this.$('.o_list_export_xlsx').hide();
+ this.$buttons.find('.o_list_export_xlsx').hide();
}
}
this._updateSelectionBox();
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 012ebedec19..6f17ac1e662 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -278,6 +278,25 @@ QUnit.module('Views', {
list.destroy();
});
+ QUnit.test('export button in empty list view', async function (assert) {
+ assert.expect(2);
+
+ const list = await createView({
+ View: ListView,
+ model: "foo",
+ data: this.data,
+ arch: '<tree><field name="foo"/></tree>',
+ domain: [["id", "<", 0]], // such that no record matches the domain
+ });
+
+ assert.isNotVisible(list.el.querySelector('.o_list_export_xlsx'));
+
+ await list.reload({ domain: [['id', '>', 0]] });
+ assert.isVisible(list.el.querySelector('.o_list_export_xlsx'));
+
+ list.destroy();
+ });
+
QUnit.test('list view with adjacent buttons', async function (assert) {
assert.expect(2);