mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
small refactoring...
This commit is contained in:
@@ -1,14 +1,36 @@
|
||||
import { Widget } from "../core/widget";
|
||||
import { Env } from "../env";
|
||||
import { ActionStack } from "../services/action_manager";
|
||||
|
||||
const template = `
|
||||
<div class="o_content">
|
||||
<span>MAIN ACTION</span>
|
||||
<input/>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export class Action extends Widget<Env, {}> {
|
||||
name = "action";
|
||||
template = template;
|
||||
export interface Props {
|
||||
stack: ActionStack;
|
||||
}
|
||||
|
||||
export class Action extends Widget<Env, Props> {
|
||||
name = "action";
|
||||
template = `<div class="o_content"/>`;
|
||||
currentWidget: any;
|
||||
|
||||
mounted() {
|
||||
this.setContentWidget();
|
||||
}
|
||||
|
||||
shouldUpdate(nextProps: Props) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user