Skip to content

Commit 0eeb68c

Browse files
committed
[IMP] estate: add additional checks while marking property as sold or cancel, add missing eod
1 parent b229be4 commit 0eeb68c

File tree

17 files changed

+185
-55
lines changed

17 files changed

+185
-55
lines changed

awesome_owl/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
('include', 'web._assets_core'),
3737
'web/static/src/libs/fontawesome/css/font-awesome.css',
3838
'awesome_owl/static/src/**/*',
39+
'awesome_owl/static/css/**'
3940
],
4041
},
4142
'license': 'AGPL-3'

awesome_owl/static/css/style.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.fade-in {
2+
opacity: 0;
3+
transform: translateY(-10px);
4+
transition: opacity 0.5s ease, transform 0.5s ease;
5+
}
6+
7+
.fade-in.show {
8+
opacity: 1;
9+
transform: translateY(0);
10+
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
import { Component, markup } from '@odoo/owl'
1+
import { Component, markup, useState } from '@odoo/owl'
22

33
export class Card extends Component {
44
static template = "awesome_owl.Card"
55
static components = {}
66
static props = {
7-
title: { type: String, default: "Card Title" },
8-
body: { type: String, default: "Card Body" },
7+
title: { type: String, default: "Card Title", required: true },
8+
slots: { type: Object },
99
visit: { type: String, default: "Visit us", optional: true }
1010
}
1111

1212
setup() {
1313
super.setup();
14+
this.state = useState({ isOpen: true })
1415
this.markup_visit = markup(this.props.visit)
1516
}
17+
18+
toggleCard() {
19+
this.state.isOpen = !this.state.isOpen;
20+
}
1621
}

awesome_owl/static/src/components/card/card.xml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<template xml:space="preserve">
33
<t t-name="awesome_owl.Card">
4-
<div class="card d-inline-block m-2" style="width: 18rem;">
4+
<div class="card d-inline-block m-2" style="width: 28rem;">
55
<div class="card-body">
6-
<h5 class="card-title"><t t-esc="props.title"/></h5>
7-
<p class="card-text">
8-
<t t-esc="props.body"/>
9-
</p>
10-
<t t-if="props.visit">
11-
<t t-out="markup_visit"></t>
12-
</t>
6+
<div class="d-flex mb-3" style="justify-content: space-between">
7+
<h5 class="card-title"><t t-esc="props.title"/></h5>
8+
<button class="btn btn-sm text-bg-light" t-on-click="toggleCard">
9+
<t t-if="state.isOpen">
10+
Close
11+
</t>
12+
<t t-else="">
13+
Open
14+
</t>
15+
</button>
16+
</div>
17+
<div t-if="state.isOpen">
18+
<p class="card-text">
19+
<t t-slot="default"/>
20+
</p>
21+
<t t-if="props.visit">
22+
<t t-out="markup_visit"></t>
23+
</t>
24+
</div>
1325
</div>
1426
</div>
1527
</t>

awesome_owl/static/src/components/counter/counter.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="card-body">
66
<h2 class="card-title">Counter</h2>
77
<div class="d-flex" style="align-items: center; justify-content: space-between">
8-
<button class="btn btn-success" t-on-click="increment" style="background-color: 'blue'">Increment</button>
8+
<button class="btn text-bg-success" t-on-click="increment" style="background-color: 'blue'">Increment</button>
99
<p class="card-text">Value: <t t-esc="state.value"/></p>
1010
</div>
1111
</div>

awesome_owl/static/src/components/playground/playground.js

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

3-
import { Component, useState, useEffect } from "@odoo/owl";
3+
import { Component, useEffect, useState } from "@odoo/owl";
44
import { Counter } from "../counter/counter";
55
import { Card } from "../card/card";
66
import { TodoList } from "../todo/todolist/todolist";
@@ -11,10 +11,11 @@ export class Playground extends Component {
1111
static props = {}
1212

1313
setup() {
14-
this.state = useState({ counters: 2, sum: 0 });
14+
super.setup();
15+
this.state = useState({ counters: 2, sum: 2 });
1516

1617
useEffect(() => {
17-
this.state.sum = this.state.counters;
18+
this.state.sum += this.state.counters;
1819
},()=>[this.state.counters]);
1920

2021
this.cards = [
@@ -53,6 +54,5 @@ export class Playground extends Component {
5354

5455
incrementSum() {
5556
this.state.sum++;
56-
5757
}
5858
}

awesome_owl/static/src/components/playground/playground.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@
2020
<div class="mt-4">
2121
<h2>Card Components</h2>
2222
<t t-foreach="cards" t-as="card" t-key="card_index">
23-
<Card t-props="card_value"/>
23+
<Card t-props="{
24+
title: card.title,
25+
visit: card.visit
26+
}">
27+
<t t-if="card_last or card_first">
28+
<Counter onChange.bind="incrementSum"/>
29+
</t>
30+
<t t-else="">
31+
<t t-esc="card.body"/>
32+
</t>
33+
</Card>
2434
</t>
2535
</div>
2636

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, useState } from "@odoo/owl"
1+
import { Component, onMounted, useRef } from "@odoo/owl"
22
import { Card } from "../../card/card"
33

44
export class TodoItem extends Component {
@@ -7,16 +7,30 @@ export class TodoItem extends Component {
77
static props = {
88
id: { type: Number },
99
description: { type: String },
10-
isCompleted: { type: Boolean, default: false }
10+
isCompleted: { type: Boolean, default: false },
11+
markTodocallback: { type: Function },
12+
deleteTodocallback: { type: Function }
1113
}
1214

1315
setup() {
14-
this.state = useState({
15-
todo: {
16-
id: String(this.props.id),
17-
description: this.props.description,
18-
isCompleted: this.props.isCompleted
19-
}
20-
})
16+
super.setup();
17+
this.todo_ref = useRef("todo_ref");
18+
this.todo_togglestatus = useRef("todo_togglestatus");
19+
20+
onMounted(() => {
21+
requestAnimationFrame(() => {
22+
this.todo_ref.el.classList.add("show");
23+
});
24+
25+
this.todo_togglestatus.el.addEventListener("change", () => {
26+
this.props.markTodocallback(this.props.id);
27+
28+
})
29+
});
30+
31+
}
32+
33+
deleteTodo() {
34+
this.props.deleteTodocallback(this.props.id)
2135
}
2236
}

awesome_owl/static/src/components/todo/todoitem/todoitem.xml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<templates xml:space="preserve">
33
<t t-name="awesome_owl.todoitem">
4-
<div class="card d-inline-block m-2" style="width: 18rem;" t-att-class="{'text-muted': !state.todo.isCompleted, 'text-decoration-line-through': !state.todo.isCompleted, 'bg-body-tertiary': !state.todo.isCompleted, 'text-body-tertiary': !state.todo.isCompleted}">
4+
<div t-ref="todo_ref" class="card d-inline-block m-2 fade-in" style="width: 18rem;" t-att-class="{'text-muted': props.isCompleted, 'text-decoration-line-through': props.isCompleted, 'bg-body-tertiary': props.isCompleted, 'text-body-tertiary': props.isCompleted}">
55
<div class="card-body">
66
<h3 class="card-title">
7-
<t t-esc="state.todo.id"/>
7+
<div class="d-flex gap-3" style="justify-content: space-between">
8+
<div class="d-flex gap-3">
9+
<input t-att-id="'todo-' + props.id" style="accent-color: grey; width: 18px" t-ref="todo_togglestatus" type="checkbox" />
10+
<label
11+
t-att-for="'todo-' + props.id"
12+
class="cursor-pointer"
13+
>
14+
<t t-esc="props.id"/>
15+
</label>
16+
</div>
17+
<button
18+
class="btn btn-sm text-bg-danger"
19+
style="text-decoration: none"
20+
t-on-click="deleteTodo"
21+
>
22+
<i class="fa fa-trash fa-lg"></i>
23+
</button>
24+
</div>
825
</h3>
926
<p class="card-text">
10-
<t t-esc="state.todo.description"/>
27+
<t t-esc="props.description"/>
1128
</p>
1229
</div>
1330
</div>
Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
1-
import { Component, useState } from "@odoo/owl"
1+
import { Component, useState, useRef } from "@odoo/owl"
22
import { TodoItem } from "../todoitem/todoitem";
3+
import { useAutofocus } from '../../../utils.js';
4+
35

46
export class TodoList extends Component {
57
static template = "awesome_owl.todolist"
68
static components = { TodoItem }
79
static props = {}
810

911
setup() {
10-
this.todos = useState([
11-
{ id: 1, description: "Buy milk", isCompleted: false },
12-
{ id: 2, description: "Walk the dog", isCompleted: true },
13-
{ id: 3, description: "Write blog post", isCompleted: false },
14-
{ id: 4, description: "Call mom", isCompleted: true },
15-
{ id: 5, description: "Clean the house", isCompleted: false },
16-
{ id: 6, description: "Pay bills", isCompleted: false },
17-
{ id: 7, description: "Read a book", isCompleted: true },
18-
{ id: 8, description: "Exercise", isCompleted: false }
19-
]);
12+
super.setup();
13+
this.todos = useState([]);
14+
this.todoInputRef = useRef("todoInputRef");
15+
this.markTodo = this.markTodo.bind(this);
16+
17+
useAutofocus("todoInputRef");
18+
19+
}
20+
21+
addTodo(ev) {
22+
if(ev.keyCode == 13) {
23+
let max_id = Math.max(...this.todos.map(todo => todo.id), 0);
24+
let new_description = this.todoInputRef.el.value;
25+
this.todos.push({ id: max_id + 1, description: new_description, isCompleted: false});
26+
this.todoInputRef.el.value = "";
27+
}
28+
}
29+
30+
markTodo(todo_id) {
31+
this.todos.forEach((todo, index) => {
32+
if (todo.id == todo_id) {
33+
todo.isCompleted = !todo.isCompleted;
34+
}
35+
});
36+
}
37+
38+
deleteTodo(todo_id) {
39+
this.todos.forEach((todo, index) => {
40+
if (todo.id == todo_id) {
41+
this.todos.splice(index,1)
42+
}
43+
});
2044
}
2145
}

0 commit comments

Comments
 (0)