small refactoring...

This commit is contained in:
Géry Debongnie
2019-01-31 13:19:30 +01:00
parent bac075dbbd
commit 92bea3df52
17 changed files with 199 additions and 158 deletions
+32 -10
View File
@@ -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;
}
}
}