]> git.agnieray.net Git - galette.git/blobdiff - galette/templates/default/elements/js/choose_adh.js.twig
Add pagination button on members search dropdown
[galette.git] / galette / templates / default / elements / js / choose_adh.js.twig
index fa1cd2af9551ca3837b56572318ac3b7e17a32f2..b77d796281a3dd50fac370aa1c459d2db6a8276c 100644 (file)
@@ -4,7 +4,6 @@
     var _adhselect = function() {
         $('{{ js_chosen_id }}').dropdown({
             match: 'text',
-            placeholder: '{{ _T("Search for name or ID and pick member") }}',
             apiSettings: {
                 url: '{{ url_for("contributionMembers", {"page": 1, "search": "{query}"}) }}',
                 method: 'post',
                         modal_classname: "redalert",
                     } %}
                 }
+            },
+            onShow: function() {
+                $('{{ js_chosen_id }} .chevron.circle.right.icon').on('click', function() {
+                    $.ajax({
+                        // TODO : get next page number.
+                        {% set next_page = 2 %}
+                        url: '{{ url_for("contributionMembers", {"page": next_page }) }}',
+                        method: 'post',
+                        {% include "elements/js/loader.js.twig" with {
+                            loader: "action",
+                            loader_text: "",
+                            selector: ".menu.visible"
+                        } %},
+                        success: function(res) {
+                            var _values = Object.values(res)[0];
+                            $('{{ js_chosen_id }}').dropdown('change values', _values);
+                        },
+                        error: function() {
+                            {% include "elements/js/modal.js.twig" with {
+                                modal_title_twig: _T("An error occurred :(")|e("js"),
+                                modal_without_content: true,
+                                modal_class: "mini",
+                                modal_deny_only: true,
+                                modal_cancel_text: _T("Close")|e("js"),
+                                modal_classname: "redalert",
+                            } %}
+                        }
+                    });
+                });
             }
         });
-
-        $('#reset-contributor').on('click', function() {
-            $('{{ js_chosen_id }}').dropdown('restore defaults');
-            $('{{ js_chosen_id }}').dropdown('refresh');
-        });
     }
 
     $(function() {