Skip to content

Commit df045f2

Browse files
committed
[IMP] owl_playground : ch1 tasks 4-6
1 parent cf7f52b commit df045f2

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

awesome_owl/static/src/counter/counter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ export class Counter extends Component {
55
static template = "awesome_owl.counter";
66

77
setup() {
8-
this.state = useState({ counter: 0 });
8+
this.state = useState({ counter: 1 });
99
}
1010

1111
incrementCounter() {
1212
this.state.counter++;
13+
this.props.callback();
1314
}
15+
16+
static props = { callback: Function };
17+
1418
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { Component, useState } from "@odoo/owl";
1+
import { Component, useState, markup } from "@odoo/owl";
22
import { Counter } from "./counter/counter";
33
import { Card } from "./card/card";
44

5-
65
export class Playground extends Component {
76
static template = "awesome_owl.playground";
87
static components = { Counter, Card };
8+
no_markup_value = "<div class='text-primary'>Testing no markup</div>";
9+
markup_value = markup("<div class='text-primary'>Testing markup</div>");
910
setup(){
11+
this.state = useState({ sum: 2 });
12+
this.incrementSum = this.incrementSum.bind(this);
13+
}
1014

15+
incrementSum(){
16+
this.state.sum += 1;
1117
}
1218
}

awesome_owl/static/src/playground.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
<t t-name="awesome_owl.playground">
44
Hello My Friend
55
<div>
6-
<Counter />
7-
<Counter />
6+
<Counter callback.bind="incrementSum" />
7+
<Counter callback.bind="incrementSum" />
88
</div>
99
<div>
10-
<Card title="'Task 1'" content="'prepare things'"/>
11-
<Card title="'Task 2'" content="'do stuff'"/>
10+
<Card title="'Task 1'" content="no_markup_value"/>
11+
<Card title="'Task 2'" content="markup_value"/>
1212
</div>
13+
<p>Sum: <t t-esc="state.sum"/></p>
1314
</t>
1415
</templates>

0 commit comments

Comments
 (0)