summaryrefslogtreecommitdiff
path: root/addons/portal_rating/views
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/portal_rating/views
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/portal_rating/views')
-rw-r--r--addons/portal_rating/views/assets.xml13
-rw-r--r--addons/portal_rating/views/portal_templates.xml8
-rw-r--r--addons/portal_rating/views/rating_templates.xml54
-rw-r--r--addons/portal_rating/views/rating_views.xml13
4 files changed, 88 insertions, 0 deletions
diff --git a/addons/portal_rating/views/assets.xml b/addons/portal_rating/views/assets.xml
new file mode 100644
index 00000000..d962bea4
--- /dev/null
+++ b/addons/portal_rating/views/assets.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <template id="assets_frontend" inherit_id="web_editor.assets_frontend" name="Portal Rating Assets">
+ <xpath expr="//link[last()]" position="after">
+ <link rel="stylesheet" type="text/scss" href="/portal_rating/static/src/scss/portal_rating.scss"/>
+ </xpath>
+ <xpath expr="//script[last()]" position="after">
+ <script type="text/javascript" src="/portal_rating/static/src/js/portal_chatter.js"></script>
+ <script type="text/javascript" src="/portal_rating/static/src/js/portal_composer.js"></script>
+ <script type="text/javascript" src="/portal_rating/static/src/js/portal_rating_composer.js"></script>
+ </xpath>
+ </template>
+</odoo>
diff --git a/addons/portal_rating/views/portal_templates.xml b/addons/portal_rating/views/portal_templates.xml
new file mode 100644
index 00000000..d616bc49
--- /dev/null
+++ b/addons/portal_rating/views/portal_templates.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <template id="message_thread" inherit_id="portal.message_thread">
+ <xpath expr="//div[@id='discussion']" position="attributes">
+ <attribute name="t-att-data-display_rating">display_rating or False</attribute>
+ </xpath>
+ </template>
+</odoo>
diff --git a/addons/portal_rating/views/rating_templates.xml b/addons/portal_rating/views/rating_templates.xml
new file mode 100644
index 00000000..7125f283
--- /dev/null
+++ b/addons/portal_rating/views/rating_templates.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <!--
+ Rating widget static: show 5 stars (full or empty) regarding the given rating_avg and rating_count
+ -->
+ <template id="rating_widget_stars_static" name="Rating: static star widget">
+ <t t-set="rating_avg" t-value="round(rating_avg * 100) / 100"/>
+ <t t-set="val_decimal" t-value="round(rating_avg % 1, 1)"/>
+ <t t-set="val_integer" t-value="int(rating_avg)"/>
+ <t t-set="empty_star" t-value="5 - (val_integer+1) if val_decimal else 5 - val_integer"/>
+ <div class="o_website_rating_static" t-att-style="inline_mode and 'display:inline'" t-att-title="rating_avg">
+ <t t-foreach="range(0, val_integer)" t-as="num">
+ <i class="fa fa-star" role="img"></i>
+ </t>
+ <t t-if="val_decimal">
+ <i class="fa fa-star-half-o" role="img"></i>
+ </t>
+ <t t-foreach="range(0, empty_star)" t-as="num">
+ <i class="fa fa-star text-black-25" role="img"></i>
+ </t>
+ (<t t-esc="rating_count"/>)
+ </div>
+ </template>
+
+ <!--
+ Display static star widget, and open rating composer on click
+ This template provide the container of the Popup Rating Composer. The rest is done in js.
+ To use this template, you need to call it after setting the following variable in your template or in your controller:
+ :float rating_avg : average rating to be displayed with star widget
+ :object browserecord : the mail_thread object
+ :token string (optional): if you want your chatter to be available for non-logged user,
+ you can use a token to verify the identity of the user;
+ the message will be posted with the identity of the partner_id of the object
+ -->
+ <template id="rating_stars_static_popup_composer" name="Rating: rating composer in popup">
+ <div class="d-print-none o_rating_popup_composer o_not_editable p-0"
+ t-att-data-rating-avg="rating_avg or 0.0"
+ t-att-data-rating-total="rating_total or 0.0"
+ t-att-data-token="token"
+ t-att-data-hash="hash"
+ t-att-data-pid="pid"
+ t-att-data-res_model="object._name"
+ t-att-data-res_id="object.id"
+ t-att-data-partner_id="request.env.user.partner_id.id"
+ t-att-data-default_message="default_message"
+ t-att-data-default_message_id="default_message_id"
+ t-att-data-default_rating_value="default_rating_value"
+ t-att-data-default_attachment_ids="default_attachment_ids"
+ t-att-data-force_submit_url="force_submit_url"
+ t-att-data-disable_composer="disable_composer"
+ t-att-data-link_btn_classes="_link_btn_classes">
+ </div>
+ </template>
+</odoo>
diff --git a/addons/portal_rating/views/rating_views.xml b/addons/portal_rating/views/rating_views.xml
new file mode 100644
index 00000000..e2386ed3
--- /dev/null
+++ b/addons/portal_rating/views/rating_views.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <record id="rating_rating_view_form" model="ir.ui.view">
+ <field name="name">rating.rating.view.form</field>
+ <field name="model">rating.rating</field>
+ <field name="inherit_id" ref="rating.rating_rating_view_form"/>
+ <field name="arch" type="xml">
+ <xpath expr="//field[@name='rating_text']" position="after">
+ <field name="publisher_comment" string="Comment"/>
+ </xpath>
+ </field>
+ </record>
+</odoo>