I am done for the night...
This commit is contained in:
@@ -75,6 +75,7 @@ let events_session_data_struct: key_val = {
|
||||
|
||||
// Badge Printing
|
||||
'badges': {
|
||||
'fulltext_search_qry_str': null,
|
||||
'status_qry__search': null,
|
||||
},
|
||||
|
||||
|
||||
35
src/lib/db_events.ts
Normal file
35
src/lib/db_events.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
export interface Badge {
|
||||
// id?: number;
|
||||
id_random: string;
|
||||
full_name: string;
|
||||
full_name_override: null|string;
|
||||
email: string;
|
||||
email_override: null|string;
|
||||
affiliations: string;
|
||||
affiliations_override: null|string;
|
||||
badge_type: string;
|
||||
badge_type_code: string;
|
||||
badge_type_code_override: null|string;
|
||||
badge_type_override: null|string;
|
||||
external_event_id: string;
|
||||
external_id: string;
|
||||
external_person_id: string;
|
||||
}
|
||||
|
||||
export class MySubClassedDexie extends Dexie {
|
||||
// 'badges' is added by dexie when declaring the stores()
|
||||
// We just tell the typing system this is the case
|
||||
badges!: Table<Badge>;
|
||||
|
||||
constructor() {
|
||||
super('ae_events_db');
|
||||
this.version(1).stores({
|
||||
// badges: '++id, full_name, email' // Primary key and indexed props
|
||||
badges: 'id_random, full_name, full_name_override, email, email_override, affiliations, affiliations_override, badge_type, badge_type_code, badge_type_code_override, badge_type_override, external_event_id, external_id, external_person_id' // Primary key and indexed props
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const db_events = new MySubClassedDexie();
|
||||
@@ -86,6 +86,8 @@ onMount(() => {
|
||||
// console.log(`ae_ ds_code_li = `, ds_code_li);
|
||||
|
||||
$: if (trigger == 'load__ds__code' && ds_code && ds_type) {
|
||||
console.log(`ae_ load__ds__code: ${ds_code} ${ds_type} ${for_type} ${for_id} ${try_cache}`);
|
||||
|
||||
trigger = null;
|
||||
|
||||
load_data_store({
|
||||
@@ -294,6 +296,8 @@ async function handle_submit_form(event) {
|
||||
return ds_results;
|
||||
})
|
||||
.finally(function (ds_val_result) {
|
||||
console.log(`ae_ ds_val_result = `, ds_val_result);
|
||||
trigger = 'load__ds__code';
|
||||
$ae_sess.ds.submit_status = 'created';
|
||||
});
|
||||
} else {
|
||||
@@ -323,7 +327,10 @@ async function handle_submit_form(event) {
|
||||
// .finally(function (ds_val_result) {
|
||||
// // console.log(`ae_ ds_code_val = `, ds_val_result);
|
||||
})
|
||||
.finally(function (ds_val_result) {
|
||||
.finally(function () {
|
||||
// console.log(`ae_ ds_val_result = `, ds_val_result);
|
||||
console.log(`ae_ load__ds__code: ${ds_code} ${ds_type} ${for_type} ${for_id} ${try_cache}`);
|
||||
trigger = 'load__ds__code';
|
||||
$ae_sess.ds.submit_status = 'updated';
|
||||
});
|
||||
}
|
||||
@@ -376,31 +383,31 @@ async function handle_update__data_store({
|
||||
|
||||
$ae_sess.ds.update_status = 'starting';
|
||||
ae_promises.update__data_store_obj = api.update_ae_obj_id_crud({
|
||||
api_cfg: $ae_api,
|
||||
obj_type: obj_type,
|
||||
obj_id: obj_id,
|
||||
fields: data,
|
||||
key: $ae_api.api_crud_super_key,
|
||||
log_lvl: 2
|
||||
})
|
||||
.then(async function (update__obj_result) {
|
||||
if (!update__obj_result) {
|
||||
console.log('The result was null or false.');
|
||||
return false;
|
||||
}
|
||||
return update__obj_result;
|
||||
api_cfg: $ae_api,
|
||||
obj_type: obj_type,
|
||||
obj_id: obj_id,
|
||||
fields: data,
|
||||
key: $ae_api.api_crud_super_key,
|
||||
log_lvl: 2
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Something went wrong.');
|
||||
console.log(error);
|
||||
.then(async function (update__obj_result) {
|
||||
if (!update__obj_result) {
|
||||
console.log('The result was null or false.');
|
||||
return false;
|
||||
})
|
||||
.finally(function (update__obj_result) {
|
||||
$ae_sess.ds.update_status = 'finished';
|
||||
return update__obj_result;
|
||||
})
|
||||
}
|
||||
return update__obj_result;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Something went wrong.');
|
||||
console.log(error);
|
||||
return false;
|
||||
})
|
||||
.finally(function (update__obj_result) {
|
||||
$ae_sess.ds.update_status = 'finished';
|
||||
return update__obj_result;
|
||||
})
|
||||
|
||||
return ae_promises.update__data_store_obj;
|
||||
return ae_promises.update__data_store_obj;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -581,7 +588,7 @@ async function handle_update__data_store({
|
||||
<button
|
||||
type="submit"
|
||||
class="btn variant-soft-primary"
|
||||
disabled={ds_submit_results instanceof Promise}
|
||||
disabled={ds_submit_results instanceof Promise && !ds_submit_results}
|
||||
on:click={() => {
|
||||
trigger = 'save__ds__code';
|
||||
// $slct_trigger = 'save__ds__code';
|
||||
@@ -600,10 +607,12 @@ async function handle_update__data_store({
|
||||
</div>
|
||||
{:then ds_submit_results}
|
||||
{#if ds_submit_results}
|
||||
<span class="fas fa-check text-green-500"></span>
|
||||
<span class="saved-text">
|
||||
Saved
|
||||
</span>
|
||||
<div>
|
||||
<span class="fas fa-check text-green-500"></span>
|
||||
<span class="saved-text">
|
||||
Saved
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
{/await}
|
||||
|
||||
@@ -644,6 +653,7 @@ async function handle_update__data_store({
|
||||
type="button"
|
||||
class="ae_btn_edit__ds btn hover:variant-glass-warning text-xs absolute top-0 right-0 opacity-75 hover:opacity-100 transition delay-700 hover:delay-200 m-1 p-1"
|
||||
on:click={() => {
|
||||
trigger = 'load__ds__code';
|
||||
show_edit = true;
|
||||
show_view = false;
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user