[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] ObjectSelector js: allow using a beforeSearch handler to modify searched...

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69f31968100e1_3818f8944918@gitlab-sidekiq-low-urgency-cpu-bound-v2-5599fc94bd-7wcc6.mail>

Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
9eb715bc by Victor Emanouilov at 2026-04-30T11:56:57+03:00
[FIX] ObjectSelector js: allow using a beforeSearch handler to modify searched string - useful when users paste various kinds of data in the search form and there should exist some custom logic to reformat the data before searching

- - - - -


1 changed file:

- lib/jquery_tiki/tiki-jquery.js


Changes:

=====================================
lib/jquery_tiki/tiki-jquery.js
=====================================
@@ -2268,11 +2268,13 @@ $(document).tiki('copy')(
                     $(input).data('use-threshold', 0);
                 }
                 if ($filter.val()) {
-                    if (wildcard === 'y') {
-                        filter[searchField] = '*' + $filter.val() + '*';
-                    } else {
-                        filter[searchField] = $filter.val();
-                    }
+                    var ctx = {
+                        value: $filter.val(),
+                        field: searchField,
+                        wildcard: wildcard === 'y'
+                    };
+                    $(input).trigger('beforeSearch.object_selector', [ctx, filter, selectorArgs]);
+                    filter[ctx.field || searchField] = ctx.wildcard ? '*' + ctx.value + '*' : ctx.value;
                 }
                 loadSelectorData(filter, selectorArgs, function (data) {
                     $container._object_selector_update_results('radio', data.resultset.result, false);
@@ -2393,11 +2395,13 @@ $(document).tiki('copy')(
                         filter.multi = {fields: ['object_id', searchField], value: objectIdExactMatch[1]};
                     } else {
                         delete filter.multi;
-                        if (wildcard === 'y') {
-                            filter[searchField] = '*' + $filter.val() + '*';
-                        } else {
-                            filter[searchField] = $filter.val();
-                        }
+                        const ctx = {
+                            value: $filter.val(),
+                            field: searchField,
+                            wildcard: wildcard === 'y'
+                        };
+                        $textarea.trigger('beforeSearch.object_selector', [ctx, filter, selectorArgs]);
+                        filter[ctx.field || searchField] = ctx.wildcard ? '*' + ctx.value + '*' : ctx.value;
                     }
                 }
                 loadSelectorData(filter, selectorArgs, function (data) {



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/9eb715bc835943bfce6119183995097927d176ad
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
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.