Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ dmypy.json

# Pyre type checker
.pyre/

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

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

static props = {
title : String,
slots : { type: Object, optional: true}
}

setup() {
this.state = useState({ open: false });
this.changeState = this.changeState.bind(this)
}

changeState() {
this.state.open = !this.state.open
}
}
20 changes: 20 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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-out="props.title"/>
</h5>
<t>
<button t-on-click="changeState"/>
</t>
<t t-if="state.open">
<div class="card-text">
<t t-slot="default"/>
</div>
</t>
</div>
</div>
</t>
</templates>
20 changes: 20 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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() {
if (this.props.onChange){
this.props.onChange();
}
this.state.value++;
}
}
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">
<div class="p-3">
<p>Counter: <t t-esc="state.value"/></p>
<button class="btn btn-primary" t-on-click="increment">Increment</button>
</div>
</t>
</templates>
28 changes: 28 additions & 0 deletions awesome_owl/static/src/global_counter/global_counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Component, useState } from "@odoo/owl";
import { Counter } from "../counter/counter";

export class GlobalCounter extends Component {
static template = "awesome_owl.global_counter";

static components = {
Counter
}

static props = {
buttons: Number
}

setup() {
this.buttons = []
for (let i = 0; i < this.props.buttons; i++) {
this.buttons.push(i)
}

this.state = useState({ value: 2 });
this.incrementSum = this.incrementSum.bind(this)
}

incrementSum() {
this.state.value++;
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/global_counter/global_counter.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.global_counter">
<div class="p-3">
<p>the sum is: <t t-esc="state.value"/></p>
<t t-foreach="buttons" t-as="i" t-key="i">
<Counter onChange="incrementSum"/>
</t>
</div>
</t>
</templates>
19 changes: 18 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import { Component } from "@odoo/owl";
import { Component, useState, markup } from "@odoo/owl";
import { Counter } from "./counter/counter";
import { Card } from "./card/card";
import { GlobalCounter } from "./global_counter/global_counter";
import { TodoItem } from "./todolist/todo_item";
import { TodoList } from "./todolist/todo_list";

export class Playground extends Component {
setup(){
this.normal_string = "normal string"
this.html_string = markup("<a href=https://www.w3schools.com>Visit W3Schools.com!</a>")
}

static template = "awesome_owl.playground";
static components = {
Counter,
Card,
TodoList,
GlobalCounter,

}
}
10 changes: 8 additions & 2 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
</div>
<!-- <GlobalCounter buttons="3"/>
<Card title="'card 1'" content="'normal_string'"/> -->
<Card title="'some title'">
<ul>
<GlobalCounter buttons="3"/>
</ul>
</Card>
<TodoList/>
</t>

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

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

static props = {
todo: Object,
toggleState: Function,
removeTodo: Function
}

setup() {
this.toggleStateItem = this.toggleStateItem.bind(this)
this.removeTodoItem = this.removeTodoItem.bind(this)
}

toggleStateItem() {
this.props.toggleState(this.props.todo.id)
}

removeTodoItem() {
this.props.removeTodo(this.props.todo.id)
}
}
12 changes: 12 additions & 0 deletions awesome_owl/static/src/todolist/todo_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.todoitem">
<div class="p-3">
<p t-att-class="{ 'text-decoration-line-through': props.todo.isCompleted }">
<input t-on-change="toggleStateItem" type="checkbox" t-att-checked="props.todo.isCompleted"/>
<t t-esc="props.todo.id"/>. <t t-esc="props.todo.description"/>
<span t-on-click="removeTodoItem" class="fa fa-remove"/>
</p>
</div>
</t>
</templates>
56 changes: 56 additions & 0 deletions awesome_owl/static/src/todolist/todo_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Component, useState, useRef, onMounted } from "@odoo/owl";
import { TodoItem } from "./todo_item";

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

static components = {
TodoItem,
}

static props = {
}

setup() {
this.state = useState({
text: "",
todos: [],

})
this.last_id = 0
this.inputRef = useRef('input')

onMounted(() => {
this.inputRef.el.focus()
});

this.toggleState = this.toggleState.bind(this)
this.removeTodo = this.removeTodo.bind(this)
}

toggleState(id) {
const index = this.state.todos.findIndex((elem) => elem.id === id);
if (index >= 0) {
// remove the element at index from list
this.state.todos[index].isCompleted = !this.state.todos[index].isCompleted
}
}

removeTodo(id) {
const index = this.state.todos.findIndex((elem) => elem.id === id);
if (index >= 0) {
// remove the element at index from list
this.state.todos.splice(index, 1)
}

}

addTodo(event) {
if (this.state.text == "") return
if (event.keyCode == 13) {
const newTodo = { id: this.last_id, description: this.state.text, isCompleted: false }
this.state.todos.push(newTodo)
this.last_id = this.last_id + 1
}
}
}
14 changes: 14 additions & 0 deletions awesome_owl/static/src/todolist/todo_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.todolist">
<div class="p-3">
<div>
<input t-ref="input" t-on-keyup="addTodo" placeholder="Enter a new task" t-model="state.text" />
<span t-esc="state.text" />
</div>
<t t-foreach="state.todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo" toggleState="toggleState" removeTodo="removeTodo"/>
</t>
</div>
</t>
</templates>
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
'name': 'estate-kehey',
'depends': [
'base',
],
'data': [
'data/ir.model.access.csv',
'views/estate_property_actions.xml',
'views/estate_property_tag_view_list.xml',
'views/estate_property_type_view_form.xml',
'views/estate_property_type_view_list.xml',
'views/estate_property_view_form.xml',
'views/estate_property_view_kanban.xml',
'views/estate_property_view_list.xml',
'views/estate_property_view_search.xml',
'views/users_extra_views.xml',
'data/estate_menus.xml',
],
'application': True,
}
13 changes: 13 additions & 0 deletions estate/data/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="test_menu_root" name="Real Estate">
<menuitem id="test_first_level_menu" name="Advertisements">
<menuitem id="test_model_menu_action" action="estate_property_action"/>
</menuitem>
<menuitem id="settings" name="Settings">
<menuitem id="property_type_menu_action" action="estate_property_type_action"/>
<menuitem id="property_tag_menu_action" action="estate_property_tag_action"/>
</menuitem>
</menuitem>
</odoo>

6 changes: 6 additions & 0 deletions estate/data/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_estate_property_user,access_estate_property_user,model_estate_property,base.group_user,1,1,1,1
access_estate_property_type_user,access_estate_property_user,model_estate_property_type,base.group_user,1,1,1,1
access_estate_property_tag_user,access_estate_property_user,model_estate_property_tag,base.group_user,1,1,1,1
access_estate_property_offer_user,access_estate_property_user,model_estate_property_offer,base.group_user,1,1,1,1

Empty file added estate/git-challenge.txt
Empty file.
8 changes: 8 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from . import (
estate_property,
estate_property_offer,
estate_property_tag,
estate_property_type,
inhereted_users,
)

Loading