diff sat_templates/templates/bulma/chat/message.html @ 385:941e4006ab6e

bulma (message): reactions + fixes: - add "reaction" button - fix attachments display - add reaction templates - add reactions to messages - fix "info" messages display
author Goffi <goffi@goffi.org>
date Wed, 22 Nov 2023 15:22:11 +0100
parents a5a80d761e3e
children e63fb06052ae
line wrap: on
line diff
--- a/sat_templates/templates/bulma/chat/message.html	Wed Nov 22 15:22:10 2023 +0100
+++ b/sat_templates/templates/bulma/chat/message.html	Wed Nov 22 15:22:11 2023 +0100
@@ -1,7 +1,7 @@
 {% import 'components/avatar.html' as avatar with context %}
 
 <div id="{{msg.id}}" class="media is-chat-message msg_{{msg.type}} {{'own_msg' if msg.from_ == own_jid}}" style="padding: 0.5em;" role="listitem" aria-label="Chat Message">
-    {%- if msg.type != C.MESS_TYPE_INFO %}
+    {%- if msg.type != "info" %}
         {%- set author = identities[msg.from_].nicknames[0] | default(msg.from_) -%}
         <figure class="media-left pt-1">
             {{ avatar.avatar(msg.from_, "is-32x32") }}
@@ -9,7 +9,7 @@
     {% endif -%}
     <div class="media-content is-relative">
         <div class="content">
-            {%- if msg.type != C.MESS_TYPE_INFO %}
+            {%- if msg.type != "info" %}
                 <nav class="level is-mobile is-marginless is-size-7">
                     <div class="level-left has-text-weight-bold">
                         <div class="level-item">
@@ -36,7 +36,7 @@
                     </div>
                 </nav>
             {% endif -%}
-            <p class="msg_body has-whitespace-pre-wrap" id="msg_body_{{msg.id}}" style="margin: 0;">
+            <p class="msg_body has-whitespace-pre-wrap {{ "has-text-info" if msg.type=="info" }}" id="msg_body_{{msg.id}}" style="margin: 0;">
             {{- msg.html or (msg.text|e|urlize|safe) -}}
             </p>
 
@@ -45,26 +45,41 @@
             </div>
 
             <div id="actions_{{msg.id}}" class="level is-mobile actions mb-0">
-                <div class="level-right">
-                    {#{{ icon('share', cls='icon is-small action-button', id='msg_share_{{msg.id}}') }} #}
-                    {{ icon('dot-3', cls='icon is-small action-button', id='msg_actions_{{msg.id}}') }}
-                </div>
+                {#{{ icon('share', cls='icon is-small action-button', id='msg_share_{{msg.id}}') }} #}
+                {{ icon('smile', cls='icon is-small action-button reaction-button', id='msg_actions_{{msg.id}}') }}
+                {{ icon('dot-3', cls='icon is-small action-button extra-button', id='msg_actions_{{msg.id}}') }}
             </div>
             <div id="msg_reactions_{{msg.id}}" style="margin-top: 0.5em;">
-                <!-- Reactions will go here -->
+                {% if msg.extra.reactions is defined %}
+                    {% set reactions = msg.extra.get("reactions") %}
+                    {% include 'chat/reactions.html' %}
+                {% endif %}
             </div>
         {% if msg.attachments %}
             <div class="message-attachments pt-2">
                 {%- for attachment in msg.attachments %}
                     <figure class="image message-attachment">
-                        {%- if attachment.media_type|media_type_main == 'image' %}
-                            <img src="{{attachment.sources[0].url}}" alt="{{attachment.name}}">
-                        {%- else %}
-                            {{ icon('doc', cls='icon') }}
-                        {%- endif %}
-                        <figcaption class="has-text-centered is-size-7">
-                            <a href="{{attachment.sources[0].url if attachment.sources}}" target="_blank" class="has-text-grey">{{attachment.name}}</a>
-                        </figcaption>
+                        {%- if not attachment.url -%}
+                            <div class="notification is-warning">
+                                <div class="is-size-6 has-text-weight-semibold mb-1">
+                                    {% trans name=attachment.name %}Attachment: {{name}}{% endtrans %}
+                                </div>
+
+                                <div class="is-size-7 mb-1">
+                                    {% trans %}Cannot be opened as there are no sources available.{% endtrans %}
+                                </div>
+
+                            </div>
+                        {%- else -%}
+                            {%- if attachment.media_type|media_type_main == 'image' %}
+                                <img src="{{attachment.url}}" alt="{{attachment.name}}">
+                            {%- else %}
+                                {{ icon('doc', cls='icon') }}
+                            {%- endif %}
+                            <figcaption class="has-text-centered is-size-7">
+                                <a href="{{attachment.url}}" target="_blank" class="has-text-grey">{{attachment.name}}</a>
+                            </figcaption>
+                        {%- endif -%}
                     </figure>
                 {%- endfor %}
             </div>