]> git.agnieray.net Git - galette.git/commitdiff
Add and use member dropdown form component
authorJohan Cwiklinski <johan@x-tnd.be>
Tue, 16 Apr 2024 20:30:38 +0000 (22:30 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Tue, 16 Apr 2024 20:30:38 +0000 (22:30 +0200)
galette/templates/default/components/forms/member_dropdown.html.twig [new file with mode: 0644]
galette/templates/default/pages/contribution_form.html.twig
galette/templates/default/pages/member_form.html.twig
galette/templates/default/pages/transaction_form.html.twig

diff --git a/galette/templates/default/components/forms/member_dropdown.html.twig b/galette/templates/default/components/forms/member_dropdown.html.twig
new file mode 100644 (file)
index 0000000..a188621
--- /dev/null
@@ -0,0 +1,40 @@
+{#
+/**
+ * Copyright © 2003-2024 The Galette Team
+ *
+ * This file is part of Galette (https://galette.eu).
+ *
+ * Galette is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Galette is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Galette. If not, see <http://www.gnu.org/licenses/>.
+ */
+#}
+{% extends "components/forms/select.html.twig" %}
+
+{% block element %}
+    <div id="{{ id }}" class="jsonly search-dropdown ui input paginated">
+        <input id="{{ id }}_input" type="hidden" name="{{ id }}" value="{% if value is not same as null %}{{ value }}{% endif %}" placeholder="{{ _T("Member ID") }}">
+        <i class="jsonly displaynone dropdown icon"></i>
+        <span class="ui mini compact icon disabled button prev-results">
+            <i class="jsonly displaynone chevron circle left icon disabled button tooltip" title="{{ _T("Load previous members...") }}"></i>
+        </span>
+        <span class="ui mini compact icon disabled button next-results">
+            <i class="jsonly displaynone chevron circle right icon disabled button tooltip" title="{{ _T("Load following members...") }}"></i>
+        </span>
+        <div class="jsonly displaynone default text">{{ _T("Search for name or ID and pick member") }}</div>
+        <div class="jsonly displaynone menu">
+    {% for k, v in members.list %}
+            <div class="item" data-value="{{ k }}">{{ v }}</div>
+    {% endfor %}
+        </div>
+    </div>
+{% endblock %}
\ No newline at end of file
index 4ed2a59a499b8f36fd10e50409e316d00c34c6f8..401743c5c01922c69a73708349f2672ef8b24837 100644 (file)
                     <div class="ui mobile reversed stackable grid">
                         <div class="{% if contribution.isTransactionPart() or contribution.hasSchedule() %}six wide {% endif %}column">
     {% if not require_mass %}
-                            <div class="inline field">
-                                <label for="id_adh">{{ _T("Contributor:") }}</label>
-                                <div id="id_adh" class="jsonly search-dropdown ui input paginated">
-                                    <input id="id_adh_input" type="hidden" name="id_adh" value="{{ contribution.member is not null ? contribution.member }}" placeholder="{{ _T("Member ID") }}">
-                                    <i class="jsonly displaynone dropdown icon" aria-hidden="true"></i>
-                                    <span class="ui mini compact icon disabled button prev-results"><i class="jsonly displaynone chevron circle left icon disabled button tooltip" title="{{ _T("Load previous members...") }}" aria-hidden="true"></i></span>
-                                    <span class="ui mini compact icon disabled button next-results"><i class="jsonly displaynone chevron circle right icon disabled button tooltip" title="{{ _T("Load following members...") }}" aria-hidden="true"></i></span>
-                                    <div class="jsonly displaynone default text">{{ _T("Search for name or ID and pick member") }}</div>
-                                    <div class="jsonly displaynone menu">
-                            {% for k, v in members.list %}
-                                        <div class="item" data-value="{{ k }}">{{ v }}</div>
-                            {% endfor %}
-                                    </div>
-                                </div>
-                            </div>
+                            {% include 'components/forms/member_dropdown.html.twig' with {
+                                'required': true,
+                                'label': _T("Contributor:"),
+                                'id': 'id_adh',
+                                'value': contribution.member,
+                                'component_class': 'inline field'
+                            } %}
     {% endif %}
                             <div class="inline field{% if required.id_type_cotis is defined and required.id_type_cotis == 1 %} required{% endif %}">
                                 <label for="id_type_cotis">{{ _T("Contribution type:") }}</label>
index 4d6a91073123924365322bcc7615bf4793021636..0b0e69a7281b08d8e5255d2eadda71cda0eaf9cb 100644 (file)
                             </div>
                         </div>
                         <span id="parent_id_elt" class="">
-                            <div id="parent_id" class="jsonly search-dropdown ui input paginated">
-                                <input id="parent_id_input" type="text" name="parent_id" value="{{ member.isDuplicate() and member.parent is defined and member.parent is not null ? member.parent.id }}" placeholder="{{ _T("Member ID") }}">
-                                <i class="jsonly displaynone dropdown icon" aria-hidden="true"></i>
-                                <span class="ui mini compact icon disabled button prev-results"><i class="jsonly displaynone chevron circle left icon disabled button tooltip" title="{{ _T("Load previous members...") }}" aria-hidden="true"></i></span>
-                                <span class="ui mini compact icon disabled button next-results"><i class="jsonly displaynone chevron circle right icon disabled button tooltip" title="{{ _T("Load following members...") }}" aria-hidden="true"></i></span>
-                                <div class="jsonly displaynone default text">{{ _T("Search for name or ID and pick member") }}</div>
-                                <div class="jsonly displaynone menu">
-            {% for k, v in members.list %}
-                                    <div class="item" data-value="{{ k }}">{{ v }}</div>
-            {% endfor %}
-                                </div>
-                            </div>
+                            {% include 'components/forms/member_dropdown.html.twig' with {
+                                'component_id': 'parent_id_elt',
+                                'id': 'parent_id',
+                                'label': _T("Parent member"),
+                                'value': member.isDuplicate() and member.parent is defined and member.parent is not null ? member.parent.id,
+                                'notag': true
+                            } %}
                         </span>
             {% if member.isDuplicate() %}
                         <input type="hidden" name="duplicate" value="1" />
index efbccf83570fea71ef4d798c437303f27ebe76ea..bc244251384b6946e31b0ec13e7328e0bf7e9c53 100644 (file)
                             <label for="trans_desc">{{ _T("Description:") }}</label>
                             <input type="text" name="trans_desc" id="trans_desc" value="{{ transaction.description }}" maxlength="150" size="30"{% if required.trans_desc is defined and required.trans_desc == 1 %} required="required"{% endif %}/>
                         </div>
-                        <div class="field inline{% if required.id_adh is defined and required.id_adh == 1 %} required{% endif %}">
-                            <label for="id_adh" >{{ _T("Originator:") }}</label>
-                            <div id="id_adh" class="jsonly search-dropdown ui input paginated"{% if required.id_adh is defined and required.id_adh == 1 %} required="required"{% endif %}>
-                                <input id="id_adh_input" type="text" name="id_adh" value="{{ transaction.member is not null ? transaction.member }}" placeholder="{{ _T("Member ID") }}">
-                                <i class="jsonly displaynone dropdown icon" aria-hidden="true"></i>
-                                <span class="ui mini compact icon disabled button prev-results"><i class="jsonly displaynone chevron circle left icon disabled button tooltip" title="{{ _T("Load previous members...") }}" aria-hidden="true"></i></span>
-                                <span class="ui mini compact icon disabled button next-results"><i class="jsonly displaynone chevron circle right icon disabled button tooltip" title="{{ _T("Load following members...") }}" aria-hidden="true"></i></span>
-                                <div class="jsonly displaynone default text">{% if not transaction.member %}{{ _T("Search for name or ID and pick member") }}{% endif %}</div>
-                                <div class="jsonly displaynone menu">
-    {% for k, v in members.list %}
-                                    <div class="item" data-value="{{ k }}">{{ v }}</div>
-    {% endfor %}
-                                </div>
-                            </div>
-                        </div>
+                        {% include 'components/forms/member_dropdown.html.twig' with {
+                            'required': required.id_adh is defined and required.id_adh == 1,
+                            'id': 'id_adh',
+                            'label': _T("Originator:"),
+                            'value': transaction.member,
+                            'component_class': 'inline field'
+                        } %}
                         <div class="field inline{% if required.trans_date is defined and required.trans_date == 1 %} required{% endif %}">
                             <label for="trans_date">{{ _T("Date:") }}</label>
                             <div class="ui calendar" id="transaction-rangestart">