[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [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 <69f3199337956_382a552b05188@gitlab-sidekiq-low-urgency-cpu-bound-v2-5599fc94bd-znvg4.mail>

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


Commits:
bd49439c by Victor Emanouilov at 2026-04-30T11:57:43+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
=====================================
@@ -2911,11 +2911,13 @@ $.fn.tiki = function(func, type, options, excludepage) {
                     $(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);
@@ -3033,11 +3035,13 @@ $.fn.tiki = function(func, type, options, excludepage) {
                     $textarea.data('use-threshold', 0);
                 }
                 if ($filter.val()) {
-                    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) {
                     $container._object_selector_update_results('checkbox', data.resultset.result, false);



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/bd49439c2bc6558e51bdc85f3e82c7650e142975
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.