Skip to content

Commit 979ca12

Browse files
committed
[IMP] Card: modified Card component to use default slot.
1 parent e4f3f1a commit 979ca12

12 files changed

+79
-330
lines changed

awesome_owl/static/src/card/card.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@ export class Card extends Component {
77
type: 'String',
88
optional: 'true',
99
},
10-
content: {
11-
type: 'String',
12-
optional: 'true',
13-
},
1410
ace: {
1511
type: 'Function',
1612
optional: 'true',
1713
},
14+
slots: {
15+
type: 'Object',
16+
optional: 'true',
17+
},
1818
};
1919

2020
setup() {
21-
this.test_title = "<p>Why do I need to put quotes <em>INSIDE</em> quotes???</p>";
22-
this.test_content = markup('<p>This limitation of passing the contents of quotation marks as raw javascript is really annoying.</br>I mean, who would want to put quotation marks <em>INSIDE ANOTHER PAIR OF QUOTATION MARKS EVERY SINGLE TIME THEY WANT TO PASS TEXT TO A COMPONENT!</em></br>Though, I guess it could be useful to pass a javascript function to the component.</br>If for whatever reason you wanted to do that.</p>');
23-
this.title = this.props.title ? this.props.title : this.test_title;
24-
this.content = this.props.content ? this.props.content : this.test_content;
21+
this.title = this.props.title ? this.props.title : 'No Title';
2522
if (this.props.ace) {
2623
this.props.ace(this);
2724
}

awesome_owl/static/src/card/card.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<t t-name="card.card">
44
<div class="card" t-on-click="() => {console.log(this.props)}">
55
<h5><t t-out="title"/></h5>
6-
<p><t t-out="content"/></p>
6+
<t t-slot="default"/>
77
</div>
88
</t>
99

awesome_owl/static/src/playground.xml

+14-6
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@
3535
}
3636
</style>
3737
<div class="p-3">
38-
<Counter onChange.bind="updateTotal"/>
39-
<Counter onChange.bind="updateTotal"/>
40-
<p>Total : <t t-esc="counter.value"/></p>
41-
<Card title="'Really cool title.'" content="'I told you it was really cool!'"/>
38+
<Card title="'Really cool title.'">
39+
<p>I told you it was really cool!</p>
40+
</Card>
4241
<Card />
43-
<Card title="'Actually, CAN you pass a function as a component?'" content="'No.'" ace="(obj) => {obj.content = 'Yes! But you need to call them inside the component.'}"/>
44-
<Card title="'This is another test of passing code instead of text. Does this work?'" content="('1' == 1)?'Yes!':'No.'"/>
42+
<Card title="'Card with cards inside!!!'">
43+
<Card title="'Card with counters'">
44+
<Counter onChange.bind="updateTotal"/>
45+
<Counter onChange.bind="updateTotal"/>
46+
<p>Total : <t t-esc="counter.value"/></p>
47+
</Card>
48+
<Card title="'Card with more counters'">
49+
<Counter onChange.bind="updateTotal"/>
50+
<Counter onChange.bind="updateTotal"/>
51+
</Card>
52+
</Card>
4553
<TodoList />
4654
</div>
4755
</t>

realestatinator/models/estate_property.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from odoo import api, exceptions, fields, models
22

33
class EstatePropery(models.Model):
4-
_name = 'estate_property'
4+
_name = 'estate.property'
55
_description = 'real estate property'
66
_order = 'id desc'
77
_sql_constraints = [

realestatinator/models/estate_property_offer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class EstatePropertyOffer(models.Model):
1414
('refused', 'Refused')
1515
], copy=False)
1616
partner_id = fields.Many2one('res.partner', string='Partner')
17-
property_id = fields.Many2one('estate_property', string='Property')
17+
property_id = fields.Many2one('estate.property', string='Property')
1818
validity = fields.Integer('Validity', default=7)
1919
date_deadline = fields.Date('Deadline', compute='_compute_deadline', inverse='_inverse_deadline')
2020
property_type_id = fields.Many2one(related='property_id.property_type_id', store=True)
@@ -48,7 +48,7 @@ def accept_offer(self):
4848
record.property_id.buyer = record.partner_id
4949
@api.model
5050
def create(self, vals):
51-
estate_property = self.env['estate_property'].browse(vals["property_id"])
51+
estate_property = self.env['estate.property'].browse(vals["property_id"])
5252
if vals["price"] < estate_property.best_price:
5353
raise exceptions.UserError(f'Offer must be higher than the current best offer({estate_property.best_price})')
5454
if estate_property.state == 'new':

realestatinator/models/estate_property_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class EstatePropertyType(models.Model):
99
]
1010

1111
name = fields.Char('Name', required=True)
12-
property_ids = fields.One2many('estate_property', 'property_type_id', string='Property Type')
12+
property_ids = fields.One2many('estate.property', 'property_type_id', string='Property Type')
1313
sequence = fields.Integer('sequence', default=1)
1414
offer_ids = fields.One2many('estate.property.offer', 'property_type_id', string='Offers')
1515
offer_count = fields.Integer(string='Offer Count', compute='_count_offers')

realestatinator/models/res_users.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
class Users(models.Model):
77
_inherit = 'res.users'
88

9-
property_ids = fields.One2many('estate_property', 'sales_person', string='Properties')
9+
property_ids = fields.One2many('estate.property', 'sales_person', string='Properties')
-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
<?xml version="1.0"?>
22
<odoo>
3-
<<<<<<< HEAD
4-
<menuitem id="estate_menu_root" name="estate">
5-
<menuitem id="estate_views_menu" name="Dashboard" action="estate_property_model_action"/>
6-
<menuitem id="property_settings_menu" name="Settings">
7-
<menuitem id="property_type_button" action="estate_property_type_action"/>
8-
<menuitem id="property_tags_button" action="estate_property_tags_action"/>
9-
</menuitem>
10-
</menuitem>
11-
=======
123
<menuitem id="estate_menu_root" name="estate">
134
<menuitem id="estate_views_menu" name="Dashboard" action="estate_property_model_action"/>
145
<menuitem id="property_settings_menu" name="Settings">
156
<menuitem id="property_type_button" action="estate_property_type_action"/>
167
<menuitem id="property_tags_button" action="estate_property_tags_action"/>
178
</menuitem>
189
</menuitem>
19-
>>>>>>> 114af13f0 ([ADD] real-estate-inator: Inator that helps you manage and sell real estate properties)
2010
</odoo>
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,13 @@
11
<?xml version="1.0"?>
22
<odoo>
3-
<<<<<<< HEAD
4-
<record id="estate_property_offer_action" model="ir.actions.act_window">
5-
<field name='name'>estate.property.offer.action</field>
6-
<field name='res_model'>estate.property.offer</field>
7-
<field name='view_mode'>list,form</field>
8-
<field name='domain'>[('property_type_id', '=', active_id)]</field>
9-
</record>
10-
<record id="estate_property_offer_view_list" model="ir.ui.view">
11-
<field name="name">estate.property.offer.view.list</field>
12-
<field name="model">estate.property.offer</field>
13-
<field name="arch" type="xml">
14-
<list string="Offers"
15-
editable="bottom"
16-
decoration-success="status == 'accepted'"
17-
decoration-danger="status == 'refused'"
18-
>
19-
<field name="price"/>
20-
<field name="partner_id"/>
21-
<button name="accept_offer" type="object" icon="fa-check" invisible="status == 'accepted' or status == 'refused'"/>
22-
<button name="refuse_offer" type="object" icon="fa-times" invisible="status == 'accepted' or status == 'refused'"/>
23-
<field name="date_deadline"/>
24-
<field name="validity"/>
25-
</list>
26-
</field>
27-
</record>
28-
=======
293
<record id="estate_property_offer_action" model="ir.actions.act_window">
304
<field name='name'>estate.property.offer.action</field>
315
<field name='res_model'>estate.property.offer</field>
326
<field name='view_mode'>list,form</field>
337
<field name='domain'>[('property_type_id', '=', active_id)]</field>
348
</record>
35-
<record id="estate_property_offer_list" model="ir.ui.view">
36-
<field name="name">estate_property_offer_list</field>
9+
<record id="estate_property_offer_view_list" model="ir.ui.view">
10+
<field name="name">estate.property.offer.view.list</field>
3711
<field name="model">estate.property.offer</field>
3812
<field name="arch" type="xml">
3913
<list string="Offers"
@@ -50,5 +24,4 @@
5024
</list>
5125
</field>
5226
</record>
53-
>>>>>>> 114af13f0 ([ADD] real-estate-inator: Inator that helps you manage and sell real estate properties)
5427
</odoo>
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
<?xml version="1.0"?>
22
<odoo>
3-
<<<<<<< HEAD
4-
<record id="estate_property_tags_action" model="ir.actions.act_window">
5-
<field name='name'>estate.property.tags.action</field>
6-
<field name='res_model'>estate.property.tags</field>
7-
<field name='view_mode'>list,form</field>
8-
</record>
9-
=======
103
<record id="estate_property_tags_action" model="ir.actions.act_window">
11-
<field name='name'>Estate Property Tag</field>
4+
<field name='name'>estate.property.tags.action</field>
125
<field name='res_model'>estate.property.tags</field>
136
<field name='view_mode'>list,form</field>
147
</record>
15-
>>>>>>> 114af13f0 ([ADD] real-estate-inator: Inator that helps you manage and sell real estate properties)
168
</odoo>
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,7 @@
11
<?xml version="1.0"?>
22
<odoo>
3-
<<<<<<< HEAD
4-
<record id="estate_property_type_action" model="ir.actions.act_window">
5-
<field name='name'>estate.property.type.action</field>
6-
<field name='res_model'>estate.property.type</field>
7-
<field name='view_mode'>list,form</field>
8-
</record>
9-
<record id="estate_property_type_view_list" model="ir.ui.view">
10-
<field name="name">estate.property.type.view.list</field>
11-
<field name="model">estate.property.type</field>
12-
<field name="arch" type="xml">
13-
<list string='Properties'>
14-
<field name='sequence' widget='handle'/>
15-
<field name='name'/>
16-
</list>
17-
</field>
18-
</record>
19-
<record id='estate_property_type_view_form' model='ir.ui.view'>
20-
<field name="name">estate.property.type.view.form</field>
21-
<field name="model">estate.property.type</field>
22-
<field name="arch" type="xml">
23-
<form>
24-
<h1><field name="name"/></h1>
25-
<button type="action" name="%(estate_property_offer_action)d" string='Offers' />
26-
<field name="offer_count"/>
27-
<notebook>
28-
<page string="Properties">
29-
<field name="property_ids">
30-
<list>
31-
<field name="name"/>
32-
<field name="expected_price"/>
33-
<field name="state"/>
34-
</list>
35-
</field>
36-
</page>
37-
<page string="Offers">
38-
<field name="offer_ids"/>
39-
</page>
40-
</notebook>
41-
</form>
42-
</field>
43-
</record>
44-
=======
453
<record id="estate_property_type_action" model="ir.actions.act_window">
46-
<field name='name'>Estate Property Type</field>
4+
<field name='name'>estate.property.type.action</field>
475
<field name='res_model'>estate.property.type</field>
486
<field name='view_mode'>list,form</field>
497
</record>
@@ -82,5 +40,4 @@
8240
</form>
8341
</field>
8442
</record>
85-
>>>>>>> 114af13f0 ([ADD] real-estate-inator: Inator that helps you manage and sell real estate properties)
8643
</odoo>

0 commit comments

Comments
 (0)