Skip to content

Commit 1f7c383

Browse files
committed
[ADD] awesome_owl: Added Toggle button to cards
1 parent 2d83e65 commit 1f7c383

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

awesome_owl/static/src/card/card.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @odoo-module **/
22

3-
import { Component } from "@odoo/owl";
3+
import { Component, useState } from "@odoo/owl";
44

55
export class Card extends Component {
66
static template = "awesome_owl.card";
@@ -14,4 +14,12 @@ export class Card extends Component {
1414
}
1515
};
1616

17+
setup() {
18+
this.state = useState({displayed: false});
19+
}
20+
21+
toggleDisplay() {
22+
this.state.displayed = !this.state.displayed;
23+
}
24+
1725
}

awesome_owl/static/src/card/card.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
<t t-name="awesome_owl.card">
55
<div class="p-3 border">
6-
<h3><t t-out="props.title"/></h3>
7-
<t t-slot="default"/>
6+
<h3><t t-out="props.title"/><button t-on-click="toggleDisplay">Toggle</button></h3>
7+
<t t-if="state.displayed" t-slot="default"/>
88
</div>
99
</t>
1010

0 commit comments

Comments
 (0)