]> git.agnieray.net Git - galette.git/commitdiff
Extend list template to render group of cards
authorGuillaume AGNIERAY <dev@agnieray.net>
Sun, 1 Oct 2023 18:52:53 +0000 (20:52 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Thu, 5 Oct 2023 04:50:20 +0000 (06:50 +0200)
galette/templates/default/elements/list.html.twig
galette/templates/default/pages/members_public_gallery.html.twig

index cf3a3078b76548ebfc363acf91d119350febf4c1..49fc111abb318536f0009d3ff20adcb463ab91d9 100644 (file)
             {% endif %}
         </form>
     {% endblock %}
-    <form action="{%  if form.route is defined %}{{ url_for(form.route.name, form.route.args|default([])) }}{% endif %}" method="post" id="listform" class="ui form">
-        <div class="ui basic fitted segment">
+    {% if form is defined %}
+        <form action="{%  if form.route is defined %}{{ url_for(form.route.name, form.route.args|default([])) }}{% endif %}" method="post" id="listform" class="ui form">
+            <div class="ui basic fitted segment">
 
-        {% if mode != 'ajax' and batch_actions is defined and batch_actions|length > 0 %}
-            {{ macros.drawBatchActionsList(batch_actions) }}
-        {% endif %}
+            {% if mode != 'ajax' and batch_actions is defined and batch_actions|length > 0 %}
+                {{ macros.drawBatchActionsList(batch_actions) }}
+            {% endif %}
+    {% endif %}
 
-            <div class="ui basic fitted segment loader_selector">
-                <table class="listing ui celled{% if basic_table is not defined %} striped{% endif %} table">
-                    <thead>
-                        <tr>
-                    {% block header %}
-                        {% for column in columns %}
-                            <th class="left">
-                                {% if column.order is defined %}
-                                <a href="{{ url_for(form.order.name, form.order.args|default([])|merge({"option": "order", "value": column.order})) }}">
-                                    {{ column.label }}
-                                    {% if filters.orderby == column.order %}
-                                        {% if filters.ordered == constant('Galette\\Core\\Pagination::ORDER_ASC') %}
-                                            <i class="ui angle down icon tooltip"></i>
-                                        {% else %}
-                                            <i class="ui angle up icon tooltip"></i>
+    {% if list_type is defined and list_type == 'cards' %}
+                <div class="{% if nb %}ui doubling {% if cards_columns is defined %}{{ cards_columns }}{% else %}six{% endif %} column cards loader_selector{% endif %}">
+    {% else %}
+                <div class="ui basic fitted segment loader_selector">
+                    <table class="listing ui celled{% if basic_table is not defined %} striped{% endif %} table">
+                        <thead>
+                            <tr>
+                        {% block header %}
+                            {% for column in columns %}
+                                <th class="left">
+                                    {% if form is defined and column.order is defined %}
+                                    <a href="{{ url_for(form.order.name, form.order.args|default([])|merge({"option": "order", "value": column.order})) }}">
+                                        {{ column.label }}
+                                        {% if filters.orderby == column.order %}
+                                            {% if filters.ordered == constant('Galette\\Core\\Pagination::ORDER_ASC') %}
+                                                <i class="ui angle down icon tooltip"></i>
+                                            {% else %}
+                                                <i class="ui angle up icon tooltip"></i>
+                                            {% endif %}
                                         {% endif %}
+                                    </a>
+                                    {% else %}
+                                        {{ column.label }}
                                     {% endif %}
-                                </a>
-                                {% else %}
-                                    {{ column.label }}
-                                {% endif %}
-                            </th>
-                        {% endfor %}
-                        {% if mode != 'ajax' and no_action is not defined or no_action == false %}
-                            <th class="actions_row">{{ _T('Actions') }}</th>
-                        {% endif %}
-                    {% endblock %}
-                        </tr>
-                    </thead>
-                    <tbody>
-                        {% block body %}{% endblock %}
-                    </tbody>
-                    <tfoot>
-                        {% block footer %}{% endblock %}
-                    </tfoot>
-                </table>
-            </div>
+                                </th>
+                            {% endfor %}
+                            {% if mode != 'ajax' and no_action is not defined or no_action == false %}
+                                <th class="actions_row">{{ _T('Actions') }}</th>
+                            {% endif %}
+                        {% endblock %}
+                            </tr>
+                        </thead>
+                        <tbody>
+    {% endif %}
+                            {% block body %}{% endblock %}
+    {% if list_type is not defined %}
+                        </tbody>
+                        <tfoot>
+                            {% block footer %}{% endblock %}
+                        </tfoot>
+                    </table>
+    {% endif %}
 
-        {% if mode != 'ajax' and batch_actions is defined and batch_actions|length > 0 %}
-            {{ macros.drawBatchActionsList(batch_actions) }}
-        {% endif %}
+            {% if form is defined and mode != 'ajax' and batch_actions is defined and batch_actions|length > 0 %}
+                {{ macros.drawBatchActionsList(batch_actions) }}
+            {% endif %}
 
-        </div>
+            </div>
 
-        {% if is_paginated %}
-        <div class="ui basic center aligned fitted segment">
-            <div class="ui inverted pagination menu">
-                <div class="header item">
-                    {{ _T('Pages:') }}
+            {% if is_paginated %}
+            <div class="ui basic center aligned fitted segment">
+                <div class="ui inverted pagination menu">
+                    <div class="header item">
+                        {{ _T('Pages:') }}
+                    </div>
+                    {{ pagination|raw }}
                 </div>
-                {{ pagination|raw }}
             </div>
-        </div>
-        {% endif %}
+            {% endif %}
 
-        {% block extra_form %}{% endblock %}
-        {% include "components/forms/csrf.html.twig" %}
-    </form>
+    {% if form is defined %}
+            {% block extra_form %}{% endblock %}
+            {% include "components/forms/csrf.html.twig" %}
+        </form>
+    {% endif %}
         {% block legend %}{% endblock %}
     {% if mode == 'ajax' %}
     </div>
index bd1ce93c74fb72a4eb6454ca61278aee844b0559..1c9bd44afc0b1ebfdf0a26745be120c87622d6d7 100644 (file)
@@ -1,66 +1,53 @@
-{% extends 'public_page.html.twig' %}
+{% extends 'elements/list.html.twig' %}
 
-{% block content %}
-        <div class="ui icon info visible message">
-            <i class="info circle blue icon"></i>
-            <div class="content">
-                {{ _T("This page shows only members who have choosen to be visible on the public lists and are up-to-date within their contributions. If you want your account to be visible here, edit your profile and check 'Be visible in the members list'") }}
-            </div>
+{% set nb = members|length %}
+{% set is_public = not login.isLogged() %}
+{% set list_type = 'cards' %}
+
+{% block infoline %}
+    {% set infoline = {
+        'label': _Tn("%count member", "%count members", nb_members)|replace({'%count': nb_members}),
+        'route': {
+            'name': 'filterPublicList',
+            'args': {
+                "type": "trombi"
+            }
+        }
+    } %}
+    {{ parent() }}
+{% endblock %}
+
+{% block search %}
+    <div class="ui icon info visible message">
+        <i class="info circle blue icon"></i>
+        <div class="content">
+            {{ _T("This page shows only members who have choosen to be visible on the public lists and are up-to-date within their contributions. If you want your account to be visible here, edit your profile and check 'Be visible in the members list'") }}
         </div>
-{% if members|length > 0 %}
-        <form action="{{ url_for("filterPublicList", {"type": "trombi"}) }}" method="POST" class="ui form">
-            <div class="infoline">
-                <div class="ui basic horizontal segments">
-                    <div class="ui basic fitted segment">
-                        <div class="ui label">{{ _Tn("%count member", "%count members", nb_members)|replace({'%count': nb_members}) }}</div>
-                    </div>
-                    <div class="ui basic right aligned fitted segment">
-                        <div class="inline field">
-                            <label for="nbshow">{{ _T('Records per page:') }}</label>
-                            <select name="nbshow" id="nbshow" class="ui dropdown nochosen">
-                                {% for key, value in nbshow_options %}
-                                    <option value="{{ key }}"{% if key == numrows %} selected="selected"{% endif %}>{{ value }}</option>
-                                {% endfor %}
-                            </select>
-                            <noscript> <span><input type="submit" value="{{ _T('Change') }}" /></span></noscript>
-                            {% include "components/forms/csrf.html.twig" %}
-                        </div>
-                    </div>
-                </div>
-            </div>
-        </form>
-        <div class="ui doubling six column cards">
+    </div>
+{% endblock %}
+
+{% block body %}
     {% for member in members %}
-            <div class="ui fluid card">
-                {% set mid = member.id %}
-                <div class="image">
-                    <img
-                        src="{{ url_for("photo", {"id": member.id, "rand": time}) }}"
-                        width="{{ member.picture.getOptimalWidth() }}"
-                        height="{{ member.picture.getOptimalHeight() }}"
-                        alt="{{ member.sfullname }}{% if member.nickname != '' %} ({{ member.nickname|escape }}){% endif %}"
-                        />
-                </div>
-                <div class="content">
-                    <div class="header">{{ member.sfullname }}</div>
-                    {% if member.nickname != '' %}<div class="meta">{{ member.nickname|escape }}</div>{% endif %}
-                </div>
+        <div class="ui fluid card">
+            {% set mid = member.id %}
+            <div class="image">
+                <img
+                    src="{{ url_for("photo", {"id": member.id, "rand": time}) }}"
+                    width="{{ member.picture.getOptimalWidth() }}"
+                    height="{{ member.picture.getOptimalHeight() }}"
+                    alt="{{ member.sfullname }}{% if member.nickname != '' %} ({{ member.nickname|escape }}){% endif %}"
+                    />
             </div>
-    {% endfor %}
-        </div>
-        <div class="ui basic center aligned fitted segment">
-            <div class="ui inverted pagination menu">
-                <div class="header item">
-                    {{ _T('Pages:') }}
-                </div>
-                {{ pagination|raw }}
+            <div class="content">
+                <div class="header">{{ member.sfullname }}</div>
+                {% if member.nickname != '' %}<div class="meta">{{ member.nickname|escape }}</div>{% endif %}
             </div>
         </div>
-{% else %}
-    <div class="ui small message">
-        <div class="content">
-            <em>{{ _T('No member to show') }}</em>
+    {% else %}
+        <div class="ui small message">
+            <div class="content">
+                <em>{{ _T('No member to show') }}</em>
+            </div>
         </div>
-    </div>
-{% endif %}
+    {% endfor %}
 {% endblock %}