Updates related to IDAA API functions and related. Some style updates.

This commit is contained in:
Scott Idem
2025-06-23 15:49:53 -04:00
parent 1ad1251931
commit 0b345e325e
8 changed files with 542 additions and 253 deletions

View File

@@ -15,12 +15,14 @@ export async function load_ae_obj_id__archive(
api_cfg, api_cfg,
archive_id, archive_id,
inc_content_li = false, inc_content_li = false,
params = {},
try_cache = true, try_cache = true,
log_lvl = 0 log_lvl = 0
}: { }: {
api_cfg: any, api_cfg: any,
archive_id: string, archive_id: string,
inc_content_li?: boolean, inc_content_li?: boolean,
params?: key_val,
try_cache?: boolean, try_cache?: boolean,
log_lvl?: number log_lvl?: number
} }
@@ -29,14 +31,12 @@ export async function load_ae_obj_id__archive(
console.log(`*** load_ae_obj_id__archive() *** archive_id=${archive_id}`); console.log(`*** load_ae_obj_id__archive() *** archive_id=${archive_id}`);
} }
let params = {};
ae_promises.load__archive_obj = await api.get_ae_obj_id_crud({ ae_promises.load__archive_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'archive', obj_type: 'archive',
obj_id: archive_id, // NOTE: This is the FQDN, not normally the ID. obj_id: archive_id,
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. use_alt_table: true,
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config. use_alt_base: false,
params: params, params: params,
log_lvl: log_lvl log_lvl: log_lvl
}) })
@@ -284,7 +284,7 @@ export async function load_ae_obj_li__archive(
} }
// Updated 2024-09-25 // Updated 2025-06-23
export async function create_ae_obj__archive( export async function create_ae_obj__archive(
{ {
api_cfg, api_cfg,
@@ -306,6 +306,11 @@ export async function create_ae_obj__archive(
console.log(`*** create_ae_obj__archive() *** account_id=${account_id}`); console.log(`*** create_ae_obj__archive() *** account_id=${account_id}`);
} }
if (!account_id) {
console.log(`ERROR: Archives - Archive - account_id required to create`);
return false;
}
ae_promises.create__archive = await api.create_ae_obj_crud({ ae_promises.create__archive = await api.create_ae_obj_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'archive', obj_type: 'archive',
@@ -318,14 +323,37 @@ export async function create_ae_obj__archive(
return_obj: true, return_obj: true,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then(function (archive_obj_create_result) { .then(async function (archive_obj_create_result) {
if (archive_obj_create_result) { if (archive_obj_create_result) {
if (try_cache) { if (try_cache) {
db_save_ae_obj_li__archive( // Process the results first
{ let processed_obj_li = await process_ae_obj__archive_props({
obj_type: 'archive', obj_li: [archive_obj_create_result],
obj_li: [archive_obj_create_result] log_lvl: log_lvl,
}); });
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_archives,
table_name: 'archive',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// db_save_ae_obj_li__archive(
// {
// obj_type: 'archive',
// obj_li: [archive_obj_create_result]
// });
} }
return archive_obj_create_result; return archive_obj_create_result;
} else { } else {
@@ -394,7 +422,7 @@ export async function delete_ae_obj_id__archive(
} }
// Updated 2024-09-25 // Updated 2025-06-23
export async function update_ae_obj__archive( export async function update_ae_obj__archive(
{ {
api_cfg, api_cfg,
@@ -415,7 +443,9 @@ export async function update_ae_obj__archive(
if (log_lvl) { if (log_lvl) {
console.log(`*** update_ae_obj__archive() *** archive_id=${archive_id}`, data_kv); console.log(`*** update_ae_obj__archive() *** archive_id=${archive_id}`, data_kv);
} }
ae_promises.update__archive_obj = await api.update_ae_obj_id_crud({
// Perform the API update
const result = await api.update_ae_obj_id_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'archive', obj_type: 'archive',
obj_id: archive_id, obj_id: archive_id,
@@ -424,29 +454,45 @@ export async function update_ae_obj__archive(
params: params, params: params,
return_obj: true, return_obj: true,
log_lvl: log_lvl log_lvl: log_lvl
})
.then(function (archive_obj_update_result) {
if (archive_obj_update_result) {
if (try_cache) {
db_save_ae_obj_li__archive({
obj_type: 'archive', obj_li: [archive_obj_update_result]
});
}
return archive_obj_update_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
}); });
if (log_lvl) { // Handle the result
console.log('ae_promises.update__archive_obj:', ae_promises.update__archive_obj); if (result) {
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__archive_props({
obj_li: [result],
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_archives,
table_name: 'archive',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// await db_save_ae_obj_li__archive({
// obj_type: 'archive',
// obj_li: [result],
// log_lvl: log_lvl,
// });
}
return result;
} else {
console.error('Failed to update archive.');
return null;
} }
return ae_promises.update__archive_obj;
} }

View File

@@ -191,7 +191,7 @@ export async function load_ae_obj_li__archive_content(
} }
// Updated 2024-09-25 // Updated 2025-06-23
export async function create_ae_obj__archive_content( export async function create_ae_obj__archive_content(
{ {
api_cfg, api_cfg,
@@ -213,6 +213,11 @@ export async function create_ae_obj__archive_content(
console.log(`*** create_ae_obj__archive_content() *** archive_id=${archive_id}`); console.log(`*** create_ae_obj__archive_content() *** archive_id=${archive_id}`);
} }
if (!archive_id) {
console.log(`ERROR: Archives - Content - archive_id required to create`);
return false;
}
ae_promises.create__archive_content = await api.create_ae_obj_crud({ ae_promises.create__archive_content = await api.create_ae_obj_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'archive_content', obj_type: 'archive_content',
@@ -228,11 +233,34 @@ export async function create_ae_obj__archive_content(
.then(async function (archive_content_obj_create_result) { .then(async function (archive_content_obj_create_result) {
if (archive_content_obj_create_result) { if (archive_content_obj_create_result) {
if (try_cache) { if (try_cache) {
await db_save_ae_obj_li__archive_content( // Process the results first
{ let processed_obj_li = await process_ae_obj__archive_content_props({
obj_type: 'archive_content', obj_li: [archive_content_obj_create_result],
obj_li: [archive_content_obj_create_result] log_lvl: log_lvl,
}); });
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_archives,
table_name: 'archive_content',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// await db_save_ae_obj_li__archive_content(
// {
// obj_type: 'archive_content',
// obj_li: [archive_content_obj_create_result]
// });
} }
return archive_content_obj_create_result; return archive_content_obj_create_result;
} else { } else {
@@ -301,7 +329,7 @@ export async function delete_ae_obj_id__archive_content(
} }
// Updated 2024-09-25 // Updated 2025-06-23
export async function update_ae_obj__archive_content( export async function update_ae_obj__archive_content(
{ {
api_cfg, api_cfg,
@@ -322,7 +350,9 @@ export async function update_ae_obj__archive_content(
if (log_lvl) { if (log_lvl) {
console.log(`*** update_ae_obj__archive_content() *** archive_content_id=${archive_content_id}`, data_kv); console.log(`*** update_ae_obj__archive_content() *** archive_content_id=${archive_content_id}`, data_kv);
} }
ae_promises.update__archive_content_obj = await api.update_ae_obj_id_crud({
// Perform the API update
const result = await api.update_ae_obj_id_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'archive_content', obj_type: 'archive_content',
obj_id: archive_content_id, obj_id: archive_content_id,
@@ -330,30 +360,46 @@ export async function update_ae_obj__archive_content(
key: api_cfg.api_crud_super_key, key: api_cfg.api_crud_super_key,
params: params, params: params,
return_obj: true, return_obj: true,
log_lvl: log_lvl log_lvl: log_lvl,
})
.then(async function (archive_content_obj_update_result) {
if (archive_content_obj_update_result) {
if (try_cache) {
await db_save_ae_obj_li__archive_content({
obj_type: 'archive_content', obj_li: [archive_content_obj_update_result]
});
}
return archive_content_obj_update_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
}); });
if (log_lvl) { // Handle the result
console.log('ae_promises.update__archive_content_obj:', ae_promises.update__archive_content_obj); if (result) {
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__archive_content_props({
obj_li: [result],
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_archives,
table_name: 'archive_content',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// await db_save_ae_obj_li__archive_content({
// obj_type: 'archive_content',
// obj_li: [result],
// log_lvl: log_lvl,
// });
}
return result;
} else {
console.error('Failed to update archive content.');
return null;
} }
return ae_promises.update__archive_content_obj;
} }

View File

@@ -611,6 +611,7 @@ export async function create_ae_obj__event(
if (log_lvl) { if (log_lvl) {
console.log('DB save completed.'); console.log('DB save completed.');
} }
// db_save_ae_obj_li__event( // db_save_ae_obj_li__event(
// { // {
// obj_type: 'event', // obj_type: 'event',

View File

@@ -584,15 +584,15 @@ export async function update_ae_obj__journal_entry(
properties_to_save: properties_to_save, properties_to_save: properties_to_save,
log_lvl: log_lvl, log_lvl: log_lvl,
}); });
if (log_lvl) {
console.log('DB save completed.');
}
// await db_save_ae_obj_li__journal_entry({ // await db_save_ae_obj_li__journal_entry({
// obj_type: 'journal_entry', // obj_type: 'journal_entry',
// obj_li: [result], // obj_li: [result],
// log_lvl: log_lvl, // log_lvl: log_lvl,
// }); // });
if (log_lvl) {
console.log('DB save completed.');
}
} }
return result; return result;
} else { } else {

View File

@@ -10,7 +10,7 @@ import { load_ae_obj_li__post_comment } from "$lib/ae_posts/ae_posts__post_comme
let ae_promises: key_val = {}; let ae_promises: key_val = {};
// Updated 2024-09-25 // Updated 2025-06-23
export async function load_ae_obj_id__post( export async function load_ae_obj_id__post(
{ {
api_cfg, api_cfg,
@@ -20,6 +20,7 @@ export async function load_ae_obj_id__post(
limit = 99, limit = 99,
offset = 0, offset = 0,
inc_comment_li = false, inc_comment_li = false,
params = {},
try_cache = true, try_cache = true,
log_lvl = 0 log_lvl = 0
}: { }: {
@@ -30,6 +31,7 @@ export async function load_ae_obj_id__post(
limit?: number, limit?: number,
offset?: number, offset?: number,
inc_comment_li?: boolean, inc_comment_li?: boolean,
params?: key_val,
try_cache?: boolean, try_cache?: boolean,
log_lvl?: number log_lvl?: number
} }
@@ -38,8 +40,6 @@ export async function load_ae_obj_id__post(
console.log(`*** load_ae_obj_id__post() *** post_id=${post_id}`); console.log(`*** load_ae_obj_id__post() *** post_id=${post_id}`);
} }
let params = {};
ae_promises.load__post_obj = await api.get_ae_obj_id_crud({ ae_promises.load__post_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'post', obj_type: 'post',
@@ -49,15 +49,38 @@ export async function load_ae_obj_id__post(
params: params, params: params,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then(function (post_obj_get_result) { .then(async function (post_obj_get_result) {
if (post_obj_get_result) { if (post_obj_get_result) {
if (try_cache) { if (try_cache) {
// This is expecting a list // Process the results first
db_save_ae_obj_li__post({ let processed_obj_li = await process_ae_obj__post_props({
obj_type: 'post',
obj_li: [post_obj_get_result], obj_li: [post_obj_get_result],
log_lvl: log_lvl log_lvl: log_lvl,
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
}); });
if (log_lvl) {
console.log('DB save completed.');
}
// // This is expecting a list
// db_save_ae_obj_li__post({
// obj_type: 'post',
// obj_li: [post_obj_get_result],
// log_lvl: log_lvl
// });
} }
return post_obj_get_result; return post_obj_get_result;
} else { } else {
@@ -73,7 +96,7 @@ export async function load_ae_obj_id__post(
console.log('ae_promises.load__post_obj:', ae_promises.load__post_obj); console.log('ae_promises.load__post_obj:', ae_promises.load__post_obj);
} }
if (inc_comment_li && ae_promises.load__post_obj) { if (inc_comment_li) {
// Load the comments for the post // Load the comments for the post
if (log_lvl) { if (log_lvl) {
console.log(`Need to load the comment list for the post now`); console.log(`Need to load the comment list for the post now`);
@@ -82,9 +105,9 @@ export async function load_ae_obj_id__post(
api_cfg: api_cfg, api_cfg: api_cfg,
for_obj_type: 'post', for_obj_type: 'post',
for_obj_id: post_id, for_obj_id: post_id,
enabled: enabled, enabled: enabled, // all, disabled, enabled
hidden: hidden, hidden: hidden, // all, hidden, not_hidden
limit: limit, limit: limit, // Limit for the comments
offset: offset, offset: offset,
params: {qry__enabled: 'all', qry__limit: 25}, params: {qry__enabled: 'all', qry__limit: 25},
try_cache: try_cache, try_cache: try_cache,
@@ -107,7 +130,7 @@ export async function load_ae_obj_id__post(
} }
// Updated 2024-11-20 // Updated 2025-06-23
export async function load_ae_obj_li__post( export async function load_ae_obj_li__post(
{ {
api_cfg, api_cfg,
@@ -143,7 +166,9 @@ export async function load_ae_obj_li__post(
let params_json: key_val = {}; let params_json: key_val = {};
// console.log('params_json:', params_json); if (log_lvl) {
console.log('params_json:', params_json);
}
ae_promises.load__post_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({ ae_promises.load__post_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg, api_cfg: api_cfg,
@@ -162,14 +187,37 @@ export async function load_ae_obj_li__post(
params: params, params: params,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then(function (post_obj_li_get_result) { .then(async function (post_obj_li_get_result) {
if (post_obj_li_get_result) { if (post_obj_li_get_result) {
if (try_cache) { if (try_cache) {
db_save_ae_obj_li__post({ // Process the results first
obj_type: 'post', let processed_obj_li = await process_ae_obj__post_props({
obj_li: post_obj_li_get_result, obj_li: post_obj_li_get_result,
log_lvl: log_lvl log_lvl: log_lvl,
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
}); });
if (log_lvl) {
console.log('DB save completed.');
}
// db_save_ae_obj_li__post({
// obj_type: 'post',
// obj_li: post_obj_li_get_result,
// log_lvl: log_lvl
// });
} }
return post_obj_li_get_result; return post_obj_li_get_result;
} else { } else {
@@ -223,7 +271,7 @@ export async function load_ae_obj_li__post(
} }
// Updated 2024-09-25 // Updated 2025-06-23
export async function create_ae_obj__post( export async function create_ae_obj__post(
{ {
api_cfg, api_cfg,
@@ -245,6 +293,11 @@ export async function create_ae_obj__post(
console.log(`*** create_ae_obj__post() *** account_id=${account_id}`); console.log(`*** create_ae_obj__post() *** account_id=${account_id}`);
} }
if (!account_id) {
console.log(`ERROR: Posts - Post - account_id required to create`);
return false;
}
ae_promises.create__post = await api.create_ae_obj_crud({ ae_promises.create__post = await api.create_ae_obj_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'post', obj_type: 'post',
@@ -257,15 +310,38 @@ export async function create_ae_obj__post(
return_obj: true, return_obj: true,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then(function (post_obj_create_result) { .then(async function (post_obj_create_result) {
if (post_obj_create_result) { if (post_obj_create_result) {
if (try_cache) { if (try_cache) {
db_save_ae_obj_li__post( // Process the results first
{ let processed_obj_li = await process_ae_obj__post_props({
obj_type: 'post', obj_li: [post_obj_create_result],
obj_li: [post_obj_create_result], log_lvl: log_lvl,
log_lvl: log_lvl
}); });
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// db_save_ae_obj_li__post(
// {
// obj_type: 'post',
// obj_li: [post_obj_create_result],
// log_lvl: log_lvl
// });
} }
return post_obj_create_result; return post_obj_create_result;
} else { } else {
@@ -336,7 +412,7 @@ export async function delete_ae_obj_id__post(
} }
// Updated 2024-09-25 // Updated 2025-06-23
export async function update_ae_obj__post( export async function update_ae_obj__post(
{ {
api_cfg, api_cfg,
@@ -357,7 +433,9 @@ export async function update_ae_obj__post(
if (log_lvl) { if (log_lvl) {
console.log(`*** update_ae_obj__post() *** post_id=${post_id}`, data_kv); console.log(`*** update_ae_obj__post() *** post_id=${post_id}`, data_kv);
} }
ae_promises.update__post_obj = await api.update_ae_obj_id_crud({
// Perform the API update
const result = await api.update_ae_obj_id_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'post', obj_type: 'post',
obj_id: post_id, obj_id: post_id,
@@ -365,32 +443,46 @@ export async function update_ae_obj__post(
key: api_cfg.api_crud_super_key, key: api_cfg.api_crud_super_key,
params: params, params: params,
return_obj: true, return_obj: true,
log_lvl: log_lvl log_lvl: log_lvl,
})
.then(function (post_obj_update_result) {
if (post_obj_update_result) {
if (try_cache) {
db_save_ae_obj_li__post({
obj_type: 'post',
obj_li: [post_obj_update_result],
log_lvl: log_lvl
});
}
return post_obj_update_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
}); });
if (log_lvl) { // Handle the result
console.log('ae_promises.update__post_obj:', ae_promises.update__post_obj); if (result) {
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__post_props({
obj_li: [result],
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// await db_save_ae_obj_li__post({
// obj_type: 'post',
// obj_li: [result],
// log_lvl: log_lvl,
// });
}
return result;
} else {
console.error('Failed to update post.');
return null;
} }
return ae_promises.update__post_obj;
} }

View File

@@ -8,7 +8,7 @@ import { db_posts } from "$lib/ae_posts/db_posts";
let ae_promises: key_val = {}; let ae_promises: key_val = {};
// Updated 2024-09-25 // Updated 2025-06-23
export async function load_ae_obj_id__post_comment( export async function load_ae_obj_id__post_comment(
{ {
api_cfg, api_cfg,
@@ -17,6 +17,7 @@ export async function load_ae_obj_id__post_comment(
hidden = 'not_hidden', hidden = 'not_hidden',
limit = 99, limit = 99,
offset = 0, offset = 0,
params = {},
try_cache = true, try_cache = true,
log_lvl = 0 log_lvl = 0
}: { }: {
@@ -26,6 +27,7 @@ export async function load_ae_obj_id__post_comment(
hidden?: string, hidden?: string,
limit?: number, limit?: number,
offset?: number, offset?: number,
params?: key_val,
try_cache?: boolean, try_cache?: boolean,
log_lvl?: number log_lvl?: number
} }
@@ -34,8 +36,6 @@ export async function load_ae_obj_id__post_comment(
console.log(`*** load_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`); console.log(`*** load_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
} }
let params = {};
ae_promises.load__post_comment_obj = await api.get_ae_obj_id_crud({ ae_promises.load__post_comment_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'post_comment', obj_type: 'post_comment',
@@ -45,16 +45,39 @@ export async function load_ae_obj_id__post_comment(
params: params, params: params,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then(function (post_comment_obj_get_result) { .then(async function (post_comment_obj_get_result) {
if (post_comment_obj_get_result) { if (post_comment_obj_get_result) {
if (try_cache) { if (try_cache) {
// This is expecting a list // Process the results first
db_save_ae_obj_li__post_comment({ let processed_obj_li = await process_ae_obj__post_comment_props({
obj_type: 'post_comment',
obj_li: [post_comment_obj_get_result], obj_li: [post_comment_obj_get_result],
log_lvl: log_lvl log_lvl: log_lvl,
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post_comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
}); });
if (log_lvl) {
console.log('DB save completed.');
}
// // This is expecting a list
// db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: [post_comment_obj_get_result],
// log_lvl: log_lvl
// });
} }
return post_comment_obj_get_result; return post_comment_obj_get_result;
} else { } else {
@@ -70,7 +93,7 @@ export async function load_ae_obj_id__post_comment(
} }
// Updated 2024-11-20 // Updated 2025-06-23
export async function load_ae_obj_li__post_comment( export async function load_ae_obj_li__post_comment(
{ {
api_cfg, api_cfg,
@@ -102,14 +125,11 @@ export async function load_ae_obj_li__post_comment(
console.log(`*** load_ae_obj_li__post_comment() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`); console.log(`*** load_ae_obj_li__post_comment() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
} }
// if (params.qry__enabled) { enabled = params.qry__enabled; }
// if (params.qry__hidden) { hidden = params.qry__hidden; }
// if (params.qry__limit) { limit = params.qry__limit; }
// if (params.qry__offset) { offset = params.qry__offset; }
let params_json: key_val = {}; let params_json: key_val = {};
// console('params_json:', params_json); if (log_lvl) {
console.log('params_json:', params_json);
}
ae_promises.load__post_comment_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({ ae_promises.load__post_comment_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg, api_cfg: api_cfg,
@@ -128,14 +148,37 @@ export async function load_ae_obj_li__post_comment(
params: params, params: params,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then(function (post_comment_obj_li_get_result) { .then(async function (post_comment_obj_li_get_result) {
if (post_comment_obj_li_get_result) { if (post_comment_obj_li_get_result) {
if (try_cache) { if (try_cache) {
db_save_ae_obj_li__post_comment({ // Process the results first
obj_type: 'post_comment', let processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: post_comment_obj_li_get_result, obj_li: post_comment_obj_li_get_result,
log_lvl: log_lvl log_lvl: log_lvl,
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post_comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
}); });
if (log_lvl) {
console.log('DB save completed.');
}
// db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: post_comment_obj_li_get_result,
// log_lvl: log_lvl
// });
} }
return post_comment_obj_li_get_result; return post_comment_obj_li_get_result;
} else { } else {
@@ -154,7 +197,7 @@ export async function load_ae_obj_li__post_comment(
} }
// Updated 2024-09-25 // Updated 2025-06-23
export async function create_ae_obj__post_comment( export async function create_ae_obj__post_comment(
{ {
api_cfg, api_cfg,
@@ -176,6 +219,11 @@ export async function create_ae_obj__post_comment(
console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`); console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`);
} }
if (!post_id) {
console.log(`ERROR: Posts - Comment - post_id required to create`);
return false;
}
ae_promises.create__post_comment = await api.create_ae_obj_crud({ ae_promises.create__post_comment = await api.create_ae_obj_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'post_comment', obj_type: 'post_comment',
@@ -188,15 +236,38 @@ export async function create_ae_obj__post_comment(
return_obj: true, return_obj: true,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then(function (post_comment_obj_create_result) { .then(async function (post_comment_obj_create_result) {
if (post_comment_obj_create_result) { if (post_comment_obj_create_result) {
if (try_cache) { if (try_cache) {
db_save_ae_obj_li__post_comment( // Process the results first
{ let processed_obj_li = await process_ae_obj__post_comment_props({
obj_type: 'post_comment', obj_li: [post_comment_obj_create_result],
obj_li: [post_comment_obj_create_result], log_lvl: log_lvl,
log_lvl: log_lvl
}); });
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post_comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// db_save_ae_obj_li__post_comment(
// {
// obj_type: 'post_comment',
// obj_li: [post_comment_obj_create_result],
// log_lvl: log_lvl
// });
} }
return post_comment_obj_create_result; return post_comment_obj_create_result;
} else { } else {
@@ -267,7 +338,7 @@ export async function delete_ae_obj_id__post_comment(
} }
// Updated 2024-09-25 // Updated 2025-06-23
export async function update_ae_obj__post_comment( export async function update_ae_obj__post_comment(
{ {
api_cfg, api_cfg,
@@ -288,7 +359,9 @@ export async function update_ae_obj__post_comment(
if (log_lvl) { if (log_lvl) {
console.log(`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`, data_kv); console.log(`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`, data_kv);
} }
ae_promises.update__post_comment_obj = await api.update_ae_obj_id_crud({
// Perform the API update
const result = await api.update_ae_obj_id_crud({
api_cfg: api_cfg, api_cfg: api_cfg,
obj_type: 'post_comment', obj_type: 'post_comment',
obj_id: post_comment_id, obj_id: post_comment_id,
@@ -296,32 +369,46 @@ export async function update_ae_obj__post_comment(
key: api_cfg.api_crud_super_key, key: api_cfg.api_crud_super_key,
params: params, params: params,
return_obj: true, return_obj: true,
log_lvl: log_lvl log_lvl: log_lvl,
})
.then(function (post_comment_obj_update_result) {
if (post_comment_obj_update_result) {
if (try_cache) {
db_save_ae_obj_li__post_comment({
obj_type: 'post_comment',
obj_li: [post_comment_obj_update_result],
log_lvl: log_lvl
});
}
return post_comment_obj_update_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
}); });
if (log_lvl) { // Handle the result
console.log('ae_promises.update__post_comment_obj:', ae_promises.update__post_comment_obj); if (result) {
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: [result],
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post_comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// await db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: [result],
// log_lvl: log_lvl,
// });
}
return result;
} else {
console.error('Failed to update post comment.');
return null;
} }
return ae_promises.update__post_comment_obj;
} }

View File

@@ -282,7 +282,6 @@ function add_activity_log(
<!-- Modal: Post (Bulletin Board) view ID --> <!-- Modal: Post (Bulletin Board) view ID -->
<!-- title="{$lq__post_obj?.title ?? 'New Post'} - {$lq__post_obj?.id ?? 'Not Saved Yet'}" --> <!-- title="{$lq__post_obj?.title ?? 'New Post'} - {$lq__post_obj?.id ?? 'Not Saved Yet'}" -->
<Modal <Modal
bind:open={$idaa_sess.bb.show__modal_view__post_id} bind:open={$idaa_sess.bb.show__modal_view__post_id}
autoclose={false} autoclose={false}
outsideclose={true} outsideclose={true}

View File

@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
/** @type {import('./$types').PageData} */ import { run } from 'svelte/legacy';
export let data: any;
let log_lvl: number = 0; let log_lvl: number = $state(0);
// console.log(`ae_events_pres_mgmt event [event_id] +page.svelte data:`, data); // console.log(`ae_events_pres_mgmt event [event_id] +page.svelte data:`, data);
import { browser } from '$app/environment'; import { browser } from '$app/environment';
@@ -25,20 +25,26 @@ import Comp__event_obj_qry from './ae_idaa_comp__event_obj_qry.svelte';
import Comp__event_obj_li from './ae_idaa_comp__event_obj_li.svelte'; import Comp__event_obj_li from './ae_idaa_comp__event_obj_li.svelte';
import Comp__event_obj_id_edit from './ae_idaa_comp__event_obj_id_edit.svelte'; import Comp__event_obj_id_edit from './ae_idaa_comp__event_obj_id_edit.svelte';
import Comp__event_obj_id_view from './ae_idaa_comp__event_obj_id_view.svelte'; import Comp__event_obj_id_view from './ae_idaa_comp__event_obj_id_view.svelte';
interface Props {
/** @type {import('./$types').PageData} */
data: any;
}
let event_id_random_li: Array<string>; let { data }: Props = $props();
let event_id_random_li: Array<string> = $state();
// Functions and Logic // Functions and Logic
$: lq__event_obj = liveQuery(async () => { let lq__event_obj = $derived(liveQuery(async () => {
let results = await db_events.events let results = await db_events.events
.get($idaa_slct.event_id); .get($idaa_slct.event_id ?? '');
return results; return results;
}); }));
$: lq_new__event_obj_li = liveQuery(async () => { let lq_new__event_obj_li = $derived(liveQuery(async () => {
let link_to_type: string = 'account'; let link_to_type: string = 'account';
let link_to_id: string = $slct.account_id; let link_to_id: string = $slct.account_id;
if (log_lvl > 1) { if (log_lvl > 1) {
@@ -90,43 +96,46 @@ $: lq_new__event_obj_li = liveQuery(async () => {
} }
return null; return null;
} }
}); }));
// This (event_li trigger for IDAA) is not currently being used. // This (event_li trigger for IDAA) is not currently being used.
// Updated 2024-11-19 // Updated 2024-11-19
$: if ($idaa_trig.event_li) { run(() => {
$idaa_trig.event_li = false; if ($idaa_trig.event_li) {
$idaa_trig.event_li = false;
if (log_lvl) { if (log_lvl) {
console.log(`Triggered: $idaa_trig.event_li`); console.log(`Triggered: $idaa_trig.event_li`);
}
if ($idaa_loc.recovery_meetings.qry__enabled !== 'all' || $idaa_loc.recovery_meetings.qry__hidden !== 'all') {
console.log(`Deleting disabled or hidden event.`);
let results = db_events.events
.clear();
console.log(`Deleted ${results} disabled event.`);
}
$idaa_prom.load__event_obj_li = events_func.load_ae_obj_li__event({
api_cfg: $ae_api,
for_obj_type: 'account',
for_obj_id: $idaa_slct.account_id,
qry_conference: false,
enabled: $idaa_loc.recovery_meetings.qry__enabled,
hidden: $idaa_loc.recovery_meetings.qry__hidden,
limit: $idaa_loc.recovery_meetings.qry__limit,
order_by_li: $idaa_loc.recovery_meetings.qry__order_by_li,
try_cache: true,
log_lvl: log_lvl,
});
} }
if ($idaa_loc.recovery_meetings.qry__enabled !== 'all' || $idaa_loc.recovery_meetings.qry__hidden !== 'all') {
console.log(`Deleting disabled or hidden event.`);
let results = db_events.events
.clear();
console.log(`Deleted ${results} disabled event.`);
}
$idaa_prom.load__event_obj_li = events_func.load_ae_obj_li__event({
api_cfg: $ae_api,
for_obj_type: 'account',
for_obj_id: $idaa_slct.account_id,
qry_conference: false,
enabled: $idaa_loc.recovery_meetings.qry__enabled,
hidden: $idaa_loc.recovery_meetings.qry__hidden,
limit: $idaa_loc.recovery_meetings.qry__limit,
order_by_li: $idaa_loc.recovery_meetings.qry__order_by_li,
try_cache: true,
log_lvl: log_lvl,
}); });
}
// Updated 2024-11-19 // Updated 2024-11-19
$: if ($idaa_trig.event_li_qry) { run(() => {
if ($idaa_trig.event_li_qry) {
$idaa_trig.event_li_qry = false; $idaa_trig.event_li_qry = false;
if (log_lvl) { if (log_lvl) {
@@ -258,8 +267,8 @@ $: if ($idaa_trig.event_li_qry) {
clearInterval(request_loop); clearInterval(request_loop);
} }
}, search_delay); }, search_delay);
} }
});
if (browser) { if (browser) {
@@ -373,7 +382,7 @@ function add_activity_log(
/> />
{#if $lq_new__event_obj_li && $lq_new__event_obj_li?.length } {#if $lq_new__event_obj_li && $lq_new__event_obj_li?.length}
<Comp__event_obj_li <Comp__event_obj_li
lq__event_obj_li={lq_new__event_obj_li} lq__event_obj_li={lq_new__event_obj_li}
/> />
@@ -386,8 +395,8 @@ function add_activity_log(
<!-- Modal: Event (Recovery Meeting) edit ID --> <!-- Modal: Event (Recovery Meeting) edit ID -->
<!-- title="{$lq__event_obj?.name} - {$lq__event_obj?.id}" -->
<Modal <Modal
title="{$lq__event_obj?.name} - {$lq__event_obj?.id}"
bind:open={$idaa_sess.recovery_meetings.show__modal_edit} bind:open={$idaa_sess.recovery_meetings.show__modal_edit}
autoclose={false} autoclose={false}
placement="top-center" placement="top-center"
@@ -395,27 +404,27 @@ function add_activity_log(
class="top-center bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y" class="top-center bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y"
> >
<svelte:fragment slot="header"> {#snippet header()}
<div class="flex flex-row items-center justify-between w-full"> <div class="flex flex-row items-center justify-between w-full">
<h3 class="text-lg font-semibold"> <h3 class="text-lg font-semibold">
{#if $ae_loc.trusted_access || $lq__event_obj?.external_person_id === $idaa_loc.novi_uuid || $lq__event_obj?.contact_li_json[0]?.email === $idaa_loc.novi_email} {#if $ae_loc.trusted_access || $lq__event_obj?.external_person_id === $idaa_loc.novi_uuid || $lq__event_obj?.contact_li_json[0]?.email === $idaa_loc.novi_email}
<!-- <div class="ae_options"> --> <!-- <div class="ae_options"> -->
<button <button
on:click={() => { onclick={() => {
// const url = new URL(location); // const url = new URL(location);
// url.searchParams.set('event_id', $lq__event_obj?.event_id_random); // url.searchParams.set('event_id', $lq__event_obj?.event_id_random);
// history.pushState({}, '', url); // history.pushState({}, '', url);
$idaa_sess.recovery_meetings.show__modal_edit = false; $idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = true; $idaa_sess.recovery_meetings.show__modal_view = true;
add_activity_log( add_activity_log(
{ {
action: 'idaa_meetings_page', action: 'idaa_meetings_page',
action_with: 'cancel_edit', action_with: 'cancel_edit',
} }
); );
}} }}
class="novi_btn btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition" class="novi_btn btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition"
title={`View meeting: ${$lq__event_obj?.name}`} title={`View meeting: ${$lq__event_obj?.name}`}
> >
@@ -428,72 +437,69 @@ function add_activity_log(
{$lq__event_obj?.name ?? 'New Recovery Meeting'} {$lq__event_obj?.name ?? 'New Recovery Meeting'}
</h3> </h3>
</div> </div>
{/snippet}
</svelte:fragment>
<Comp__event_obj_id_edit <Comp__event_obj_id_edit
lq__event_obj={lq__event_obj} lq__event_obj={lq__event_obj}
/> />
{#snippet footer()}
<svelte:fragment slot="footer">
<div class="text-center w-full"> <div class="text-center w-full">
<button <button
type="button" type="button"
on:click={() => { onclick={() => {
console.log('Close modal'); console.log('Close modal');
$idaa_sess.recovery_meetings.show__modal_edit = false; $idaa_sess.recovery_meetings.show__modal_edit = false;
add_activity_log( add_activity_log(
{ {
action: 'idaa_meetings_page', action: 'idaa_meetings_page',
action_with: 'close_modal', action_with: 'close_modal',
} }
); );
}} }}
class="novi_btn btn btn-sm preset-tonal-warning hover:preset-tonal-warning border border-warning-500" class="novi_btn btn btn-sm preset-tonal-warning hover:preset-tonal-warning border border-warning-500"
> >
<span class="fas fa-times mx-1"></span> <span class="fas fa-times mx-1"></span>
Close Close
</button> </button>
</div> </div>
</svelte:fragment> {/snippet}
</Modal> </Modal>
<!-- Modal: Event (Recovery Meeting) view ID --> <!-- Modal: Event (Recovery Meeting) view ID -->
<!-- title="{$lq__event_obj?.name} - {$lq__event_obj?.id}" -->
<Modal <Modal
title="{$lq__event_obj?.name} - {$lq__event_obj?.id}"
bind:open={$idaa_sess.recovery_meetings.show__modal_view} bind:open={$idaa_sess.recovery_meetings.show__modal_view}
autoclose={false} autoclose={false}
outsideclose={true} outsideclose={true}
placement="top-center" placement="top-center"
size="lg" size="lg"
class="bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y" class="top-center bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y"
> >
<svelte:fragment slot="header"> {#snippet header()}
<div class="flex flex-row items-center justify-between w-full"> <div class="flex flex-row items-center justify-between w-full">
<h3 class="text-lg font-semibold text-center"> <h3 class="text-lg font-semibold text-center">
{#if $ae_loc.trusted_access || $lq__event_obj?.external_person_id === $idaa_loc.novi_uuid || $lq__event_obj?.contact_li_json[0].email === $idaa_loc.novi_email} {#if $ae_loc.trusted_access || $lq__event_obj?.external_person_id === $idaa_loc.novi_uuid || $lq__event_obj?.contact_li_json[0].email === $idaa_loc.novi_email}
<button <button
on:click={() => { onclick={() => {
// const url = new URL(location); // const url = new URL(location);
// url.searchParams.set('event_id', $lq__event_obj?.event_id_random); // url.searchParams.set('event_id', $lq__event_obj?.event_id_random);
// history.pushState({}, '', url); // history.pushState({}, '', url);
$idaa_sess.recovery_meetings.show__modal_view = false; $idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_edit = true; $idaa_sess.recovery_meetings.show__modal_edit = true;
add_activity_log( add_activity_log(
{ {
action: 'idaa_meetings_page', action: 'idaa_meetings_page',
action_with: 'edit', action_with: 'edit',
} }
); );
}} }}
class="novi_btn btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition" class="novi_btn btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition"
title={`Edit meeting: ${$lq__event_obj?.name}`} title={`Edit meeting: ${$lq__event_obj?.name}`}
> >
@@ -501,7 +507,7 @@ function add_activity_log(
</button> </button>
{/if} {/if}
<span class="fas fa-calendar-day m-1"></span> <span class="fas fa-calendar-day m-1"></span>
{$lq__event_obj?.name ?? '-- not set'} {$lq__event_obj?.name ?? '-- not set --'}
</h3> </h3>
{#if $lq__event_obj?.status == 'unknown'} {#if $lq__event_obj?.status == 'unknown'}
<span class="badge badge-warning preset-tonal-error" title="This meeting has not been confirmed by IDAA Central Office. Please reach out to the chair for current meeting list info. Meeting attendees can reach out to info@idaa.org if they know this is information is accurate and this meeting is still taking place."> <span class="badge badge-warning preset-tonal-error" title="This meeting has not been confirmed by IDAA Central Office. Please reach out to the chair for current meeting list info. Meeting attendees can reach out to info@idaa.org if they know this is information is accurate and this meeting is still taking place.">
@@ -512,7 +518,19 @@ function add_activity_log(
</span> </span>
{/if} {/if}
</div> </div>
</svelte:fragment>
<button
type="button"
class="btn btn-sm btn-secondary absolute top-2 right-2"
onclick={() => {
$idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_edit = false;
}}
>
<span class="fas fa-times"></span>
Close
</button>
{/snippet}
<Comp__event_obj_id_view <Comp__event_obj_id_view
lq__event_obj={lq__event_obj} lq__event_obj={lq__event_obj}