[TikiWiki-commits] [Git][tikiwiki/tiki][master] [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 | <6a9067cded972_38fd4044958b9@gitlab-sidekiq-low-urgency-cpu-bound-v2-6ffbbc95d9-5pts4.mail> |
Merci Jacob pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
a0f91306 by Merci Jacob at 2026-08-27T16:20:05+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
- - - - -
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
=====================================
@@ -261,6 +261,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
=====================================
@@ -110,6 +110,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/a0f9130636a94e07136b7321a6f81f4c353aa159
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a0f9130636a94e07136b7321a6f81f4c353aa159
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