[FIX] web: kanban view flickering unfiltering columns

Before this commit, when unfiltering a column in a kanban view, a
flickering occurs and the show more button is visible for a moment.

closes odoo/odoo#110130

X-original-commit: 0cd9c7dbba12e362a6445f47d52b43c48dffdb61
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2023-01-17 14:16:59 +01:00
parent 3752ac6832
commit 4af6fcd779
2 changed files with 58 additions and 3 deletions
@@ -205,9 +205,8 @@ class KanbanGroup extends Group {
this.list.domain = this.getProgressBarDomain();
// Do not update progress bars data when filtering on them.
this.model.trigger("group-updated", { group: this, withProgressBars: false });
await Promise.all([this.list.load()]);
this.list.model.notify();
this.model.trigger("group-updated", { group: this, withProgressBars: false });
}
/**
@@ -9059,6 +9059,7 @@ QUnit.module("Views", (hooks) => {
"read_progress_bar",
"web_search_read",
"web_search_read",
"web_search_read",
// activate filter
"web_read_group", // recomputes aggregates
"web_search_read",
@@ -9067,7 +9068,6 @@ QUnit.module("Views", (hooks) => {
"web_search_read",
// deactivate active filter
"web_read_group", // recomputes aggregates
"web_search_read",
]);
});
@@ -11200,6 +11200,62 @@ QUnit.module("Views", (hooks) => {
assert.strictEqual(getProgressBars(1)[2].style.width, "25%"); // ghi: 1
});
QUnit.test("load more button shouldn't be visible when unfiltering column", async (assert) => {
serverData.models.partner.records.push({ id: 5, state: "abc", bar: true });
let def;
await makeView({
type: "kanban",
resModel: "partner",
serverData,
arch: /* xml */ `
<kanban>
<progressbar field="state" colors='{"abc": "success", "def": "warning", "ghi": "danger"}' />
<templates>
<div t-name="kanban-box">
<field name="state" widget="state_selection" />
<field name="id" />
</div>
</templates>
</kanban>
`,
groupBy: ["bar"],
mockRPC: async (route, args) => {
const { method } = args;
if (method === "web_search_read") {
await def;
}
},
});
// Initial state: 2 columns, the "No" column contains 1 record, The "Yes" column contains 4 records
assert.deepEqual(getCounters(), ["1", "4"]);
// Filter on state "abc" => matches 2 records
await click(getProgressBars(1)[0]);
// Filtered state: 2 columns, the "No" column contains 1 record, The "Yes" column contains 2 records
assert.deepEqual(getCounters(), ["1", "2"]);
def = makeDeferred();
// UnFiltered the "Yes" column
await click(getProgressBars(1)[0]);
assert.containsNone(
target,
".o_kanban_load_more",
"The load more button should not be visible"
);
def.resolve();
await nextTick();
//Return to initial state
assert.deepEqual(getCounters(), ["1", "4"]);
assert.containsNone(
target,
".o_kanban_load_more",
"The load more button should not be visible"
);
});
QUnit.test("click on the progressBar of a new column", async (assert) => {
serverData.models.partner.records = [];
await makeView({