Files
owl/web/static/src/ts/widgets/Action.ts
T
2019-02-02 16:26:20 +01:00

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;
}
}
}