Done with clean up for the night. Still need to rename all of the shared functions that start with handle_.
This commit is contained in:
@@ -6,16 +6,26 @@ import { db_events } from "$lib/db_events";
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-07-02
|
||||
// Updated 2024-09-25
|
||||
export async function handle_load_ae_obj_id__event(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
inc_file_li = false,
|
||||
inc_location_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
inc_session_li = false,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_location_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
@@ -62,12 +72,24 @@ export async function handle_load_ae_obj_li__event(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
inc_file_li = false,
|
||||
inc_location_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
inc_session_li = false,
|
||||
order_by_li = {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_location_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
@@ -94,7 +116,7 @@ export async function handle_load_ae_obj_li__event(
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
@@ -122,6 +144,118 @@ export async function handle_load_ae_obj_li__event(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__event(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__event = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_create_result) {
|
||||
if (event_obj_create_result) {
|
||||
handle_db_save_ae_obj_li__event(
|
||||
{
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_create_result]
|
||||
});
|
||||
return event_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event:', ae_promises.create__event);
|
||||
}
|
||||
return ae_promises.create__event;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event() *** event_id=${event_id}`, data_kv);
|
||||
}
|
||||
// ae_promises.update__event_obj = 'test';
|
||||
ae_promises.update__event_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
obj_id: event_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_update_result) {
|
||||
if (event_obj_update_result) {
|
||||
if (try_cache) {
|
||||
handle_db_save_ae_obj_li__event({
|
||||
obj_type: 'event', obj_li: [event_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_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__event_obj:', ae_promises.update__event_obj);
|
||||
}
|
||||
return ae_promises.update__event_obj;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_obj_li and save each one to the DB.
|
||||
export function handle_db_save_ae_obj_li__event(
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@ export async function handle_load_ae_obj_id__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_file_id,
|
||||
try_cache=false,
|
||||
log_lvl=0
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_file_id: string,
|
||||
@@ -57,9 +57,9 @@ export async function handle_load_ae_obj_li__event_file(
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
@@ -130,8 +130,8 @@ export async function handle_delete_ae_obj_id__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_file_id,
|
||||
params={},
|
||||
log_lvl=0
|
||||
params = {},
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_file_id: string,
|
||||
@@ -165,12 +165,12 @@ export async function create_event_file_obj_from_hosted_file_async(
|
||||
{
|
||||
api_cfg,
|
||||
hosted_file_id,
|
||||
params={},
|
||||
data={},
|
||||
return_obj=false,
|
||||
inc_hosted_file=false,
|
||||
return_meta=false,
|
||||
log_lvl=0
|
||||
params = {},
|
||||
data = {},
|
||||
return_obj = false,
|
||||
inc_hosted_file = false,
|
||||
return_meta = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
hosted_file_id: string,
|
||||
@@ -228,8 +228,8 @@ export async function handle_update_ae_obj__event_file(
|
||||
api_cfg,
|
||||
event_file_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
params = {},
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_file_id: string,
|
||||
@@ -403,7 +403,7 @@ export function db_save_ae_obj_li__event_file(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl=0
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
@@ -574,4 +574,4 @@ export function db_update_ae_obj_id__event_file(
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +265,117 @@ export async function load_ae_obj_li__event_location(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-25
|
||||
export async function create_ae_obj__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event_location() *** event_id=${event_id}`);
|
||||
|
||||
ae_promises.create__event_location = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
fields: {
|
||||
event_id_random: event_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_create_result) {
|
||||
if (event_location_obj_create_result) {
|
||||
db_save_ae_obj_li__event_location(
|
||||
{
|
||||
obj_type: 'event_location',
|
||||
obj_li: [event_location_obj_create_result]
|
||||
});
|
||||
return event_location_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event_location:', ae_promises.create__event_location);
|
||||
}
|
||||
return ae_promises.create__event_location;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_location_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_location_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event_location() *** event_location_id=${event_location_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__event_location_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
obj_id: event_location_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_update_result) {
|
||||
if (event_location_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_location({
|
||||
obj_type: 'event_location', obj_li: [event_location_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_location_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__event_location_obj:', ae_promises.update__event_location_obj);
|
||||
}
|
||||
return ae_promises.update__event_location_obj;
|
||||
}
|
||||
|
||||
|
||||
export async function search__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -385,117 +496,6 @@ export async function search__event_location(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-25
|
||||
export async function create_ae_obj__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event_location() *** event_id=${event_id}`);
|
||||
|
||||
ae_promises.create__event_location = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
fields: {
|
||||
event_id_random: event_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_create_result) {
|
||||
if (event_location_obj_create_result) {
|
||||
db_save_ae_obj_li__event_location(
|
||||
{
|
||||
obj_type: 'event_location',
|
||||
obj_li: [event_location_obj_create_result]
|
||||
});
|
||||
return event_location_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event_location:', ae_promises.create__event_location);
|
||||
}
|
||||
return ae_promises.create__event_location;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_location_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_location_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event_location() *** event_location_id=${event_location_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__event_location_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
obj_id: event_location_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_update_result) {
|
||||
if (event_location_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_location({
|
||||
obj_type: 'event_location', obj_li: [event_location_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_location_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__event_location_obj:', ae_promises.update__event_location_obj);
|
||||
}
|
||||
return ae_promises.update__event_location_obj;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_location_obj_li and save each one to the DB.
|
||||
// Updated 2024-06-25
|
||||
export function db_save_ae_obj_li__event_location(
|
||||
|
||||
@@ -337,6 +337,7 @@ export async function create_ae_obj__event_session(
|
||||
return ae_promises.create__event_session;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-13
|
||||
export async function update_ae_obj__event_session(
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import {
|
||||
handle_load_ae_obj_id__event,
|
||||
handle_load_ae_obj_li__event,
|
||||
create_ae_obj__event,
|
||||
update_ae_obj__event,
|
||||
handle_db_save_ae_obj_li__event,
|
||||
sync_config__event_pres_mgmt,
|
||||
} from "$lib/ae_events__event";
|
||||
@@ -32,12 +34,14 @@ import {
|
||||
load_ae_obj_id__event_location,
|
||||
load_ae_obj_li__event_location,
|
||||
create_ae_obj__event_location,
|
||||
update_ae_obj__event_location,
|
||||
db_save_ae_obj_li__event_location,
|
||||
} from "$lib/ae_events__event_location";
|
||||
|
||||
import {
|
||||
load_ae_obj_id__event_session,
|
||||
load_ae_obj_li__event_session,
|
||||
create_ae_obj__event_session,
|
||||
update_ae_obj__event_session,
|
||||
qry__event_session,
|
||||
search__event_session,
|
||||
@@ -49,6 +53,7 @@ import {
|
||||
load_ae_obj_id__event_presentation,
|
||||
load_ae_obj_li__event_presentation,
|
||||
create_ae_obj__event_presentation,
|
||||
update_ae_obj__event_presentation,
|
||||
db_save_ae_obj_li__event_presentation,
|
||||
} from "$lib/ae_events__event_presentation";
|
||||
|
||||
@@ -74,6 +79,8 @@ import {
|
||||
let export_obj = {
|
||||
handle_load_ae_obj_id__event: handle_load_ae_obj_id__event,
|
||||
handle_load_ae_obj_li__event: handle_load_ae_obj_li__event,
|
||||
create_ae_obj__event: create_ae_obj__event,
|
||||
update_ae_obj__event: update_ae_obj__event,
|
||||
handle_db_save_ae_obj_li__event: handle_db_save_ae_obj_li__event,
|
||||
sync_config__event_pres_mgmt: sync_config__event_pres_mgmt,
|
||||
|
||||
@@ -87,10 +94,12 @@ let export_obj = {
|
||||
load_ae_obj_id__event_location: load_ae_obj_id__event_location,
|
||||
load_ae_obj_li__event_location: load_ae_obj_li__event_location,
|
||||
create_ae_obj__event_location: create_ae_obj__event_location,
|
||||
update_ae_obj__event_location: update_ae_obj__event_location,
|
||||
db_save_ae_obj_li__event_location: db_save_ae_obj_li__event_location,
|
||||
|
||||
load_ae_obj_id__event_session: load_ae_obj_id__event_session,
|
||||
load_ae_obj_li__event_session: load_ae_obj_li__event_session,
|
||||
create_ae_obj__event_session: create_ae_obj__event_session,
|
||||
update_ae_obj__event_session: update_ae_obj__event_session,
|
||||
qry__event_session: qry__event_session,
|
||||
search__event_session: search__event_session,
|
||||
@@ -100,6 +109,7 @@ let export_obj = {
|
||||
load_ae_obj_id__event_presentation: load_ae_obj_id__event_presentation,
|
||||
load_ae_obj_li__event_presentation: load_ae_obj_li__event_presentation,
|
||||
create_ae_obj__event_presentation: create_ae_obj__event_presentation,
|
||||
update_ae_obj__event_presentation: update_ae_obj__event_presentation,
|
||||
db_save_ae_obj_li__event_presentation: db_save_ae_obj_li__event_presentation,
|
||||
|
||||
load_ae_obj_id__event_presenter: load_ae_obj_id__event_presenter,
|
||||
|
||||
Reference in New Issue
Block a user