mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
make doAction async
This commit is contained in:
@@ -249,10 +249,13 @@ function actionManagerMixin<T extends ReturnType<typeof rpcMixin>>(Base: T) {
|
|||||||
if (!menu) {
|
if (!menu) {
|
||||||
throw new Error("Invalid menu id");
|
throw new Error("Invalid menu id");
|
||||||
}
|
}
|
||||||
this.updateAppState(menu.app, menu.actionId);
|
return this.updateAppState(menu.app, menu.actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateAppState(app: MenuItem | null, actionId: number | null) {
|
private async updateAppState(
|
||||||
|
app: MenuItem | null,
|
||||||
|
actionId: number | null
|
||||||
|
) {
|
||||||
const newApp = app || this.state.currentApp;
|
const newApp = app || this.state.currentApp;
|
||||||
if (actionId) {
|
if (actionId) {
|
||||||
const query: Query = { action_id: String(actionId) };
|
const query: Query = { action_id: String(actionId) };
|
||||||
@@ -264,7 +267,7 @@ function actionManagerMixin<T extends ReturnType<typeof rpcMixin>>(Base: T) {
|
|||||||
this.update({ currentApp: app });
|
this.update({ currentApp: app });
|
||||||
}
|
}
|
||||||
this.services.router.navigate(query);
|
this.services.router.navigate(query);
|
||||||
this.doAction(actionId);
|
return this.doAction(actionId);
|
||||||
} else {
|
} else {
|
||||||
this.update({ inHome: true, currentApp: newApp });
|
this.update({ inHome: true, currentApp: newApp });
|
||||||
}
|
}
|
||||||
@@ -296,9 +299,9 @@ function actionManagerMixin<T extends ReturnType<typeof rpcMixin>>(Base: T) {
|
|||||||
return { app, actionId };
|
return { app, actionId };
|
||||||
}
|
}
|
||||||
|
|
||||||
doAction(request: ActionRequest) {
|
async doAction(request: ActionRequest) {
|
||||||
if (typeof request === "number") {
|
if (typeof request === "number") {
|
||||||
this.loadAction(request);
|
await this.loadAction(request);
|
||||||
// this is an action ID
|
// this is an action ID
|
||||||
let name = request === 131 ? "discuss" : "crm";
|
let name = request === 131 ? "discuss" : "crm";
|
||||||
let title =
|
let title =
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ describe("state transitions", () => {
|
|||||||
// should still be in home menu since no app is currently active
|
// should still be in home menu since no app is currently active
|
||||||
expect(store.state.inHome).toBe(true);
|
expect(store.state.inHome).toBe(true);
|
||||||
|
|
||||||
store.activateMenuItem(96);
|
await store.activateMenuItem(96);
|
||||||
expect(store.state.inHome).toBe(false);
|
expect(store.state.inHome).toBe(false);
|
||||||
|
|
||||||
store.toggleHomeMenu();
|
store.toggleHomeMenu();
|
||||||
|
|||||||
Reference in New Issue
Block a user