[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [FIX] Search module: use wildcard search when enabled - use 'wiki page' for...
"Merci Jacob \(@mercihabam\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a91772aa3f89_371e0235015d4@gitlab-sidekiq-low-urgency-cpu-bound-v2-85746979f6-wwn4v.mail> |
Merci Jacob pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki Commits: dc5369b1 by Merci Jacob at 2026-08-28T11:55:19+00:00 [FIX] Search module: use wildcard search when enabled - use 'wiki page' for default object parent type - search suggestions in the title field rather than 'content' --- * only search against the title field and proper display of highlights * fix unit tests * [FIX] Search module: use wildcard search when enabled and only include wiki pages in autocomplete suggestions by default See merge request tikiwiki/tiki!10871 (cherry picked from commit a0f9130636a94e07136b7321a6f81f4c353aa159) 849ba338 [FIX] Search module: use wildcard search when enabled and only include wiki... 68d41c66 fix unit tests 77c9d57e only search against the title field and proper display of highlights Co-authored-by: Merci Jacob <[email protected]> - - - - - 8 changed files: - lib/setup/javascript.php - modules/mod-func-search.php - src/js/@tiki/modules/search.js - src/js/@tiki/ui-utils/autocomplete.js - src/js/vue-widgets/element-plus-ui/src/components/Autocomplete/Autocomplete.vue - src/js/vue-widgets/element-plus-ui/src/helpers/autocomplete/remote.js - src/js/vue-widgets/element-plus-ui/src/tests/components/Autocomplete.test.js - src/js/vue-widgets/element-plus-ui/src/tests/helpers/autocomplete/remote.test.js Changes: ===================================== lib/setup/javascript.php ===================================== @@ -263,6 +263,7 @@ if (! timezone) { $jqueryTiki['calendar_pdf_export_layout'] = $prefs['calendar_pdf_export_layout']; $jqueryTiki['feature_search_show_object_type'] = $prefs['feature_search_show_object_type'] === 'y'; $jqueryTiki['user_mention_enabled'] = $prefs['feature_tag_users'] === 'y'; + $jqueryTiki['tiki_object_selector_wildcardsearch'] = $prefs['tiki_object_selector_wildcardsearch'] === 'y'; // Check if user has active tasks (Pending or InProgress) to enable smart polling $hasActiveJobs = false; if (($prefs['feature_queued_tasks'] ?? 'n') === 'y') { ===================================== modules/mod-func-search.php ===================================== @@ -279,4 +279,8 @@ function module_search($mod_reference, $smod_params) // modifies $smod_params $smod_params['advanced_search'] = 'n'; } } + + if (! $smod_params['autocomplete_objecttypes']) { + $smod_params['autocomplete_objecttypes'] = module_search_info()['params']['autocomplete_objecttypes']['default']; + } } ===================================== src/js/@tiki/modules/search.js ===================================== @@ -4,7 +4,11 @@ const autocompleteExcludeParentIds = $("#assign_params\\[autocomplete_exclude_pa updateAutocompleteExcludeParentIdsOptions(); autocompleteObjectTypes.on("change", function () { - autocompleteExcludeParentIds.empty(); + if (!$(this).val().length) { + autocompleteExcludeParentIds.empty(); + return; + } + updateAutocompleteExcludeParentIdsOptions(); }); ===================================== src/js/@tiki/ui-utils/autocomplete.js ===================================== @@ -112,12 +112,13 @@ export function getAutocompleteResources(type, options = {}) { }); transformResultCb = (res) => { return res.resultset.result.map((item) => ({ - value: item.title, + value: $("<div/>").append(item.title).text(), // strip HTML tags from value + html: item.title, object_id: item.title, url: $("<div/>").append(item.link).find("a").attr("href"), })); }; - customRemoteQueryKey = "filter~content"; + customRemoteQueryKey = "filter~title"; break; default: remoteSourceUrl = null; ===================================== src/js/vue-widgets/element-plus-ui/src/components/Autocomplete/Autocomplete.vue ===================================== @@ -99,6 +99,10 @@ export const DATA_TEST_ID = { clearable :teleported="false" > + <template #default="{ item }"> + <span v-if="item.html" v-html="item.html"></span> + <span v-else>{{ item[valueKey] }}</span> + </template> </el-autocomplete> </ConfigWrapper> </template> \ No newline at end of file ===================================== src/js/vue-widgets/element-plus-ui/src/helpers/autocomplete/remote.js ===================================== @@ -17,6 +17,10 @@ export function fetchSuggestions(query, callback, sourceRemoteUrl = null, source return; } + if (window.jqueryTiki.tiki_object_selector_wildcardsearch) { + query = "*" + query + "*"; + } + const url = new URL(sourceRemoteUrl); url.searchParams.append(remoteQueryKey, query); fetch(url.href, { ===================================== src/js/vue-widgets/element-plus-ui/src/tests/components/Autocomplete.test.js ===================================== @@ -10,7 +10,7 @@ vi.mock("element-plus", async (importOriginal) => { const actual = await importOriginal(); return { ...actual, - ElAutocomplete: vi.fn((props, { slots }) => h("div", props, slots.default ? slots.default() : null)), + ElAutocomplete: vi.fn((props, { slots }) => h("div", props, slots.default ? slots.default({ item: { value: "Suggestion" } }) : null)), }; }); ===================================== src/js/vue-widgets/element-plus-ui/src/tests/helpers/autocomplete/remote.test.js ===================================== @@ -1,8 +1,12 @@ -import { describe, test, vi, expect, afterEach } from "vitest"; +import { describe, test, vi, expect, afterEach, beforeEach } from "vitest"; import { fetchSuggestions } from "../../../helpers/autocomplete/remote"; describe("Autocomplete remote helper functions", () => { describe("fetchSuggestions", () => { + beforeEach(() => { + window.jqueryTiki = {}; + }); + afterEach(() => { vi.clearAllMocks(); }); View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dc5369b199dbe59e462d17cfd6ffa494378c3411 -- View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dc5369b199dbe59e462d17cfd6ffa494378c3411 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