refactor(badges): standardize reactive search and fix text filtering
- Corrected 'search__event_badge' to use the valid 'default_qry_str' field name, resolving 400 errors during text search. - Re-implemented the standardized debounced search pattern in '+page.svelte' with a robust Search Guard to eliminate loops. - Hardened Fast Path local filtering to match the 'Badge' schema and synchronized result sorting with API revalidation. - Updated 'ae_comp__badge_search.svelte' and 'ae_comp__badge_obj_li.svelte' to align with the shared data pattern and fixed Lucide icon imports. - Ensured 'events_loc' store initialization for new search-related fields.
This commit is contained in:
@@ -328,7 +328,7 @@ export async function update_ae_obj__event_badge({
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updated 2026-01-21 to Restore Full Aether Search Logic
|
// Updated 2026-01-27 to Restore Full Aether Search Logic
|
||||||
export async function search__event_badge({
|
export async function search__event_badge({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_id,
|
event_id,
|
||||||
@@ -380,20 +380,25 @@ export async function search__event_badge({
|
|||||||
|
|
||||||
const params: key_val = {};
|
const params: key_val = {};
|
||||||
|
|
||||||
// Restore Fulltext Logic (Aether Business Logic)
|
// Standardized Text Search Pattern (V3 API)
|
||||||
if (fulltext_search_qry_str || affiliations_qry_str) {
|
// NOTE: Using 'default_qry_str' (Strict DB Column) instead of 'default_qry_string'
|
||||||
params['ft_qry'] = {};
|
if (fulltext_search_qry_str && fulltext_search_qry_str.trim().length > 0) {
|
||||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
const qry = fulltext_search_qry_str.trim();
|
||||||
params['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry}%` });
|
||||||
}
|
params['lk_qry'] = params['lk_qry'] || {};
|
||||||
if (affiliations_qry_str && affiliations_qry_str.length > 2) {
|
params['lk_qry']['default_qry_str'] = qry;
|
||||||
params['ft_qry']['affiliations'] = affiliations_qry_str;
|
}
|
||||||
}
|
|
||||||
|
if (affiliations_qry_str && affiliations_qry_str.trim().length > 0) {
|
||||||
|
const qry = affiliations_qry_str.trim();
|
||||||
|
search_query.and.push({ field: 'affiliations', op: 'like', value: `%${qry}%` });
|
||||||
|
params['lk_qry'] = params['lk_qry'] || {};
|
||||||
|
params['lk_qry']['affiliations'] = qry;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore Like Logic
|
|
||||||
if (like_search_qry_str) {
|
if (like_search_qry_str) {
|
||||||
params['lk_qry'] = { 'default_qry_str': like_search_qry_str };
|
params['lk_qry'] = params['lk_qry'] || {};
|
||||||
|
params['lk_qry']['default_qry_str'] = like_search_qry_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (external_event_id) {
|
if (external_event_id) {
|
||||||
@@ -410,28 +415,36 @@ export async function search__event_badge({
|
|||||||
search_query.and.push({ field: 'print_count', op: 'eq', value: 0 });
|
search_query.and.push({ field: 'print_count', op: 'eq', value: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 1 });
|
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: true });
|
||||||
else if (enabled === 'not_enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 0 });
|
else if (enabled === 'not_enabled') search_query.and.push({ field: 'enable', op: 'eq', value: false });
|
||||||
|
|
||||||
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 1 });
|
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: true });
|
||||||
else if (hidden === 'not_hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 0 });
|
else if (hidden === 'not_hidden') search_query.and.push({ field: 'hide', op: 'eq', value: false });
|
||||||
|
|
||||||
ae_promises.search__event_badge_obj_li = await api
|
ae_promises.search__event_badge_obj_li = await api
|
||||||
.search_ae_obj_v3({
|
.search_ae_obj_v3({
|
||||||
api_cfg,
|
api_cfg: api_cfg,
|
||||||
obj_type: 'event_badge',
|
obj_type: 'event_badge',
|
||||||
search_query,
|
search_query,
|
||||||
params, // Correctly pass the specialized business logic params
|
params,
|
||||||
order_by_li,
|
order_by_li,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
log_lvl
|
log_lvl
|
||||||
})
|
})
|
||||||
.then(async function (badge_obj_li_get_result) {
|
.then(async function (badge_obj_li_get_result) {
|
||||||
if (badge_obj_li_get_result) {
|
// Handle both direct array and {data: []} envelope
|
||||||
|
let result_li: ae_EventBadge[] = [];
|
||||||
|
if (Array.isArray(badge_obj_li_get_result)) {
|
||||||
|
result_li = badge_obj_li_get_result;
|
||||||
|
} else if (badge_obj_li_get_result?.data && Array.isArray(badge_obj_li_get_result.data)) {
|
||||||
|
result_li = badge_obj_li_get_result.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result_li.length > 0) {
|
||||||
if (try_cache) {
|
if (try_cache) {
|
||||||
const processed_obj_li = await process_ae_obj__event_badge_props({
|
const processed_obj_li = await process_ae_obj__event_badge_props({
|
||||||
obj_li: badge_obj_li_get_result,
|
obj_li: result_li,
|
||||||
event_id,
|
event_id,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
@@ -443,7 +456,7 @@ export async function search__event_badge({
|
|||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return badge_obj_li_get_result;
|
return result_li;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ const events_local_data_struct: key_val = {
|
|||||||
fulltext_search_qry_str: null,
|
fulltext_search_qry_str: null,
|
||||||
search_badge_type_code: null,
|
search_badge_type_code: null,
|
||||||
|
|
||||||
|
// New additions for search stabilization (Standardized Pattern 2026-01-27)
|
||||||
|
search_version: 0,
|
||||||
|
qry__remote_first: false,
|
||||||
|
|
||||||
// New additions for filter states
|
// New additions for filter states
|
||||||
qry_printed_status: 'all', // Default to all
|
qry_printed_status: 'all', // Default to all
|
||||||
qry_affiliations: null, // Default to null for no filter
|
qry_affiliations: null, // Default to null for no filter
|
||||||
|
|||||||
Reference in New Issue
Block a user