mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
work on menu data/home menu/navbar/routing
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { EventBus } from "../core/event_bus";
|
||||
import { Widget, Type } from "../core/widget";
|
||||
import { Env } from "../env";
|
||||
import { Registry } from "../core/registry";
|
||||
import { IRouter, Query } from "../core/router";
|
||||
import { Type, Widget } from "../core/widget";
|
||||
import { Env } from "../env";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
@@ -38,7 +37,6 @@ export type ActionEvent = "action_stack_updated";
|
||||
type Callback = (stack: ActionStack) => void;
|
||||
|
||||
export interface IActionManager {
|
||||
activate(): void;
|
||||
doAction(request: ActionRequest): void;
|
||||
on(event: ActionEvent, owner: any, callback: Callback): void;
|
||||
getStack(): ActionStack;
|
||||
@@ -49,22 +47,15 @@ export interface IActionManager {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export class ActionManager extends EventBus implements IActionManager {
|
||||
router: IRouter;
|
||||
registry: Registry<Type<Widget<Env, any>>>;
|
||||
stack: ActionStack;
|
||||
|
||||
constructor(router: IRouter, registry: Registry<Type<Widget<Env, any>>>) {
|
||||
constructor(registry: Registry<Type<Widget<Env, any>>>) {
|
||||
super();
|
||||
this.router = router;
|
||||
this.registry = registry;
|
||||
this.stack = [];
|
||||
}
|
||||
|
||||
activate() {
|
||||
this.router.on("query_changed", this, this.update);
|
||||
this.update(this.router.getQuery());
|
||||
}
|
||||
|
||||
doAction(request: ActionRequest) {
|
||||
if (typeof request === "number") {
|
||||
// this is an action ID
|
||||
@@ -89,11 +80,4 @@ export class ActionManager extends EventBus implements IActionManager {
|
||||
getStack(): ActionStack {
|
||||
return [];
|
||||
}
|
||||
|
||||
update(query: Query) {
|
||||
if ("action_id" in query) {
|
||||
const actionID = parseInt(query.action_id);
|
||||
this.doAction(actionID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user