diff sat_templates/templates/bulma/components/block.html @ 325:8c779fb46384

bulma (components/block): interests_grid is more customisable: - new `delete_icon` argument can be set to `false` if delete icon is not desired - the macro can now be called, the caller then get 2 arguments: part to customise and current interest. Part to customise can be: * `header-title`: markup to put in the title * `content`: car content (replaces the default `interest.name`)
author Goffi <goffi@goffi.org>
date Sat, 01 May 2021 18:44:47 +0200
parents 2a697b1376f1
children dc83f45625b3
line wrap: on
line diff
--- a/sat_templates/templates/bulma/components/block.html	Sat May 01 18:41:11 2021 +0200
+++ b/sat_templates/templates/bulma/components/block.html	Sat May 01 18:44:47 2021 +0200
@@ -46,18 +46,29 @@
     </div>
 {% endmacro %}
 
-{% macro interests_grid(interests, default_icon_name) %}
+{% macro interests_grid(interests, default_icon_name, delete_icon=true) %}
 {# display list of interests
+
+    Can be called, in which call caller is called with 2 arguments:
+        - part: par to fill, can be "header-title" or "content"
+        - interest: current interest
     @param interests: list of interests
     @param default_icon_name: name of a defined icon to use when no thumb_url is available
+    @param delete_icon: unset to remove the icon
 #}
 <div class="columns is-multiline">
     {% for interest in interests %}
         <div class="column is-4 item" data-item='{{interest|tojson}}'>
             <div class="card">
                 <div class="card-header">
-                    <div class="card-header-title"></div>
-                    <div class="card-header-icon"><button class="delete action_delete"></button></div>
+                    <div class="card-header-title">
+                        {% if caller is defined %}
+                            {{ caller("header-title", interest) }}
+                        {% endif %}
+                    </div>
+                    {% if delete_icon %}
+                        <div class="card-header-icon"><button class="delete action_delete"></button></div>
+                    {% endif %}
                 </div>
                 <div class="card-image is-photo-thumbnail-container is-flex has-items-centered has-background-light">
                     <a href="{{interest.url}}">
@@ -71,9 +82,13 @@
                     </a>
                 </div>
                 <div class="card-content has-text-centered x-is-hoverable">
-                    <a href="{{interest.url}}">
-                        <span><em>{{ interest.name|default(_("unnamed")) }}</em></span>
-                    </a>
+                    {% if caller is defined %}
+                            {{ caller("content", interest) }}
+                    {% else %}
+                        <a href="{{interest.url}}">
+                            <span><em>{{ interest.name|default(_("unnamed")) }}</em></span>
+                        </a>
+                    {% endif %}
                 </div>
             </div>
         </div>