mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
add IAjax and IActionManager interfaces
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { QWeb } from "./core/qweb_vdom";
|
||||
import { idGenerator } from "./core/utils";
|
||||
import { WEnv } from "./core/widget";
|
||||
import { ActionManager } from "./services/action_manager";
|
||||
import { Ajax } from "./services/ajax";
|
||||
import { ActionManager, IActionManager } from "./services/action_manager";
|
||||
import { Ajax, IAjax } from "./services/ajax";
|
||||
import { Router, IRouter } from "./services/router";
|
||||
|
||||
export interface Menu {
|
||||
@@ -11,10 +11,11 @@ export interface Menu {
|
||||
}
|
||||
|
||||
export interface Env extends WEnv {
|
||||
actionManager: ActionManager;
|
||||
ajax: Ajax;
|
||||
actionManager: IActionManager;
|
||||
ajax: IAjax;
|
||||
router: IRouter;
|
||||
menus: Menu[];
|
||||
rpc: IAjax["rpc"];
|
||||
}
|
||||
|
||||
export function makeEnvironment(): Env {
|
||||
@@ -28,11 +29,17 @@ export function makeEnvironment(): Env {
|
||||
];
|
||||
|
||||
return {
|
||||
// Base widget requirements
|
||||
qweb,
|
||||
getID: idGenerator(),
|
||||
|
||||
// services
|
||||
ajax,
|
||||
router,
|
||||
actionManager,
|
||||
menus,
|
||||
getID: idGenerator()
|
||||
|
||||
// helpers
|
||||
rpc: ajax.rpc
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EventBus } from "../core/event_bus";
|
||||
import { EventBus, Callback } from "../core/event_bus";
|
||||
import { Widget } from "../core/widget";
|
||||
import { Env } from "../env";
|
||||
import { CRM } from "../widgets/crm";
|
||||
@@ -19,6 +19,14 @@ interface ActWindowAction {
|
||||
views: string[];
|
||||
}
|
||||
|
||||
type ActionEvent = "action_ready";
|
||||
|
||||
export interface IActionManager {
|
||||
doAction(actionID: number);
|
||||
on(event: ActionEvent, owner: any, callback: Callback);
|
||||
getCurrentAction(): ActionWidget | null;
|
||||
}
|
||||
|
||||
export type Action = ClientAction | ActWindowAction;
|
||||
|
||||
export interface ActionWidget {
|
||||
@@ -32,7 +40,7 @@ const actions: any[] = [
|
||||
{ id: 2, title: "CRM", Widget: CRM }
|
||||
];
|
||||
|
||||
export class ActionManager extends EventBus {
|
||||
export class ActionManager extends EventBus implements IActionManager {
|
||||
router: IRouter;
|
||||
currentAction: ActionWidget | null = null;
|
||||
|
||||
|
||||
@@ -1 +1,14 @@
|
||||
export class Ajax {}
|
||||
export interface RPC {
|
||||
model: string;
|
||||
method: string;
|
||||
args: any;
|
||||
}
|
||||
export interface IAjax {
|
||||
rpc(rpc: RPC): Promise<any>;
|
||||
}
|
||||
|
||||
export class Ajax implements IAjax {
|
||||
rpc(rpc: RPC): Promise<any> {
|
||||
return Promise.resolve(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user