[FIX] web: display filters directly in search bar
In views with a searchbar, we want the filters to be displayed
directly when they are activated, without waiting for the view to
be reloaded. This is to provide a direct feedback to the user.
Before this commit, this didn't work in grouped kanban view with
progressbar. The regression has been introduced by [1] which moves
the progressbar logic out of the model. With [1], the rendering of
the KanbanController waits for the progressbar data to be loaded
in onWillUpdateProps, thus delaying the rendering coming from the
WithSearch when a filter is toggled.
This commit applies the same logic as for the model: we do not wait
for the loading promise in onWillUpdateProps. That way, the
rendering coming from WithSearch is synchronous, but a reload is
initiated and another rendering will be scheduled by the Controller
itself when the data will be loaded.
This commit also adds a test for the model case, as it appears that
this wasn't tested.
[1] 58ca40b032
closes odoo/odoo#139967
X-original-commit: 47cf6e326f5a795984bac2138b169503c3dd099c
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
This commit is contained in:
committed by
Mathieu Duckerts-Antoine
parent
ceebd2e8d0
commit
4dc211dff8
@@ -338,7 +338,7 @@ export function useProgressBar(progressAttributes, model, aggregateFields, activ
|
||||
return progressBarState.loadProgressBar(component.props);
|
||||
});
|
||||
onWillUpdateProps((nextProps) => {
|
||||
return progressBarState.loadProgressBar(nextProps);
|
||||
progressBarState.loadProgressBar(nextProps);
|
||||
});
|
||||
|
||||
return reactive(progressBarState);
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
pagerNext,
|
||||
toggleSearchBarMenu,
|
||||
validateSearch,
|
||||
toggleMenuItem,
|
||||
} from "@web/../tests/search/helpers";
|
||||
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
import { createWebClient, doAction } from "@web/../tests/webclient/helpers";
|
||||
@@ -10904,7 +10905,7 @@ QUnit.module("Views", (hooks) => {
|
||||
|
||||
QUnit.test(
|
||||
"keyboard navigation on kanban when the focus is on a link that " +
|
||||
"has an action and the kanban has no oe_kanban_global_... class",
|
||||
"has an action and the kanban has no oe_kanban_global_... class",
|
||||
async (assert) => {
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
@@ -13534,7 +13535,7 @@ QUnit.module("Views", (hooks) => {
|
||||
MyField.template = xml`<span t-esc="renderCount"/>`;
|
||||
registry.category("fields").add("my_field", { component: MyField });
|
||||
|
||||
serverData.models.partner.onchanges = { product_id: () => {} };
|
||||
serverData.models.partner.onchanges = { product_id: () => { } };
|
||||
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
@@ -13883,6 +13884,88 @@ QUnit.module("Views", (hooks) => {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
QUnit.test("searchbar filters are displayed directly", async (assert) => {
|
||||
let def;
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<kanban>
|
||||
<field name="foo"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div><field name="foo"/></div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>`,
|
||||
searchViewArch: `
|
||||
<search>
|
||||
<filter name="some_filter" string="Some Filter" domain="[['foo', '!=', 'bar']]"/>
|
||||
</search>`,
|
||||
async mockRPC(route, args) {
|
||||
if (args.method === "web_search_read") {
|
||||
await def;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual(getFacetTexts(target), []);
|
||||
|
||||
// toggle a filter, and slow down the web_search_read rpc
|
||||
def = makeDeferred();
|
||||
await toggleSearchBarMenu(target);
|
||||
await toggleMenuItem(target, "Some Filter");
|
||||
assert.deepEqual(getFacetTexts(target), ["Some Filter"]);
|
||||
|
||||
def.resolve();
|
||||
await nextTick();
|
||||
assert.deepEqual(getFacetTexts(target), ["Some Filter"]);
|
||||
});
|
||||
|
||||
QUnit.test("searchbar filters are displayed directly (with progressbar)", async (assert) => {
|
||||
let def;
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<kanban>
|
||||
<progressbar field="state" colors='{"abc": "success", "def": "warning", "ghi": "danger"}' />
|
||||
<field name="foo"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div><field name="foo"/></div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>`,
|
||||
groupBy: ["int_field"],
|
||||
searchViewArch: `
|
||||
<search>
|
||||
<filter name="some_filter" string="Some Filter" domain="[['foo', '!=', 'bar']]"/>
|
||||
</search>`,
|
||||
async mockRPC(route, args) {
|
||||
if (args.method === "read_progress_bar") {
|
||||
await def;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual(getFacetTexts(target), []);
|
||||
|
||||
// toggle a filter, and slow down the read_progress_bar rpc
|
||||
def = makeDeferred();
|
||||
await toggleSearchBarMenu(target);
|
||||
await toggleMenuItem(target, "Some Filter");
|
||||
|
||||
assert.deepEqual(getFacetTexts(target), ["Some Filter"]);
|
||||
|
||||
def.resolve();
|
||||
await nextTick();
|
||||
assert.deepEqual(getFacetTexts(target), ["Some Filter"]);
|
||||
});
|
||||
|
||||
QUnit.test("group by properties and drag and drop", async (assert) => {
|
||||
assert.expect(10);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user