[IMP] portal_rating: add static star compressed style

This commit adds a new template called "Rating: static star compressed
widget".
Instead, having 5 stars, it returns an empty/half/full star with the
average rating. This smaller layout is used in the dynamic snippets
product.

Adapts the style of empty stars (it uses the outline star icon instead grey
background) to work well on light and dark backgrounds.

Part of https://github.com/odoo/odoo/pull/75623
task-2602978

X-original-commit: 0690e187ebb7e67694c8236f420213beed29993d
Part-of: odoo/odoo#77153
This commit is contained in:
Brieuc-brd
2021-09-24 12:35:37 +00:00
committed by Jeremy Kersten
parent 2033ba58f5
commit 51d50a1379
+26 -10
View File
@@ -9,18 +9,34 @@
<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-if="rating_style_compressed">
<t t-if="rating_avg &lt;= 2">
<i class="fa fa-star-o" role="img"></i>
</t>
<t t-elif="rating_avg &gt;= 2.1 and rating_avg &lt;= 3.5">
<i class="fa fa-star-half-o" role="img"></i>
</t>
<t t-else="">
<i class="fa fa-star" role="img"></i>
</t>
<small class="text-muted ml-1">
<t t-esc="rating_avg"/>
</small>
</t>
<t t-if="val_decimal">
<i class="fa fa-star-half-o" role="img"></i>
<t t-else="">
<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-o" role="img"></i>
</t>
<small class="text-muted ml-1">
(<t t-esc="rating_count"/>)
</small>
</t>
<t t-foreach="range(0, empty_star)" t-as="num">
<i class="fa fa-star text-black-25" role="img"></i>
</t>
<small class="text-muted ml-1">
(<t t-esc="rating_count"/>)
</small>
</div>
</template>