Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component } from "@odoo/owl";

export class Card extends Component {
static template = "awesome_owl.card";

static props = {
title: {
type: String,
},
content: {
type: String,
}
}
}
17 changes: 17 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.card">
<div class="card d-inline-block m-2" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">
<t t-esc="props.title"/>
</h5>
<p class="card-text">
<t t-esc="props.content"/>
</p>
</div>
</div>
</t>

</templates>
23 changes: 23 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, useState } from "@odoo/owl";

export class Counter extends Component {
static template = "awesome_owl.counter";

static props = {
onChange: {
type: Function,
optional: true
}
}

setup() {
this.state = useState({ value: 0});
}

increment() {
this.state.value++;
if(this.props.onChange) {
this.props.onChange();
}
}
}
9 changes: 9 additions & 0 deletions awesome_owl/static/src/counter/counter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.counter">
<p>Counter: <t t-esc="state.value"/></p>
<button class="btn btn-primary" t-on-click="increment">Increment</button>
</t>

</templates>
15 changes: 14 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { Component } from "@odoo/owl";
import { Component, useState } from "@odoo/owl";
import { Counter } from "./counter/counter";
import { Card } from "./card/card";
import {TodoList} from "./todo/list/todo_list";

export class Playground extends Component {
static template = "awesome_owl.playground";

static components = { Counter, Card, TodoList };

setup() {
this.state = useState({value: 0});
}

incrementSum() {
this.state.value++;
}
}
10 changes: 7 additions & 3 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
<templates xml:space="preserve">

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
</div>
<h1>My Counter</h1>
<Card title="'Card 1'" content="'Content of card 1'"/>
<Card title="'Card 2'" content="'Content of card 2'"/>
<Counter onChange.bind="incrementSum"/>
<Counter onChange.bind="incrementSum"/>
<p>Sum: <t t-esc="state.value"/></p>
<TodoList/>
</t>

</templates>
19 changes: 19 additions & 0 deletions awesome_owl/static/src/todo/item/todo_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from "@odoo/owl";
import {Card} from "../../card/card";

export class TodoItem extends Component {
static template = "awesome_owl.todo_item";

static Components = [ Card ]

static props = {
todo: {
type: Object,
shape: {
id: Number,
description: String,
isCompleted: Boolean,
}
}
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/todo/item/todo_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.todo_item">
<div t-att-class="{'text-muted text-decoration-line-through': props.todo.isCompleted}">
<t t-esc="props.todo.id"/>
<t t-esc="props.todo.description"/>
</div>
</t>

</templates>
22 changes: 22 additions & 0 deletions awesome_owl/static/src/todo/list/todo_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Component, useState} from "@odoo/owl";
import {TodoItem} from "../item/todo_item";

export class TodoList extends Component {
static template = "awesome_owl.todo_list";

static components = {TodoItem};

static props = {
items: {
type: Array,
optional: true,
}
}

setup() {
this.props.items = useState([
{ id: 1, description: "buy Beer", isCompleted: true },
{ id: 2, description: "buy Chicken", isCompleted: false },
])
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/todo/list/todo_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.todo_list">
<t t-foreach="props.items" t-as="todo" t-key="todo.id">
<TodoItem todo="todo"/>
<br/>
</t>
</t>

</templates>