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
25 changes: 25 additions & 0 deletions awesome_dashboard/static/src/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
import { Component } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks";
import { DashboardItem } from "./dashboard_item/dashboard_item"

class AwesomeDashboard extends Component {
static template = "awesome_dashboard.AwesomeDashboard";

static components = {
Layout,
DashboardItem
}

setup() {
this.action = useService("action")
}


openCustomers() {
this.action.doAction("base.action_partner_form")
}

openLeads() {
this.action.doAction({
type: 'ir.actions.act_window',
res_model: 'crm.lead',
views: [[false, 'list'], [false, 'form']]
})
}
}

registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
3 changes: 3 additions & 0 deletions awesome_dashboard/static/src/dashboard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.o_dashboard {
background-color: azure;
}
13 changes: 12 additions & 1 deletion awesome_dashboard/static/src/dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">
hello dashboard
<Layout display="{ controlPanel: {} }" className="'o_dashboard h-100'">
<t t-set-slot="control-panel-create-button">
<button t-on-click="openCustomers" class="btn btn-primary">Customer</button>
<button t-on-click="openLeads" class="btn btn-primary">Leads</button>
</t>
<DashboardItem size="1">
This is a smol item
</DashboardItem>
<DashboardItem size="3">
This is a BIG item
</DashboardItem>
</Layout>
</t>

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

export class DashboardItem extends Component {
static template = "awesome_dashboard.dashboard_item";

static props = {
size: {type:Number, default: 1},
slots: {type: Object, optional: true}
}
}
10 changes: 10 additions & 0 deletions awesome_dashboard/static/src/dashboard_item/dashboard_item.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.card {
display: flex;
flex-direction: row;
align-items: center;
background: white;
border-radius: 0.5rem;
border: none;
padding: 1rem;
margin: 2rem
}
10 changes: 10 additions & 0 deletions awesome_dashboard/static/src/dashboard_item/dashboard_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.dashboard_item">
<div class="card" t-att-style="'width: calc(18rem * ' + props.size + ');'">
<t t-slot="default"/>
</div>
</t>

</templates>
2 changes: 1 addition & 1 deletion awesome_owl/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
('include', 'web._assets_bootstrap'),
('include', 'web._assets_core'),
'web/static/src/libs/fontawesome/css/font-awesome.css',
'awesome_owl/static/src/**/*',
'awesome_owl/static/src/**/*'
],
},
'license': 'AGPL-3'
Expand Down
23 changes: 23 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, useState } from "@odoo/owl";

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

static props = {
title: {type: String, validate: val => {
if(val.length === 0) return false;

let first = val.substring(0, 1);
return first === first.toUpperCase();
}},
slots: {type: Object, optional: true},
}

setup() {
this.state = useState({open: true});
}

toggle(){
this.state.open = !this.state.open;
}
}
18 changes: 18 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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">
<div>
<h5 class="card-title">
<t t-esc="props.title"/>
</h5>
<button t-on-click="toggle">Toggle</button>
</div>
<t t-if="state.open" t-slot="default"/>
</div>
</div>
</t>

</templates>
18 changes: 18 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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: 1 });
}

increment() {
this.state.value++;
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">
<p>Counter: <t t-esc="state.value"/></p>
<button class="btn btn-primary" t-on-click="increment">Increment</button>
</t>

</templates>
22 changes: 21 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import { Component } from "@odoo/owl";
import { Component, markup, 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";

someHtml = "<div class='text-primary'>some content</div>"
markupedHtml = markup(this.someHtml);

static components = {
Counter,
Card,
TodoList
};

setup() {
this.state = useState({ sum: 2 });
}

incrementSum() {
this.state.sum++;
}
}
19 changes: 18 additions & 1 deletion awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,25 @@

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
hello word
<Counter onChange.bind="incrementSum"/>
</div>
<Counter onChange.bind="incrementSum"/>
<Card title="'Hi'">
This is working
</Card>
<Card title="'Food'">
<Counter onChange.bind="incrementSum"/>
</Card>
<Card title="'No markup'">
<t t-out="someHtml"/>
</Card>
<Card title="'Markup'">
<t t-out="markupedHtml"/>
</Card>
<!--<Card title="'bad'">This title is bad</Card>-->
<p>The sum : <t t-esc="state.sum"/></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";

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

static props = {
todo: {type: Object, shape: {id: Number, description: String, isCompleted: Boolean}},
toggleState: Function,
removeTodo: Function
}

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

remove() {
this.props.removeTodo(this.props.todo.id)
}
}
14 changes: 14 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,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="awesome_owl.todo_item">
<div>
<input type="checkbox" t-on-click="complete"/>
<span t-att-class="{'text-muted text-decoration-line-through': props.todo.isCompleted}"><t t-esc="props.todo.id"/></span>
<span t-att-class="{'text-muted text-decoration-line-through': props.todo.isCompleted}">. </span>
<span t-att-class="{'text-muted text-decoration-line-through': props.todo.isCompleted}"><t t-esc="props.todo.description"/></span>
<span t-on-click="remove" class="fa fa-remove"/>
</div>
</t>

</templates>
38 changes: 38 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,38 @@
import { Component, useState } from "@odoo/owl";
import { TodoItem } from "../todo_item/todo_item";
import { useAutofocus } from "../util";

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

counter = 1;

static components = {
TodoItem
}

setup() {
this.todos = useState([]);
useAutofocus("input");
}

change(id) {
let found = this.todos.findIndex(t => t.id === id);
if(found >= 0) this.todos[found] = {...this.todos[found], isCompleted: !this.todos[found].isCompleted};
}

remove(id) {
let found = this.todos.findIndex(t => t.id === id);
if(found >= 0) this.todos.splice(found, 1);
}

tryAdd(ev) {
if(ev.keyCode != 13) return;

let txt = ev.srcElement.value;
if(txt === "") return;

this.todos.push({id: this.counter++, description: txt, isCompleted: false});
ev.srcElement.value = "";
}
}
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">
<input t-ref="input" t-on-keyup="tryAdd" type="text" placeholder="Enter a new task"/>
<div t-foreach="todos" t-as="i" t-key="i.id">
<TodoItem todo="i" toggleState.bind="change" removeTodo.bind="remove"/>
</div>
</t>

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

export function useAutofocus(refName) {
let ref = useRef(refName);
onMounted(() => {
ref.el?.focus()
})
}
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
16 changes: 16 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
'name': 'Real Estate',
'author': 'zavan',
'depends': ['base'],
'application': True,
'license': 'LGPL-3',
'data': [
'security/ir.model.access.csv',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_property_views.xml',
'views/estate_menus.xml',
'views/res_users_views.xml'
]
}
5 changes: 5 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
from . import res_users
Loading