summaryrefslogtreecommitdiff
path: root/addons/portal_rating/static/src/xml
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/static/src/xml
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/portal_rating/static/src/xml')
-rw-r--r--addons/portal_rating/static/src/xml/portal_chatter.xml116
-rw-r--r--addons/portal_rating/static/src/xml/portal_rating_composer.xml52
-rw-r--r--addons/portal_rating/static/src/xml/portal_tools.xml87
3 files changed, 255 insertions, 0 deletions
diff --git a/addons/portal_rating/static/src/xml/portal_chatter.xml b/addons/portal_rating/static/src/xml/portal_chatter.xml
new file mode 100644
index 00000000..93d0122c
--- /dev/null
+++ b/addons/portal_rating/static/src/xml/portal_chatter.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+ <!--
+ Inherited templates from portal to custom chatter with rating
+ -->
+ <t t-extend="portal.Composer">
+ <t t-jquery="textarea" t-operation="inner"><t t-esc="widget.options['default_message'] ? _.str.trim(widget.options['default_message']) : ''"/></t><!-- need to be one line to avoid \t in textarea -->
+ <t t-jquery="form" t-operation="attributes">
+ <attribute name="t-attf-action">#{widget.options['force_submit_url'] ? widget.options['force_submit_url'] : '/mail/chatter_post'}</attribute>
+ </t>
+ <t t-jquery=".o_portal_chatter_composer_form input[name='csrf_token']" t-operation="after">
+ <t t-call="portal_rating.rating_star_input">
+ <t t-set="default_rating" t-value="widget.options['default_rating_value']"/>
+ </t>
+ <input type="hidden" name="message_id" t-att-value="widget.options['default_message_id']" t-if="widget.options['default_message_id']"/>
+ </t>
+ </t>
+
+ <t t-extend="portal.chatter_messages">
+ <t t-jquery="t[t-raw='message.body']" t-operation="before">
+ <t t-if="message['rating_value']">
+ <t t-call="portal_rating.rating_stars_static">
+ <t t-set="val" t-value="message.rating_value"/>
+ </t>
+ </t>
+ </t>
+ <t t-jquery=".o_portal_chatter_attachments" t-operation="after">
+ <!--Only possible if a rating is link to the message, for now we can't comment if no rating
+ is link to the message (because publisher comment data
+ is on the rating.rating model - one comment max) -->
+ <t t-if="message.rating and message.rating.id" t-call="portal_rating.chatter_rating_publisher">
+ <t t-set="is_publisher" t-value="widget.options['is_user_publisher']"/>
+ <t t-set="rating" t-value="message.rating"/>
+ </t>
+ </t>
+ </t>
+
+ <t t-extend="portal.Chatter">
+ <t t-jquery="t[t-call='portal.chatter_message_count']" t-operation="replace">
+ <t t-if="widget.options['display_rating']">
+ <t t-call="portal_rating.rating_card"/>
+ </t>
+ <t t-if="!widget.options['display_rating']">
+ <t t-call="portal.chatter_message_count"/>
+ </t>
+ </t>
+ </t>
+
+ <!--
+ New templates specific of rating in Chatter
+ -->
+ <t t-name="portal_rating.chatter_rating_publisher">
+ <div class="o_wrating_publisher_container">
+ <button t-if="is_publisher"
+ t-attf-class="btn px-2 mb-2 btn-sm border o_wrating_js_publisher_comment_btn {{ rating.publisher_comment !== '' ? 'd-none' : '' }}"
+ t-att-data-mes_index="rating.mes_index">
+ <i class="fa fa-comment text-muted mr-1"/>Comment
+ </button>
+ <div class="o_wrating_publisher_comment mt-2 mb-2">
+ <t t-if="rating.publisher_comment" t-call="portal_rating.chatter_rating_publisher_comment"/>
+ </div>
+ </div>
+ </t>
+
+ <t t-name="portal_rating.chatter_rating_publisher_comment">
+ <div class="media o_portal_chatter_message">
+ <img class="o_portal_chatter_avatar" t-att-src="rating.publisher_avatar" alt="avatar"/>
+ <div class="media-body">
+ <div class="o_portal_chatter_message_title">
+ <div class="d-inline-block">
+ <h5 class="mb-1"><t t-esc="rating.publisher_name"/></h5>
+ </div>
+ <div t-if="is_publisher" class="dropdown d-inline-block">
+ <button class="btn py-0" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <i class="fa fa-ellipsis-v"/>
+ </button>
+ <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+ <button class="dropdown-item o_wrating_js_publisher_comment_edit" t-att-data-mes_index="rating.mes_index">
+ <i class="fa fa-fw fa-pencil mr-1"/>Edit
+ </button>
+ <button class="dropdown-item o_wrating_js_publisher_comment_delete" t-att-data-mes_index="rating.mes_index">
+ <i class="fa fa-fw fa-trash-o mr-1"/>Delete
+ </button>
+ </div>
+ </div>
+ <p>Published on <t t-esc="rating.publisher_datetime"/></p>
+ </div>
+ <t t-esc="rating.publisher_comment"/>
+ </div>
+ </div>
+ </t>
+ <t t-name="portal_rating.chatter_rating_publisher_form">
+ <div t-if="is_publisher" class="media o_portal_chatter_message shadow bg-white rounded px-3 py-3 my-1">
+ <img class="o_portal_chatter_avatar" t-att-src="rating.publisher_avatar" alt="avatar"/>
+ <div class="media-body">
+ <div class="o_portal_chatter_message_title">
+ <h5 class='mb-1'><t t-esc="rating.publisher_name"/></h5>
+ <p>Published on <t t-esc="rating.publisher_datetime"/></p>
+ </div>
+ <textarea rows="3" class="form-control o_portal_rating_comment_input"><t t-esc="rating.publisher_comment"/></textarea>
+ <div>
+ <button class="btn btn-primary mt-2 o_wrating_js_publisher_comment_submit" t-att-data-mes_index="rating.mes_index">
+ <t t-if="rating.publisher_comment === ''">
+ Post comment
+ </t><t t-else="">
+ Update comment
+ </t>
+ </button>
+ <button class="border btn btn-light mt-2 bg-white o_wrating_js_publisher_comment_cancel" t-att-data-mes_index="rating.mes_index">
+ Cancel
+ </button>
+ </div>
+ </div>
+ </div>
+ </t>
+</templates>
diff --git a/addons/portal_rating/static/src/xml/portal_rating_composer.xml b/addons/portal_rating/static/src/xml/portal_rating_composer.xml
new file mode 100644
index 00000000..d9d46d99
--- /dev/null
+++ b/addons/portal_rating/static/src/xml/portal_rating_composer.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+ <!--
+ Popup Rating Composer Widget
+ It can alse be used to modify a message
+ -->
+ <t t-name="portal_rating.PopupComposer">
+ <div class="d-flex flex-wrap align-items-center">
+ <div class="text-nowrap">
+ <t t-call="portal_rating.rating_stars_static">
+ <t t-set="val" t-value="widget.rating_avg || 0"/>
+ <t t-set="inline_mode" t-value="true"/>
+ </t>
+ </div>
+ <button t-if="widget.options['display_composer']" type="button"
+ t-att-class="'btn btn-sm mx-3 ' + widget.options['link_btn_classes'] or 'btn-primary'"
+ data-toggle="modal" data-target="#ratingpopupcomposer">
+ <t t-if="widget.options['display_composer']">
+ <t t-if="widget.options['default_message_id']">
+ Modify your review
+ </t>
+ <t t-else="">
+ Add a review
+ </t>
+ </t>
+ </button>
+ </div>
+
+ <div t-if="widget.options['display_composer']" class="modal fade" id="ratingpopupcomposer" tabindex="-1" role="dialog" aria-labelledby="ratingpopupcomposerlabel" aria-hidden="true">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title o_rating_popup_composer_label" id="ratingpopupcomposerlabel">
+ <t t-if="widget.options['default_message_id']">
+ Modify your review
+ </t>
+ <t t-else="">
+ Add a review
+ </t>
+ </h5>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span>×</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <div class="o_portal_chatter_composer"/>
+ </div>
+ </div>
+ </div>
+ </div>
+ </t>
+</templates>
diff --git a/addons/portal_rating/static/src/xml/portal_tools.xml b/addons/portal_rating/static/src/xml/portal_tools.xml
new file mode 100644
index 00000000..9f314360
--- /dev/null
+++ b/addons/portal_rating/static/src/xml/portal_tools.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+ <t t-name="portal_rating.rating_stars_static">
+ <t t-set="val_integer" t-value="Math.floor(val)"/>
+ <t t-set="val_decimal" t-value="val - val_integer"/>
+ <t t-set="empty_star" t-value="5 - (val_integer+Math.ceil(val_decimal))"/>
+ <div class="o_website_rating_static" t-att-style="inline_mode ? 'display:inline' : ''" t-attf-aria-label="#{val} stars on 5" t-attf-title="#{val} stars on 5">
+ <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>
+ </div>
+ </t>
+
+ <t t-name="portal_rating.rating_card">
+ <div class="row o_website_rating_card_container">
+ <div class="col-lg-3 offset-lg-2" t-if="!_.isEmpty(widget.get('rating_card_values'))">
+ <p><strong>Average</strong></p>
+ <div class="o_website_rating_avg text-center">
+ <h1><t t-esc="widget.get('rating_card_values')['avg']"/></h1>
+ <t t-call="portal_rating.rating_stars_static">
+ <t t-set="val" t-value="widget.get('rating_card_values')['avg'] || 0"/>
+ </t>
+ <t t-call="portal.chatter_message_count"/>
+ </div>
+ </div>
+ <div class="col-lg-6" t-if="!_.isEmpty(widget.get('rating_card_values'))">
+ <p><strong>Details</strong></p>
+ <div class="o_website_rating_progress_bars">
+ <table class="o_website_rating_progress_table">
+ <t t-foreach="widget.get('rating_card_values')['percent']" t-as="percent">
+ <tr class="o_website_rating_select" t-att-data-star="percent['num']" style="opacity: 1">
+ <td class="o_website_rating_table_star_num" t-att-data-star="percent['num']">
+ <t t-esc="percent['num']"/> stars
+ </td>
+ <td class="o_website_rating_table_progress">
+ <div class="progress">
+ <div class="progress-bar o_rating_progressbar" role="progressbar" t-att-aria-valuenow="percent['percent']" aria-valuemin="0" aria-valuemax="100" t-att-style="'width:' + percent['percent'] + '%;'">
+ </div>
+ </div>
+ </td>
+ <td class="o_website_rating_table_percent">
+ <strong><t t-esc="Math.round(percent['percent'] * 100) / 100"/>%</strong>
+ </td>
+ <td class="o_website_rating_table_reset">
+ <button class="btn btn-link o_website_rating_select_text" t-att-data-star="percent['num']">
+ <i class="fa fa-times d-block d-sm-none" role="img" aria-label="Remove Selection"/>
+ <span class="d-none d-sm-block">Remove Selection</span>
+ </button>
+ </td>
+ </tr>
+ </t>
+ </table>
+ </div>
+ </div>
+ </div>
+ </t>
+
+ <t t-name="portal_rating.rating_star_input">
+ <div class="o_rating_star_card" t-if="widget.options['display_rating']">
+ <t t-set="val_integer" t-value="Math.floor(default_rating)"/>
+ <t t-set="val_decimal" t-value="default_rating - val_integer"/>
+ <t t-set="empty_star" t-value="5 - (val_integer+Math.ceil(val_decimal))"/>
+
+ <div class="stars enabled">
+ <t t-foreach="_.range(0, val_integer)" t-as="num">
+ <i class="fa fa-star" role="img" aria-label="One star" title="One star"></i>
+ </t>
+ <t t-if="val_decimal">
+ <i class="fa fa-star-half-o" role="img" aria-label="Half a star" title="Half a star"></i>
+ </t>
+ <t t-foreach="_.range(0, empty_star)" t-as="num" role="img" t-attf-aria-label="#{empty_star} on 5" t-attf-title="#{empty_star} on 5">
+ <i class="fa fa-star-o text-black-25"></i>
+ </t>
+ </div>
+ <div class="rate_text">
+ <span class="badge badge-info"></span>
+ </div>
+ <input type="hidden" readonly="readonly" name="rating_value" t-att-value="default_rating || ''"/>
+ </div>
+ </t>
+</templates>