mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
34 lines
819 B
TypeScript
34 lines
819 B
TypeScript
import { Widget } from "../core/widget";
|
|
import { Env } from "../env";
|
|
import { ActionStack } from "../services/action_manager";
|
|
|
|
export interface Props {
|
|
stack: ActionStack;
|
|
}
|
|
|
|
export class Action extends Widget<Env, Props> {
|
|
template = "action";
|
|
currentWidget: any;
|
|
|
|
shouldUpdate(nextProps: Props) {
|
|
if (nextProps.stack !== this.props.stack) {
|
|
this.props = nextProps;
|
|
this.setContentWidget();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
async setContentWidget() {
|
|
const info = this.props.stack[this.props.stack.length - 1];
|
|
if (info && info.type === "client") {
|
|
const Widget = info.Widget;
|
|
let widget = new Widget(this, {});
|
|
await widget.mount(this.el!);
|
|
if (this.currentWidget) {
|
|
this.currentWidget.destroy();
|
|
}
|
|
this.currentWidget = widget;
|
|
}
|
|
}
|
|
}
|