General work through out the day. Lots of interruptions from the dogs.

This commit is contained in:
Scott Idem
2024-03-25 19:26:49 -04:00
parent b0f2e2ccdf
commit 3ddef770c0
16 changed files with 497 additions and 491 deletions

View File

@@ -99,9 +99,65 @@ async function handle_load_ae_obj_code__data_store({ api_cfg, code=null, data_ty
}
async function handle_update_ae_obj_id_crud({api_cfg, object_type, object_id, field_name, new_field_value, params={}, try_cache=false}) {
let patch_result: any = null;
ae_promises.api_update__ae_obj = api.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: object_type,
obj_id: object_id,
field_name: field_name,
field_value: new_field_value,
// fields: data,
key: api_cfg.api_crud_super_key,
// jwt: null,
// params: params,
// data: patch_data,
log_lvl: 2
})
.then(function (results) {
console.log('PATCH Promise', results);
if (results) {
console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}`);
patch_result = 'PATCH complete';
} else {
console.log(`Not Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Account ID: ${api_cfg.account_id}`);
patch_result = 'PATCH failed';
return false;
}
// dispatch(
// 'ae_crud_updated',
// {
// 'type': object_type,
// 'id': object_id,
// 'field_name': field_name,
// 'field_value': new_field_value,
// 'original_value': original_field_value,
// }
// );
return true;
})
.catch(function (error) {
console.log('Something went wrong patching the record.');
console.log(error);
return false;
})
.finally(function () {
console.log('PATCH Promise finally');
});
return ae_promises.api_update__ae_obj;
}
let export_obj = {
handle_load_ae_obj_id__site_domain: handle_load_ae_obj_id__site_domain,
handle_load_ae_obj_code__data_store: handle_load_ae_obj_code__data_store,
handle_update_ae_obj_id_crud: handle_update_ae_obj_id_crud,
};
export let core_func = export_obj;

View File

@@ -41,6 +41,39 @@ async function handle_load_ae_obj_id__event({api_cfg, event_id, try_cache=false}
}
async function handle_load_ae_obj_id__badge({api_cfg, badge_id, try_cache=false}) {
console.log(`*** handle_load_ae_obj_id__badge() *** badge_id=${badge_id}`);
let params = {};
// $events_sess.badges.status_load__badge_obj = 'loading';
ae_promises.load__badge_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'event_badge',
obj_id: badge_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: false, // 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.
params: params,
log_lvl: 0
})
.then(function (badge_obj_get_result) {
if (badge_obj_get_result) {
// This is expecting a list
handle_db_save_ae_obj_li__badge({obj_type: 'event_badge', obj_li: [badge_obj_get_result]});
return badge_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
return ae_promises.load__badge_obj;
}
// Updated 2024-03-06
async function handle_load_ae_obj_li__badge({api_cfg, event_id, params={}, try_cache=true}: {api_cfg: any, event_id: any, params: any, try_cache?: boolean}) {
console.log(`*** handle_load_ae_obj_li__badge() *** event_id=${event_id}`);
@@ -121,7 +154,6 @@ async function handle_load_ae_obj_li__badge({api_cfg, event_id, params={}, try_c
}
async function handle_search__event_badge({api_cfg, event_id, fulltext_search_qry_str, external_event_id, params={}, try_cache=true}) {
console.log(`*** handle_search__event_badge() *** event_id=${event_id}`);
@@ -476,6 +508,10 @@ async function handle_create_ae_obj__exhibit_tracking({api_cfg, exhibit_id, even
}
// This function will loop through the badge_obj_li and save each one to the DB.
function handle_db_save_ae_obj_li__badge({obj_type, obj_li}) {
console.log(`*** handle_db_save_ae_obj_li__badge() ***`);
@@ -544,7 +580,7 @@ function handle_db_save_ae_obj_li__badge({obj_type, obj_li}) {
created_on: obj.created_on,
updated_on: obj.updated_on,
});
console.log(`Put obj with ID: ${obj.event_badge_id_random} or ${id_random}`);
// console.log(`Put obj with ID: ${obj.event_badge_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.event_badge_id_random}: ${error}`;
console.log(status);
@@ -666,7 +702,7 @@ function handle_db_save_ae_obj_li__exhibitor_tracking({obj_type, obj_li}) {
created_on: obj.created_on,
updated_on: obj.updated_on,
});
console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random} or ${id_random}`);
// console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.event_exhibit_tracking_id_random}: ${error}`;
console.log(status);
@@ -683,6 +719,7 @@ function handle_db_save_ae_obj_li__exhibitor_tracking({obj_type, obj_li}) {
let export_obj = {
handle_load_ae_obj_id__event: handle_load_ae_obj_id__event,
handle_load_ae_obj_id__badge: handle_load_ae_obj_id__badge,
handle_load_ae_obj_li__badge: handle_load_ae_obj_li__badge,
handle_search__event_badge: handle_search__event_badge,
handle_load_ae_obj_id__exhibit: handle_load_ae_obj_id__exhibit,

View File

@@ -5,6 +5,7 @@ import { createEventDispatcher, onMount } from 'svelte';
// *** Import Aether core variables and functions
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
import { core_func } from '$lib/ae_core_functions';
// import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
// *** Import Aether core components
@@ -14,8 +15,8 @@ import { api } from '$lib/api';
// *** Export/Exposed variables and functions for component
export let log_lvl: number = 0;
export let trigger_patch: any = null;
export let api_cfg: object = {'api_crud_super_key': null};
export let api_crud_super_key: null|string = api_cfg.api_crud_super_key;
export let api_cfg: key_val = {'api_crud_super_key': null};
// export let api_crud_super_key: null|string = api_cfg.api_crud_super_key;
export let object_type: string;
export let object_id: string;
export let field_name: string;
@@ -42,7 +43,7 @@ export let class_li: string = '';
// *** Set initial variables
let ae_promises: key_val = {}; // Promise<any>;
let patch_result: Promise<any>|key_val;
let patch_result: null|Promise<any>|key_val|string;
let original_field_value = field_value;
@@ -87,18 +88,12 @@ async function handle_obj_field_patch(new_field_value: any) {
// let params = {};
ae_promises.api_update__ae_obj = api.update_ae_obj_id_crud({
ae_promises.api_update__ae_obj = core_func.handle_update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: object_type,
obj_id: object_id,
object_type: object_type,
object_id: object_id,
field_name: field_name,
field_value: new_field_value,
// fields: data,
key: api_crud_super_key,
// jwt: null,
// params: params,
// data: patch_data,
log_lvl: 2
new_field_value: new_field_value,
})
.then(function (results) {
console.log('PATCH Promise', results);
@@ -133,6 +128,62 @@ async function handle_obj_field_patch(new_field_value: any) {
console.log('PATCH Promise finally');
});
// if (ae_promises.api_update__ae_obj) {
// console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
// patch_result = 'PATCH complete';
// } else {
// console.log(`Not Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
// patch_result = 'PATCH failed';
// return false;
// }
// ae_promises.api_update__ae_obj = api.update_ae_obj_id_crud({
// api_cfg: api_cfg,
// obj_type: object_type,
// obj_id: object_id,
// field_name: field_name,
// field_value: new_field_value,
// // fields: data,
// key: api_crud_super_key,
// // jwt: null,
// // params: params,
// // data: patch_data,
// log_lvl: 2
// })
// .then(function (results) {
// console.log('PATCH Promise', results);
// if (results) {
// console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
// patch_result = 'PATCH complete';
// } else {
// console.log(`Not Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
// patch_result = 'PATCH failed';
// return false;
// }
// dispatch(
// 'ae_crud_updated',
// {
// 'type': object_type,
// 'id': object_id,
// 'field_name': field_name,
// 'field_value': new_field_value,
// 'original_value': original_field_value,
// }
// );
// return true;
// })
// .catch(function (error) {
// console.log('Something went wrong patching the record.');
// console.log(error);
// return false;
// })
// .finally(function () {
// console.log('PATCH Promise finally');
// });
return ae_promises.api_update__ae_obj;
}
</script>
@@ -226,10 +277,10 @@ async function handle_obj_field_patch(new_field_value: any) {
/* BEGIN: Svelte CRUD (update) component */
.ae_crud {
/* margin: 0; */
/* padding: 0; */
}
/* .ae_crud {
margin: 0;
padding: 0;
} */
.ae_crud.display_inline {
/* outline: solid thin red; */

View File

@@ -131,13 +131,21 @@ $: if (trigger == 'load__ds__code' && ds_code && ds_type) {
});
}
async function load_data_store({
async function load_data_store(
{
code,
type='text',
for_type=null,
for_id=null,
try_cache=true
}) {
}: {
code: string,
type: string,
for_type: string|null,
for_id: string|null,
try_cache: boolean
}
) {
// let ds_code_val = await api.get_data_store_obj_w_code({
ds_get_results = api.get_data_store_obj_w_code({
@@ -145,6 +153,7 @@ async function load_data_store({
data_store_code: code,
data_type: type,
log_lvl: 1
})
.then( function (ds_results) {
// console.log(`ae_ Data Store ${code} = `, ds_results);
@@ -210,18 +219,18 @@ async function load_data_store({
}
async function handle_submit_form(event) {
console.log('*** handle_submit_form() ***');
async function handle_submit_form(event: any) {
// console.log('*** handle_submit_form() ***');
$ae_sess.ds.submit_status = 'processing';
// Data in
let form_data = new FormData(event.target);
console.log(form_data);
// console.log(form_data);
let data_store_di: key_val = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: 0});
console.log(data_store_di);
// console.log(data_store_di);
// Data out
let data_store_do: key_val = {};
@@ -423,7 +432,7 @@ async function handle_update__data_store({
obj_id: obj_id,
fields: data,
key: $ae_api.api_crud_super_key,
log_lvl: 2
log_lvl: 1
})
.then(async function (update__obj_result) {
if (!update__obj_result) {