fix issue with subwidgets not being mounted/unmounted

This commit is contained in:
Géry Debongnie
2019-01-31 15:14:26 +01:00
parent ed35e0d8e4
commit 7e90aec028
6 changed files with 36 additions and 37 deletions
+2 -17
View File
@@ -22,31 +22,16 @@ const template = `
<t t-widget="ColorWidget" t-props="{color: state.color}"/>
<button t-on-click="addNotif(false)">Add notif</button>
<button t-on-click="addNotif(true)">Add sticky notif</button>
<t t-foreach="state.test" t-as="number">
<t t-widget="ChildWidget" t-key="number"/>
</t>
</div>
`;
let n = 1;
class ChildWidget extends Widget<Env, never> {
name = "c";
template = `<span><t t-esc="state.n"/></span>`;
constructor(parent) {
super(parent);
this.state = { n };
n++;
}
}
export class Discuss extends Widget<Env, {}> {
name = "discuss";
template = template;
widgets = { Clock, Counter, ColorWidget, ChildWidget };
state = { validcounter: true, color: "red", test: [1, 2, 3] };
widgets = { Clock, Counter, ColorWidget };
state = { validcounter: true, color: "red" };
mounted() {}
resetCounter(ev: MouseEvent) {
if (this.refs.counter instanceof Counter) {
this.refs.counter.updateState({ counter: 3 });