[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] listexecute: alternate output with filters

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69706abf53512_2c1824dc53837@gitlab-sidekiq-low-urgency-cpu-bound-v2-85d5545cc7-xjg9c.mail>

Victor Emanouilov pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
d03db165 by Victor Emanouilov at 2026-01-21T07:57:13+02:00
[FIX] listexecute: alternate output with filters
---
* [FIX] listexecute: alternate output with filters made the ajax reload drop the filters - make sure we add listexecute top form to alternate output, so JS events can bind correctly and reload only the results upon submission

See merge request tikiwiki/tiki!9384

- - - - -


3 changed files:

- lib/core/Search/Formatter.php
- lib/jquery_tiki/wikiplugin-listexecute.js
- lib/wiki-plugins/wikiplugin_listexecute.php


Changes:

=====================================
lib/core/Search/Formatter.php
=====================================
@@ -30,6 +30,11 @@ class Search_Formatter
         $this->alternateOutput = $output;
     }
 
+    public function getAlternateOutput()
+    {
+        return $this->alternateOutput;
+    }
+
     public function setContext(?string $context)
     {
         $this->context = $context;


=====================================
lib/jquery_tiki/wikiplugin-listexecute.js
=====================================
@@ -1,6 +1,6 @@
 $.fn.setupListExecute = function (id) {
     const $container = this;
-    const iListExecute = $container.attr('id').replace('wplistexecute-', '');
+    const iListExecute = $container.attr('id').replace('wplistexecute-', '').replace('listexecute-', '');
 
     let countChecked = function() {
         if ($container.find('.checkbox_objects').is(':checked')) {
@@ -124,6 +124,12 @@ $.fn.setupListExecute = function (id) {
         return false;
     });
 
+    $(`#list_filter${iListExecute} form`).off('submit').on("submit", function(e){
+        e.preventDefault();
+        $container.trigger('submit');
+        return false;
+    });
+
     $(`#listexecute-download-${iListExecute}, #listexecute-download-top-${iListExecute}`).on("submit", function(){
         var $form = $(this);
         $form.find('input[name^=filter]').remove();


=====================================
lib/wiki-plugins/wikiplugin_listexecute.php
=====================================
@@ -306,15 +306,18 @@ function wikiplugin_listexecute($data, $params, $offset, $parser)
         }
     }
 
-    $formatted = $formatter->format($result);
-
-    if (! str_contains($formatted, "listexecute-$iListExecute")) {
-        $formatted = '~np~
+    $alternateOutput = $formatter->getAlternateOutput();
+    if (! strstr($alternateOutput, "listexecute-$iListExecute")) {
+        // no results found or custom alternatate code supplied, thus missing list execute main form, add it artificially as JS code bind to it
+        $alternateOutput = '~np~
 <form method="post" class="list-executable" id="listexecute-' . $iListExecute . '" data-id="wplistexecute-' . $iListExecute . '">
-    <input type="hidden" name="plugin" value="' . $fingerprint . '">~/np~' . $formatted . '~np~
+    <input type="hidden" name="plugin" value="' . $fingerprint . '">~/np~' . $alternateOutput . '~np~
 </form>~/np~';
+        $formatter->setAlternateOutput($alternateOutput);
     }
 
+    $formatted = $formatter->format($result);
+
     $mark_plugins = $parser->option['mark_plugins'];
     if (empty($mark_plugins && ! empty(TikiLib::lib('parser')->core_options['mark_plugins']))) {
         $mark_plugins = TikiLib::lib('parser')->core_options['mark_plugins'];



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/d03db165492d94a1893f01b19cb0c7682eb3946e

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/d03db165492d94a1893f01b19cb0c7682eb3946e
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.