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,
archive_id,
inc_content_li = false,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
archive_id: string,
inc_content_li?: boolean,
params?: key_val,
try_cache?: boolean,
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}`);
}
let params = {};
ae_promises.load__archive_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'archive',
obj_id: archive_id, // NOTE: This is the FQDN, not normally the 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_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
obj_id: archive_id,
use_alt_table: true,
use_alt_base: false,
params: params,
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(
{
api_cfg,
@@ -306,6 +306,11 @@ export async function create_ae_obj__archive(
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({
api_cfg: api_cfg,
obj_type: 'archive',
@@ -318,14 +323,37 @@ export async function create_ae_obj__archive(
return_obj: true,
log_lvl: log_lvl
})
.then(function (archive_obj_create_result) {
.then(async function (archive_obj_create_result) {
if (archive_obj_create_result) {
if (try_cache) {
db_save_ae_obj_li__archive(
{
obj_type: 'archive',
obj_li: [archive_obj_create_result]
// Process the results first
let processed_obj_li = await process_ae_obj__archive_props({
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;
} 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(
{
api_cfg,
@@ -415,7 +443,9 @@ export async function update_ae_obj__archive(
if (log_lvl) {
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,
obj_type: 'archive',
obj_id: archive_id,
@@ -424,29 +454,45 @@ export async function update_ae_obj__archive(
params: params,
return_obj: true,
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) {
console.log('ae_promises.update__archive_obj:', ae_promises.update__archive_obj);
// Handle the result
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(
{
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}`);
}
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({
api_cfg: api_cfg,
obj_type: 'archive_content',
@@ -228,11 +233,34 @@ export async function create_ae_obj__archive_content(
.then(async function (archive_content_obj_create_result) {
if (archive_content_obj_create_result) {
if (try_cache) {
await db_save_ae_obj_li__archive_content(
{
obj_type: 'archive_content',
obj_li: [archive_content_obj_create_result]
// Process the results first
let processed_obj_li = await process_ae_obj__archive_content_props({
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;
} 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(
{
api_cfg,
@@ -322,7 +350,9 @@ export async function update_ae_obj__archive_content(
if (log_lvl) {
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,
obj_type: 'archive_content',
obj_id: archive_content_id,
@@ -330,30 +360,46 @@ export async function update_ae_obj__archive_content(
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
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 () {
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('ae_promises.update__archive_content_obj:', ae_promises.update__archive_content_obj);
// Handle the result
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) {
console.log('DB save completed.');
}
// db_save_ae_obj_li__event(
// {
// obj_type: 'event',

View File

@@ -584,15 +584,15 @@ export async function update_ae_obj__journal_entry(
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
// await db_save_ae_obj_li__journal_entry({
// obj_type: 'journal_entry',
// obj_li: [result],
// log_lvl: log_lvl,
// });
if (log_lvl) {
console.log('DB save completed.');
}
}
return result;
} 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 = {};
// Updated 2024-09-25
// Updated 2025-06-23
export async function load_ae_obj_id__post(
{
api_cfg,
@@ -20,6 +20,7 @@ export async function load_ae_obj_id__post(
limit = 99,
offset = 0,
inc_comment_li = false,
params = {},
try_cache = true,
log_lvl = 0
}: {
@@ -30,6 +31,7 @@ export async function load_ae_obj_id__post(
limit?: number,
offset?: number,
inc_comment_li?: boolean,
params?: key_val,
try_cache?: boolean,
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}`);
}
let params = {};
ae_promises.load__post_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post',
@@ -49,15 +49,38 @@ export async function load_ae_obj_id__post(
params: params,
log_lvl: log_lvl
})
.then(function (post_obj_get_result) {
.then(async function (post_obj_get_result) {
if (post_obj_get_result) {
if (try_cache) {
// This is expecting a list
db_save_ae_obj_li__post({
obj_type: 'post',
// Process the results first
let processed_obj_li = await process_ae_obj__post_props({
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;
} 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);
}
if (inc_comment_li && ae_promises.load__post_obj) {
if (inc_comment_li) {
// Load the comments for the post
if (log_lvl) {
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,
for_obj_type: 'post',
for_obj_id: post_id,
enabled: enabled,
hidden: hidden,
limit: limit,
enabled: enabled, // all, disabled, enabled
hidden: hidden, // all, hidden, not_hidden
limit: limit, // Limit for the comments
offset: offset,
params: {qry__enabled: 'all', qry__limit: 25},
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(
{
api_cfg,
@@ -143,7 +166,9 @@ export async function load_ae_obj_li__post(
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({
api_cfg: api_cfg,
@@ -162,14 +187,37 @@ export async function load_ae_obj_li__post(
params: params,
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 (try_cache) {
db_save_ae_obj_li__post({
obj_type: 'post',
// Process the results first
let processed_obj_li = await process_ae_obj__post_props({
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;
} 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(
{
api_cfg,
@@ -245,6 +293,11 @@ export async function create_ae_obj__post(
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({
api_cfg: api_cfg,
obj_type: 'post',
@@ -257,15 +310,38 @@ export async function create_ae_obj__post(
return_obj: true,
log_lvl: log_lvl
})
.then(function (post_obj_create_result) {
.then(async function (post_obj_create_result) {
if (post_obj_create_result) {
if (try_cache) {
db_save_ae_obj_li__post(
{
obj_type: 'post',
obj_li: [post_obj_create_result],
log_lvl: log_lvl
// Process the results first
let processed_obj_li = await process_ae_obj__post_props({
obj_li: [post_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_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;
} 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(
{
api_cfg,
@@ -357,7 +433,9 @@ export async function update_ae_obj__post(
if (log_lvl) {
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,
obj_type: 'post',
obj_id: post_id,
@@ -365,32 +443,46 @@ export async function update_ae_obj__post(
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
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 () {
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('ae_promises.update__post_obj:', ae_promises.update__post_obj);
// Handle the result
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 = {};
// Updated 2024-09-25
// Updated 2025-06-23
export async function load_ae_obj_id__post_comment(
{
api_cfg,
@@ -17,6 +17,7 @@ export async function load_ae_obj_id__post_comment(
hidden = 'not_hidden',
limit = 99,
offset = 0,
params = {},
try_cache = true,
log_lvl = 0
}: {
@@ -26,6 +27,7 @@ export async function load_ae_obj_id__post_comment(
hidden?: string,
limit?: number,
offset?: number,
params?: key_val,
try_cache?: boolean,
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}`);
}
let params = {};
ae_promises.load__post_comment_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
@@ -45,16 +45,39 @@ export async function load_ae_obj_id__post_comment(
params: params,
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 (try_cache) {
// This is expecting a list
db_save_ae_obj_li__post_comment({
obj_type: 'post_comment',
// Process the results first
let processed_obj_li = await process_ae_obj__post_comment_props({
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;
} 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(
{
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}`);
}
// 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 = {};
// 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({
api_cfg: api_cfg,
@@ -128,14 +148,37 @@ export async function load_ae_obj_li__post_comment(
params: params,
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 (try_cache) {
db_save_ae_obj_li__post_comment({
obj_type: 'post_comment',
// Process the results first
let processed_obj_li = await process_ae_obj__post_comment_props({
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;
} 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(
{
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}`);
}
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({
api_cfg: api_cfg,
obj_type: 'post_comment',
@@ -188,15 +236,38 @@ export async function create_ae_obj__post_comment(
return_obj: true,
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 (try_cache) {
db_save_ae_obj_li__post_comment(
{
obj_type: 'post_comment',
obj_li: [post_comment_obj_create_result],
log_lvl: log_lvl
// Process the results first
let processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: [post_comment_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_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;
} 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(
{
api_cfg,
@@ -288,7 +359,9 @@ export async function update_ae_obj__post_comment(
if (log_lvl) {
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,
obj_type: 'post_comment',
obj_id: post_comment_id,
@@ -296,32 +369,46 @@ export async function update_ae_obj__post_comment(
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
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 () {
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('ae_promises.update__post_comment_obj:', ae_promises.update__post_comment_obj);
// Handle the result
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 -->
<!-- title="{$lq__post_obj?.title ?? 'New Post'} - {$lq__post_obj?.id ?? 'Not Saved Yet'}" -->
<Modal
bind:open={$idaa_sess.bb.show__modal_view__post_id}
autoclose={false}
outsideclose={true}

View File

@@ -1,7 +1,7 @@
<script lang="ts">
/** @type {import('./$types').PageData} */
export let data: any;
let log_lvl: number = 0;
import { run } from 'svelte/legacy';
let log_lvl: number = $state(0);
// console.log(`ae_events_pres_mgmt event [event_id] +page.svelte data:`, data);
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_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';
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
$: lq__event_obj = liveQuery(async () => {
let lq__event_obj = $derived(liveQuery(async () => {
let results = await db_events.events
.get($idaa_slct.event_id);
.get($idaa_slct.event_id ?? '');
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_id: string = $slct.account_id;
if (log_lvl > 1) {
@@ -90,43 +96,46 @@ $: lq_new__event_obj_li = liveQuery(async () => {
}
return null;
}
});
}));
// This (event_li trigger for IDAA) is not currently being used.
// Updated 2024-11-19
$: if ($idaa_trig.event_li) {
$idaa_trig.event_li = false;
run(() => {
if ($idaa_trig.event_li) {
$idaa_trig.event_li = false;
if (log_lvl) {
console.log(`Triggered: $idaa_trig.event_li`);
if (log_lvl) {
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
$: if ($idaa_trig.event_li_qry) {
run(() => {
if ($idaa_trig.event_li_qry) {
$idaa_trig.event_li_qry = false;
if (log_lvl) {
@@ -258,8 +267,8 @@ $: if ($idaa_trig.event_li_qry) {
clearInterval(request_loop);
}
}, search_delay);
}
});
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
lq__event_obj_li={lq_new__event_obj_li}
/>
@@ -386,8 +395,8 @@ function add_activity_log(
<!-- Modal: Event (Recovery Meeting) edit ID -->
<!-- title="{$lq__event_obj?.name} - {$lq__event_obj?.id}" -->
<Modal
title="{$lq__event_obj?.name} - {$lq__event_obj?.id}"
bind:open={$idaa_sess.recovery_meetings.show__modal_edit}
autoclose={false}
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"
>
<svelte:fragment slot="header">
{#snippet header()}
<div class="flex flex-row items-center justify-between w-full">
<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}
<!-- <div class="ae_options"> -->
<button
on:click={() => {
// const url = new URL(location);
// url.searchParams.set('event_id', $lq__event_obj?.event_id_random);
// history.pushState({}, '', url);
onclick={() => {
// const url = new URL(location);
// url.searchParams.set('event_id', $lq__event_obj?.event_id_random);
// history.pushState({}, '', url);
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = true;
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = true;
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'cancel_edit',
}
);
}}
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'cancel_edit',
}
);
}}
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}`}
>
@@ -428,72 +437,69 @@ function add_activity_log(
{$lq__event_obj?.name ?? 'New Recovery Meeting'}
</h3>
</div>
</svelte:fragment>
{/snippet}
<Comp__event_obj_id_edit
lq__event_obj={lq__event_obj}
/>
<svelte:fragment slot="footer">
{#snippet footer()}
<div class="text-center w-full">
<button
type="button"
on:click={() => {
console.log('Close modal');
$idaa_sess.recovery_meetings.show__modal_edit = false;
onclick={() => {
console.log('Close modal');
$idaa_sess.recovery_meetings.show__modal_edit = false;
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'close_modal',
}
);
}}
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'close_modal',
}
);
}}
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>
Close
</button>
</div>
</svelte:fragment>
{/snippet}
</Modal>
<!-- Modal: Event (Recovery Meeting) view ID -->
<!-- title="{$lq__event_obj?.name} - {$lq__event_obj?.id}" -->
<Modal
title="{$lq__event_obj?.name} - {$lq__event_obj?.id}"
bind:open={$idaa_sess.recovery_meetings.show__modal_view}
autoclose={false}
outsideclose={true}
placement="top-center"
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">
<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}
<button
on:click={() => {
// const url = new URL(location);
// url.searchParams.set('event_id', $lq__event_obj?.event_id_random);
// history.pushState({}, '', url);
onclick={() => {
// const url = new URL(location);
// url.searchParams.set('event_id', $lq__event_obj?.event_id_random);
// history.pushState({}, '', url);
$idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_edit = true;
$idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_edit = true;
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'edit',
}
);
}}
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'edit',
}
);
}}
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}`}
>
@@ -501,7 +507,7 @@ function add_activity_log(
</button>
{/if}
<span class="fas fa-calendar-day m-1"></span>
{$lq__event_obj?.name ?? '-- not set'}
{$lq__event_obj?.name ?? '-- not set --'}
</h3>
{#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.">
@@ -512,7 +518,19 @@ function add_activity_log(
</span>
{/if}
</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
lq__event_obj={lq__event_obj}