-
Notifications
You must be signed in to change notification settings - Fork 2.2k
18.0 owl tutorials abye #804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
A-Yehia19
wants to merge
10
commits into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-owl_tutorials-abye
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
94f8777
[ADD] counter and card components
A-Yehia19 3e39cca
[ADD] todo list
A-Yehia19 ab2b98e
[ADD] interactivity to todolist
A-Yehia19 68bfa91
[ADD] features in the Card component
A-Yehia19 01e138e
[ADD] Dashboard Item, PieChart components
A-Yehia19 f0becb6
[Add] lazy loading the dashboard
A-Yehia19 1610c4c
[ADD] create items to load the dashboard with
A-Yehia19 1b8f442
[ADD] make the dashboard data generic
A-Yehia19 2ea4b47
[ADD] configuration dialogue
A-Yehia19 fa4c27c
[ADD] translation to js modules
A-Yehia19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, markup } from "@odoo/owl"; | ||
|
||
export class Card extends Component { | ||
static template = "awesome_owl.card"; | ||
|
||
static props = { | ||
title: { | ||
type: String, | ||
optional: true, | ||
}, | ||
content: { | ||
type: String, | ||
optional: true, | ||
}, | ||
}; | ||
|
||
get content() { | ||
if (this.props.content) { | ||
return markup(this.props.content); | ||
} | ||
return undefined; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<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-out="props.title"/></h5> | ||
<p class="card-text"><t t-out="this.content"/></p> | ||
</div> | ||
</div> | ||
|
||
</t> | ||
|
||
</templates> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, useState } from "@odoo/owl"; | ||
|
||
export class Counter extends Component { | ||
static template = "awesome_owl.counter"; | ||
|
||
static props = { | ||
callback: { | ||
type: Function, | ||
optional: true, | ||
} | ||
} | ||
|
||
setup() { | ||
this.count = useState({ value: 0 }); | ||
} | ||
|
||
increment() { | ||
this.count.value += 1; | ||
if (this.props.callback) { | ||
this.props.callback(); | ||
} | ||
A-Yehia19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.counter"> | ||
<div style="border: 1px solid #ccc; padding: 15px; margin: 10px; width: fit-content; height:fit-content; display: inline"> | ||
<label style="margin:10px">Counter: <t t-esc="count.value"/></label> | ||
<button class="btn" t-on-click="increment" style="background-color: purple; color: white">Increment</button> | ||
</div> | ||
</t> | ||
|
||
</templates> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
/** @odoo-module **/ | ||
|
||
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.content1 = "<u>Card Content 1</u>"; | ||
this.content2 = "<u>Card Content 2</u>"; | ||
this.state = useState({ | ||
sum: 0, | ||
}); | ||
} | ||
|
||
incrementSum() { | ||
this.state.sum += 1; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_owl.playground"> | ||
<div class="p-3"> | ||
hello world | ||
<p>◇─◇─ welcome to the Owl Playground! ─◇─◇</p> | ||
<p>Here you can experiment with Owl components and see how they work.</p> | ||
<p>Feel free to modify the code and see the changes in real-time.</p> | ||
<p>Use the buttons below to interact with the components.</p> | ||
<h2>Have fun!</h2> | ||
<h4>love u 🫶🏻💓</h4> | ||
</div> | ||
<div style="border: 1px solid #ccc; padding: 10px; margin: 10px; width: fit-content;"> | ||
<div style="display:inline"> | ||
<Counter callback.bind="incrementSum"/> | ||
<Counter callback.bind="incrementSum"/> | ||
</div> | ||
<br /> | ||
<br /> | ||
<p style="padding: 0 10px"> The sum is <t t-esc="state.sum"/> </p> | ||
</div> | ||
</t> | ||
|
||
<div style="border: 1px solid #ccc; padding: 10px; margin: 10px; width: fit-content;"> | ||
<h3>Todo List</h3> | ||
<TodoList /> | ||
</div> | ||
|
||
</t> | ||
|
||
</templates> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component } from "@odoo/owl"; | ||
|
||
export class TodoItem extends Component { | ||
static template = "awesome_owl.todo_item"; | ||
|
||
static props = { | ||
todo: { | ||
type: Object, | ||
optional: true, | ||
} | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_owl.todo_item"> | ||
<p class="card-text" t-att-class="props.todo.isCompleted ? 'text-decoration-line-through text-muted' : '' "> | ||
<t t-esc="props.todo.id"/>. <t t-esc="props.todo.description"/> | ||
</p> | ||
</t> | ||
|
||
</templates> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, useState } from "@odoo/owl"; | ||
import { TodoItem } from "./todo_item/todo_item"; | ||
|
||
export class TodoList extends Component { | ||
static template = "awesome_owl.todo_list"; | ||
|
||
static components = { | ||
TodoItem, | ||
}; | ||
|
||
setup() { | ||
this.todos = useState([]); | ||
} | ||
|
||
static props = { | ||
todos: { | ||
type: Array, | ||
optional: true, | ||
default: () => [], | ||
}, | ||
}; | ||
|
||
addTodo(ev){ | ||
let input_val = ev.target.value; | ||
if (ev.keyCode === 13 && input_val != "") { | ||
this.todos.push({ | ||
id: this.todos.length + 1, | ||
description: input_val, | ||
isCompleted: false, | ||
}); | ||
ev.target.value = ""; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_owl.todo_list"> | ||
<div class="container"> | ||
<div class="col"> | ||
<input type="text" placeholder="Add a new todo..." t-on-keyup="addTodo"/> | ||
<div class="card-body"> | ||
<t t-foreach="todos" t-as="todo" t-key="todo.id"> | ||
<TodoItem todo="todo" /> | ||
</t> | ||
</div> | ||
</div> | ||
</div> | ||
</t> | ||
|
||
</templates> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.