Fix: Restore Journal Entry text search compatibility
- Backend: Updated `qry__journal_entry` in `ae_journals__journal_entry.ts`.
- Logic: Switched `default_qry_str` operator to `like` (from `match`) for V3 API compatibility.
- Fix: Corrected filter field names from `enabled`/`hidden` to `enable`/`hide`.
- Resilience: Added robust unwrapping of V3 API response envelopes (handling `{ data: [] }` vs array) to prevent iteration errors.
This commit is contained in:
@@ -346,8 +346,8 @@ export async function qry__journal_entry({
|
||||
|
||||
if (qry_str) {
|
||||
console.log('qry_str:', qry_str);
|
||||
// Using 'match' as per previous code's intent
|
||||
search_query.and.push({ field: 'default_qry_str', op: 'match', value: qry_str });
|
||||
// Using 'like' with wildcards to ensure compatibility
|
||||
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry_str.trim()}%` });
|
||||
}
|
||||
|
||||
if (qry_created_on) {
|
||||
@@ -366,15 +366,15 @@ export async function qry__journal_entry({
|
||||
|
||||
// Add enabled/hidden filters
|
||||
if (enabled === 'enabled') {
|
||||
search_query.and.push({ field: 'enabled', op: 'eq', value: true });
|
||||
search_query.and.push({ field: 'enable', op: 'eq', value: true });
|
||||
} else if (enabled === 'not_enabled') {
|
||||
search_query.and.push({ field: 'enabled', op: 'eq', value: false });
|
||||
search_query.and.push({ field: 'enable', op: 'eq', value: false });
|
||||
}
|
||||
|
||||
if (hidden === 'hidden') {
|
||||
search_query.and.push({ field: 'hidden', op: 'eq', value: true });
|
||||
search_query.and.push({ field: 'hide', op: 'eq', value: true });
|
||||
} else if (hidden === 'not_hidden') {
|
||||
search_query.and.push({ field: 'hidden', op: 'eq', value: false });
|
||||
search_query.and.push({ field: 'hide', op: 'eq', value: false });
|
||||
}
|
||||
|
||||
ae_promises.load__journal_entry_obj_li = await api
|
||||
@@ -388,10 +388,22 @@ export async function qry__journal_entry({
|
||||
log_lvl
|
||||
})
|
||||
.then(async function (journal_entry_obj_li_get_result) {
|
||||
if (journal_entry_obj_li_get_result) {
|
||||
// Handle V3 API envelope { data: [], meta: ... } or direct array
|
||||
let valid_result_li: ae_JournalEntry[] = [];
|
||||
if (Array.isArray(journal_entry_obj_li_get_result)) {
|
||||
valid_result_li = journal_entry_obj_li_get_result;
|
||||
} else if (
|
||||
journal_entry_obj_li_get_result &&
|
||||
typeof journal_entry_obj_li_get_result === 'object' &&
|
||||
Array.isArray((journal_entry_obj_li_get_result as any).data)
|
||||
) {
|
||||
valid_result_li = (journal_entry_obj_li_get_result as any).data;
|
||||
}
|
||||
|
||||
if (valid_result_li && valid_result_li.length > 0) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__journal_entry_props({
|
||||
obj_li: journal_entry_obj_li_get_result,
|
||||
obj_li: valid_result_li,
|
||||
journal_id,
|
||||
log_lvl
|
||||
});
|
||||
@@ -403,7 +415,7 @@ export async function qry__journal_entry({
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return journal_entry_obj_li_get_result;
|
||||
return valid_result_li;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user