[FIX] web: kanban: add a onPagerUpdate callback
Use case: in the reconciliation widget, we need to know when the pager is updated before the next render because we need to select the appropriate id to use. cf the following PR: https://github.com/odoo/enterprise/pull/33631 opw-3031131 closes odoo/odoo#106581 X-original-commit: 19523b511d54278613a3d3e7389a51665dcc3fc1 Related: odoo/enterprise#34408 Signed-off-by: Georis François (fge) <fge@odoo.com> Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
@@ -65,6 +65,7 @@ export class KanbanController extends Component {
|
||||
this.model.root.offset = offset;
|
||||
this.model.root.limit = limit;
|
||||
await this.model.root.load();
|
||||
await this.onUpdatedPager();
|
||||
this.render(true); // FIXME WOWL reactivity
|
||||
},
|
||||
updateTotal: hasLimitedCount ? () => root.fetchCount() : undefined,
|
||||
@@ -118,6 +119,8 @@ export class KanbanController extends Component {
|
||||
async beforeExecuteActionButton(clickParams) {}
|
||||
|
||||
async afterExecuteActionButton(clickParams) {}
|
||||
|
||||
async onUpdatedPager() {}
|
||||
}
|
||||
|
||||
KanbanController.template = `web.KanbanView`;
|
||||
|
||||
@@ -35,14 +35,16 @@ import { nbsp } from "@web/core/utils/strings";
|
||||
import { getNextTabableElement } from "@web/core/utils/ui";
|
||||
import { session } from "@web/session";
|
||||
import { KanbanAnimatedNumber } from "@web/views/kanban/kanban_animated_number";
|
||||
import { KanbanController } from "@web/views/kanban/kanban_controller";
|
||||
import { kanbanView } from "@web/views/kanban/kanban_view";
|
||||
import { DynamicRecordList } from "@web/views/relational_model";
|
||||
import { ViewButton } from "@web/views/view_button/view_button";
|
||||
|
||||
import { Component, xml } from "@odoo/owl";
|
||||
import { Component, onWillRender, xml } from "@odoo/owl";
|
||||
|
||||
const serviceRegistry = registry.category("services");
|
||||
const viewWidgetRegistry = registry.category("view_widgets");
|
||||
const viewRegistry = registry.category("views");
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
@@ -1228,6 +1230,55 @@ QUnit.module("Views", (hooks) => {
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("pager, update calls onUpdatedPager before the render", async (assert) => {
|
||||
assert.expect(8);
|
||||
|
||||
class TestKanbanController extends KanbanController {
|
||||
setup() {
|
||||
super.setup();
|
||||
onWillRender(() => {
|
||||
assert.step("render");
|
||||
});
|
||||
}
|
||||
|
||||
async onUpdatedPager() {
|
||||
assert.step("onUpdatedPager");
|
||||
}
|
||||
}
|
||||
|
||||
viewRegistry.add("test_kanban_view", {
|
||||
...kanbanView,
|
||||
Controller: TestKanbanController,
|
||||
});
|
||||
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<kanban js_class="test_kanban_view">
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div><field name="foo"/></div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>`,
|
||||
limit: 3,
|
||||
});
|
||||
|
||||
assert.deepEqual(getPagerValue(target), [1, 3]);
|
||||
assert.strictEqual(getPagerLimit(target), 4);
|
||||
assert.step("next page");
|
||||
await click(target.querySelector(".o_pager_next"));
|
||||
assert.deepEqual(getPagerValue(target), [4, 4]);
|
||||
assert.verifySteps([
|
||||
"render",
|
||||
"next page",
|
||||
"onUpdatedPager",
|
||||
"render"
|
||||
]);
|
||||
});
|
||||
|
||||
QUnit.test("click on a button type='delete' to delete a record in a column", async (assert) => {
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
|
||||
Reference in New Issue
Block a user