| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<odoo> |
| 3 |
<!-- |
| 4 |
Rating widget static: show 5 stars (full or empty) regarding the given rating_avg and rating_count |
| 5 |
--> |
| 6 |
<template id="rating_widget_stars_static" name="Rating: static star widget"> |
| 7 |
<t t-set="rating_avg" t-value="round(rating_avg * 100) / 100"/> |
| 8 |
<t t-set="val_decimal" t-value="round(rating_avg % 1, 1)"/> |
| 9 |
<t t-set="val_integer" t-value="int(rating_avg)"/> |
| 10 |
<t t-set="empty_star" t-value="5 - (val_integer+1) if val_decimal else 5 - val_integer"/> |
| 11 |
<div class="o_website_rating_static" t-att-style="inline_mode and 'display:inline'" t-att-title="rating_avg"> |
| 12 |
<t t-if="rating_style_compressed"> |
| 13 |
<t t-if="rating_avg <= 2"> |
| 14 |
<i class="fa fa-star-o" role="img"></i> |
| 15 |
</t> |
| 16 |
<t t-elif="rating_avg >= 2.1 and rating_avg <= 3.5"> |
| 17 |
<i class="fa fa-star-half-o" role="img"></i> |
| 18 |
</t> |
| 19 |
<t t-else=""> |
| 20 |
<i class="fa fa-star" role="img"></i> |
| 21 |
</t> |
| 22 |
<small class="text-muted ms-1"> |
| 23 |
<t t-esc="rating_avg"/> |
| 24 |
</small> |
| 25 |
</t> |
| 26 |
<t t-else=""> |
| 27 |
<t t-foreach="range(0, val_integer)" t-as="num"> |
| 28 |
<i class="fa fa-star" role="img"></i> |
| 29 |
</t> |
| 30 |
<t t-if="val_decimal"> |
| 31 |
<i class="fa fa-star-half-o" role="img"></i> |
| 32 |
</t> |
| 33 |
<t t-foreach="range(0, empty_star)" t-as="num"> |
| 34 |
<i class="fa fa-star-o" role="img"></i> |
| 35 |
</t> |
| 36 |
<small class="text-muted ms-1"> |
| 37 |
(<t t-esc="rating_count"/>) |
| 38 |
</small> |
| 39 |
</t> |
| 40 |
</div> |
| 41 |
</template> |
| 42 |
|
| 43 |
<!-- |
| 44 |
Display static star widget, and open rating composer on click |
| 45 |
This template provide the container of the Popup Rating Composer. The rest is done in js. |
| 46 |
To use this template, you need to call it after setting the following variable in your template or in your controller: |
| 47 |
:float rating_avg : average rating to be displayed with star widget |
| 48 |
:object browserecord : the mail_thread object |
| 49 |
:token string (optional): if you want your chatter to be available for non-logged user, |
| 50 |
you can use a token to verify the identity of the user; |
| 51 |
the message will be posted with the identity of the partner_id of the object |
| 52 |
--> |
| 53 |
<template id="rating_stars_static_popup_composer" name="Rating: rating composer in popup"> |
| 54 |
<t t-set="display_composer" t-value="not disable_composer and not (request.session.uid and env.user._is_public())"/> |
| 55 |
|
| 56 |
<div class="d-print-none o_rating_popup_composer o_not_editable p-0" |
| 57 |
contenteditable="false" |
| 58 |
t-att-data-rating_avg="rating_avg or 0.0" |
| 59 |
t-att-data-rating_count="rating_count or 0.0" |
| 60 |
t-att-data-token="token" |
| 61 |
t-att-data-hash="hash" |
| 62 |
t-att-data-pid="pid" |
| 63 |
t-att-data-res_model="object._name" |
| 64 |
t-att-data-res_id="object.id" |
| 65 |
t-att-data-partner_id="request.env.user.partner_id.id" |
| 66 |
t-att-data-default_message="default_message" |
| 67 |
t-att-data-default_message_id="default_message_id" |
| 68 |
t-att-data-default_rating_value="default_rating_value" |
| 69 |
t-att-data-default_attachment_ids="default_attachment_ids" |
| 70 |
t-att-data-force_submit_url="force_submit_url" |
| 71 |
t-att-data-rate_with_void_content="rate_with_void_content" |
| 72 |
t-att-data-disable_composer="disable_composer" |
| 73 |
t-att-data-display_composer="display_composer" |
| 74 |
t-att-data-link_btn_classes="_link_btn_classes" |
| 75 |
t-att-data-icon="icon" |
| 76 |
t-att-data-text_classes="_text_classes" |
| 77 |
t-att-data-hide_rating_avg="hide_rating_avg" |
| 78 |
t-att-data-is_fullscreen="is_fullscreen"> |
| 79 |
<div class="d-flex flex-wrap align-items-center"> |
| 80 |
<div class="o_rating_popup_composer_stars text-nowrap"/> |
| 81 |
<button t-if="display_composer" type="button" |
| 82 |
t-att-class="'btn ' + _link_btn_classes or 'btn-primary'" |
| 83 |
data-bs-toggle="modal" data-bs-target="#ratingpopupcomposer"> |
| 84 |
<i t-if="icon" t-att-class="icon"/> |
| 85 |
<span t-attf-class="#{_text_classes} o_rating_popup_composer_text"> |
| 86 |
<t t-if="is_fullscreen">Review</t> |
| 87 |
<t t-elif="default_message_id">Edit Review</t> |
| 88 |
<t t-else="">Add Review</t> |
| 89 |
</span> |
| 90 |
</button> |
| 91 |
<div class="o_rating_popup_composer_modal"/> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
</template> |
| 95 |
</odoo> |