Now able to do stuff with the locations
This commit is contained in:
370
src/lib/ae_events__event_location.ts
Normal file
370
src/lib/ae_events__event_location.ts
Normal file
@@ -0,0 +1,370 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
export async function handle_load_ae_obj_id__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_location_id,
|
||||
try_cache=false,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_location_id: string,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__event_location() *** event_location_id=${event_location_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
// $events_sess.badges.status_load__event_location_obj = 'loading';
|
||||
ae_promises.load__event_location_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
obj_id: event_location_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: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_get_result) {
|
||||
if (event_location_obj_get_result) {
|
||||
// This is expecting a list
|
||||
handle_db_save_ae_obj_li__event_location({obj_type: 'event_location', obj_li: [event_location_obj_get_result]});
|
||||
return event_location_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__event_location_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-05-24
|
||||
export async function handle_load_ae_obj_li__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__event_location() ***`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_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
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'code': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_li_get_result) {
|
||||
if (event_location_obj_li_get_result) {
|
||||
handle_db_save_ae_obj_li__event_location({obj_type: 'event_location', obj_li: event_location_obj_li_get_result});
|
||||
return event_location_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_location_obj_li:', ae_promises.load__event_location_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_location_obj_li;
|
||||
}
|
||||
|
||||
|
||||
export async function handle_search__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
fulltext_search_qry_str,
|
||||
ft_presenter_search_qry_str,
|
||||
like_search_qry_str = null,
|
||||
like_presentation_search_qry_str = null,
|
||||
like_presenter_search_qry_str = null,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
fulltext_search_qry_str?: null|string,
|
||||
ft_presenter_search_qry_str?: null|string,
|
||||
like_search_qry_str?: null|string,
|
||||
like_presentation_search_qry_str?: null|string,
|
||||
like_presenter_search_qry_str?: null|string,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_search__event_location() *** event_id=${event_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 25); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
if (!fulltext_search_qry_str && !like_search_qry_str) {
|
||||
console.log('No search string provided!!!');
|
||||
return false; // Returning false instead of [] because no search was performed.
|
||||
}
|
||||
|
||||
if (fulltext_search_qry_str || ft_presenter_search_qry_str) {
|
||||
params_json['ft_qry'] = {};
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
||||
}
|
||||
|
||||
if (ft_presenter_search_qry_str && ft_presenter_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['event_presenter_li_qry_str'] = ft_presenter_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
// Use the AND (AND LIKE) query
|
||||
// if (like_search_qry_str || like_presenter_search_qry_str) {
|
||||
// params_json['and_like'] = {};
|
||||
// if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['default_qry_str'] = like_search_qry_str;
|
||||
// }
|
||||
// if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Use the AND (OR LIKE) query
|
||||
if (like_search_qry_str || like_presentation_search_qry_str || like_presenter_search_qry_str) {
|
||||
params_json['or_like'] = {};
|
||||
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
params_json['or_like']['default_qry_str'] = like_search_qry_str;
|
||||
}
|
||||
if (like_presentation_search_qry_str && like_presentation_search_qry_str.length > 2) {
|
||||
params_json['or_like']['event_presentation_li_qry_str'] = like_presentation_search_qry_str;
|
||||
}
|
||||
if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
|
||||
params_json['or_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
|
||||
// if (location_type_code) {
|
||||
// params_json['and_qry']['location_type_code'] = location_type_code;
|
||||
// }
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: true, // NOTE: We want to use the alt table for location searching
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_li_get_result) {
|
||||
if (event_location_obj_li_get_result) {
|
||||
handle_db_save_ae_obj_li__event_location({obj_type: 'event_location', obj_li: event_location_obj_li_get_result});
|
||||
return event_location_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_location_obj_li:', ae_promises.load__event_location_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_location_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-25
|
||||
export async function handle_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(`*** handle_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) {
|
||||
handle_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;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_location_obj_li and save each one to the DB.
|
||||
// Updated 2024-06-25
|
||||
export function handle_db_save_ae_obj_li__event_location(
|
||||
{
|
||||
obj_type,
|
||||
obj_li
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_db_save_ae_obj_li__event_location() ***`);
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
// console.log(`ae_obj ${obj_type}:`, obj);
|
||||
|
||||
try {
|
||||
const id_random = await db_events.locations.put({
|
||||
id: obj.event_location_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
|
||||
// poc_person_given_name: obj.poc_person_given_name,
|
||||
// poc_person_family_name: obj.poc_person_family_name,
|
||||
// poc_person_full_name: obj.poc_person_full_name,
|
||||
// poc_person_primary_email: obj.poc_person_primary_email,
|
||||
// poc_person_passcode: obj.poc_person_passcode,
|
||||
// poc_kv_json: obj.poc_kv_json,
|
||||
|
||||
event_name: obj.event_name,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_location_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_location_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.locations.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_location_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,13 @@ import {
|
||||
handle_db_save_ae_obj_li__exhibitor
|
||||
} from "$lib/ae_events__exhibit";
|
||||
|
||||
import {
|
||||
handle_load_ae_obj_id__event_location,
|
||||
handle_load_ae_obj_li__event_location,
|
||||
handle_create_ae_obj__event_location,
|
||||
handle_db_save_ae_obj_li__event_location
|
||||
} from "$lib/ae_events__event_location";
|
||||
|
||||
import {
|
||||
handle_load_ae_obj_id__event_session,
|
||||
handle_load_ae_obj_li__event_session,
|
||||
@@ -63,6 +70,10 @@ let export_obj = {
|
||||
handle_load_ae_obj_li__event_file: handle_load_ae_obj_li__event_file,
|
||||
handle_delete_ae_obj_id__event_file: handle_delete_ae_obj_id__event_file,
|
||||
|
||||
handle_load_ae_obj_id__event_location: handle_load_ae_obj_id__event_location,
|
||||
handle_load_ae_obj_li__event_location: handle_load_ae_obj_li__event_location,
|
||||
handle_create_ae_obj__event_location: handle_create_ae_obj__event_location,
|
||||
|
||||
handle_load_ae_obj_id__event_session: handle_load_ae_obj_id__event_session,
|
||||
handle_load_ae_obj_li__event_session: handle_load_ae_obj_li__event_session,
|
||||
handle_search__event_session: handle_search__event_session,
|
||||
|
||||
@@ -361,3 +361,24 @@ export let events_slct = writable(events_slct_obj_template);
|
||||
// Updated 2024-03-06
|
||||
export let events_trigger: any = writable(null);
|
||||
// console.log(`AE Events Stores - Events Trigger:`, events_trigger);
|
||||
|
||||
|
||||
/* *** BEGIN *** TESTING Initialize trig_resp */
|
||||
// The idea behind this is for a shared (Svelte app (within Events for now)) trigger and response. In theory this could be used to monitor multiple downloads or have a universal status area. Intended for temporary session storage.
|
||||
// Updated 2024-06-25
|
||||
let events_trig_kv_tmp: key_val = {};
|
||||
// {
|
||||
// 'example-1':
|
||||
// {
|
||||
// 'a-rand-id-1': true,
|
||||
// 'a-rand-id-2': false,
|
||||
// 'a-rand-id-3': Promise.resolve('This is a test promise.'),
|
||||
// },
|
||||
// 'example-2':
|
||||
// {
|
||||
// 'a-rand-id-4': true,
|
||||
// 'a-rand-id-5': false,
|
||||
// 'a-rand-id-6': Promise.resolve('This is a test promise.'),
|
||||
// },
|
||||
// };
|
||||
export let events_trig_kv = writable(events_trig_kv_tmp);
|
||||
@@ -238,8 +238,46 @@ export interface File {
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-25
|
||||
export interface Location {
|
||||
// Nothing here yet
|
||||
id: string;
|
||||
// id_random: string;
|
||||
event_location_id: string;
|
||||
event_location_id_random: string;
|
||||
|
||||
external_id?: null|string;
|
||||
code?: null|string;
|
||||
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
|
||||
name: string;
|
||||
description?: null|string;
|
||||
|
||||
passcode?: null|string;
|
||||
|
||||
hide_event_launcher?: null|boolean;
|
||||
|
||||
alert?: null|boolean;
|
||||
alert_msg?: null|string;
|
||||
|
||||
data_json?: null|string;
|
||||
|
||||
enable: null|boolean;
|
||||
hide?: null|boolean;
|
||||
priority?: null|boolean
|
||||
sort?: null|number;
|
||||
group?: null|string;
|
||||
notes?: null|string;
|
||||
created_on: Date;
|
||||
updated_on?: null|Date;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
file_count?: null|number;
|
||||
file_count_all?: null|number;
|
||||
internal_use_count?: null|number;
|
||||
|
||||
event_name?: null|string;
|
||||
}
|
||||
|
||||
|
||||
@@ -441,6 +479,7 @@ export class MySubClassedDexie extends Dexie {
|
||||
exhibits!: Table<Exhibit>;
|
||||
exhibit_tracking!: Table<Exhibit_tracking>;
|
||||
files!: Table<File>;
|
||||
locations!: Table<Location>;
|
||||
sessions!: Table<Session>;
|
||||
presentations!: Table<Presentation>;
|
||||
presenters!: Table<Presenter>;
|
||||
@@ -503,6 +542,17 @@ export class MySubClassedDexie extends Dexie {
|
||||
lu_file_purpose_id, lu_event_file_purpose_name, file_purpose,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
|
||||
locations: `
|
||||
id, event_location_id, event_location_id_random,
|
||||
external_id, code,
|
||||
event_id, event_id_random,
|
||||
name, description,
|
||||
passcode,
|
||||
hide_event_launcher,
|
||||
alert, alert_msg,
|
||||
data_json,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
|
||||
presentations: `
|
||||
id, event_presentation_id, event_presentation_id_random,
|
||||
external_id, code,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { core_func } from '$lib/ae_core_functions';
|
||||
// *** Import Aether module components
|
||||
|
||||
// *** Export/Exposed variables and functions for component
|
||||
export let log_lvl: number = 0;
|
||||
export let log_lvl: number = 1;
|
||||
export let trigger_patch: any = null;
|
||||
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;
|
||||
@@ -24,6 +24,7 @@ export let field_type: string = 'text'; // button, text, textarea, template (old
|
||||
export let field_value: any;
|
||||
export let allow_null: boolean = false;
|
||||
export let select_option_li: key_val = {};
|
||||
export let edit_label: string = 'Edit';
|
||||
export let display_inline: boolean = false;
|
||||
export let display_block_edit: boolean = false;
|
||||
|
||||
@@ -35,7 +36,7 @@ export let textarea_rows: number = 5;
|
||||
export let hide_edit_btn = false;
|
||||
export let outline_element = false;
|
||||
export let show_crud = false;
|
||||
export let btn_label = '<span class="fas fa-check mx-1"></span> Save'; // PATCH
|
||||
export let btn_label = null; // '<span class="fas fa-check mx-1"></span> Save'; // PATCH
|
||||
|
||||
// export let show_field_name = true;
|
||||
// export let show_original_value = true;
|
||||
@@ -56,7 +57,8 @@ const dispatch = createEventDispatcher();
|
||||
onMount(() => {
|
||||
// console.log('** Element Mounted: ** Element AE CRUD');
|
||||
if (log_lvl) {
|
||||
console.log(`Element AE CRUD: Object Type: ${object_type}; Object ID: ${object_id}; Field Name: ${field_name}; Field Value: ${field_value}`); // ; Super Key: ${api_crud_super_key}
|
||||
console.log(`Element AE CRUD: Object Type: ${object_type}; Object ID: ${object_id}; Field Name: ${field_name}; Field Value: ${field_value} (Original: ${original_field_value})`);
|
||||
// ; Super Key: ${api_crud_super_key}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -91,7 +93,7 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
|
||||
// let params = {};
|
||||
|
||||
ae_promises.api_update__ae_obj = await core_func.handle_update_ae_obj_id_crud({
|
||||
ae_promises.api_update__ae_obj = core_func.handle_update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
object_type: object_type,
|
||||
object_id: object_id,
|
||||
@@ -107,6 +109,7 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
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';
|
||||
original_field_value = new_field_value;
|
||||
} 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';
|
||||
@@ -139,7 +142,12 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
</script>
|
||||
|
||||
|
||||
<div class="{class_li} ae_crud" class:show_crud class:display_inline class:outline_element>
|
||||
<div
|
||||
class="{class_li} ae_crud"
|
||||
class:show_crud
|
||||
class:display_inline
|
||||
class:outline_element
|
||||
>
|
||||
<span class="field_viewing_wrapper">
|
||||
<slot></slot>
|
||||
|
||||
@@ -158,19 +166,25 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
|
||||
<div
|
||||
class:display_block_edit
|
||||
class="field_editing_wrapper flex flex-row items-center justify-center min-w-content w-100 max-w-full"
|
||||
class="field_editing_wrapper min-w-content w-100 max-w-full"
|
||||
>
|
||||
<button
|
||||
class="btn btn-md variant-glass-tertiary hover:variant-ghost-tertiary m-1 transition-all"
|
||||
class:show_crud
|
||||
on:click={() => {
|
||||
show_crud = false;
|
||||
}}
|
||||
title="Close field editing"
|
||||
>
|
||||
<span class="fas fa-window-close"></span>
|
||||
<span class="hidden md:inline">Close</span>
|
||||
</button>
|
||||
<!-- <span class="grow flex flex-row items-center justify-between"> -->
|
||||
<!-- <span class="">
|
||||
{edit_label}
|
||||
</span> -->
|
||||
|
||||
<button
|
||||
class="btn btn-md variant-glass-tertiary hover:variant-ghost-tertiary m-1 transition-all"
|
||||
class:show_crud
|
||||
on:click={() => {
|
||||
show_crud = false;
|
||||
}}
|
||||
title="Close field editing"
|
||||
>
|
||||
<span class="fas fa-window-close"></span>
|
||||
<span class="hidden md:inline">Close</span>
|
||||
</button>
|
||||
<!-- </span> -->
|
||||
|
||||
<span
|
||||
class="field_value grow min-w-content max-w-full"
|
||||
@@ -188,10 +202,12 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
>
|
||||
{#if select_option_li && Object.keys(select_option_li).length == 0}
|
||||
<option value="">-- not set --</option>
|
||||
{:else}
|
||||
{:else if select_option_li && Object.keys(select_option_li).length > 0}
|
||||
{#each Object.keys(select_option_li) as option}
|
||||
<option value={option}>{select_option_li[option]}</option>
|
||||
{/each}
|
||||
{:else}
|
||||
<option value="">-- no list --</option>
|
||||
{/if}
|
||||
</select>
|
||||
|
||||
@@ -216,7 +232,7 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
{#if allow_null}
|
||||
<button
|
||||
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning m-1"
|
||||
on:click={async () => {
|
||||
on:click={() => {
|
||||
field_value = null;
|
||||
}}
|
||||
title="Set value to NULL"
|
||||
@@ -230,20 +246,39 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
<button
|
||||
class="btn btn-lg variant-glass-primary hover:variant-ghost-primary m-1"
|
||||
class:show_crud
|
||||
disabled={field_value == original_field_value}
|
||||
on:click={async () => {
|
||||
handle_obj_field_patch(field_value);
|
||||
}}
|
||||
title="Save new field value"
|
||||
>
|
||||
{@html btn_label}
|
||||
{#if field_value == original_field_value}
|
||||
{#if (btn_label)}
|
||||
{@html btn_label}
|
||||
{:else}
|
||||
<span class="fas fa-check mx-1"></span>
|
||||
<span>Save</span>
|
||||
{/if}
|
||||
<!-- <span>{patch_result}</span> -->
|
||||
{:else}
|
||||
{#if (btn_label)}
|
||||
{@html btn_label}
|
||||
{:else}
|
||||
<span class="fas fa-save mx-1"></span>
|
||||
<span>Save?</span>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</button>
|
||||
|
||||
<div class="field_patch_result" class:show_crud>
|
||||
{#await ae_promises.api_update__ae_obj}
|
||||
<div>Processing...</div>
|
||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||
<span>Processing...</span>
|
||||
{:then}
|
||||
{#if patch_result}
|
||||
<div>{patch_result}</div>
|
||||
<span class="fas fa-check mx-1"></span>
|
||||
<span>{patch_result}</span>
|
||||
{:else}
|
||||
<!-- <div>Nothing to show yet...</div> -->
|
||||
{/if}
|
||||
@@ -405,14 +440,18 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.ae_crud.ae_crud.show_crud.display_inline .field_editing_wrapper.display_block_edit {
|
||||
.ae_crud.show_crud.display_inline .field_editing_wrapper.display_block_edit {
|
||||
/* display: block; */
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: .5em;
|
||||
|
||||
flex-grow: 1;
|
||||
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ import type { key_val } from '$lib/ae_stores';
|
||||
// import { ae_util } from '$lib/ae_utils';
|
||||
import { api } from '$lib/api';
|
||||
import { ae_loc, ae_sess, ae_api, slct } from '$lib/ae_stores';
|
||||
import { events_loc, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||
import { events_loc, events_slct, events_trigger, events_trig_kv } from '$lib/ae_events_stores';
|
||||
import { events_func } from '$lib/ae_events_functions';
|
||||
|
||||
// import Element_data_store from '$lib/element_data_store.svelte';
|
||||
|
||||
@@ -39,6 +40,26 @@ onMount(() => {
|
||||
console.log($events_slct.event_obj_li);
|
||||
});
|
||||
|
||||
|
||||
// Updated 2024-06-25
|
||||
$: if ($events_trigger == 'load__event_session_obj_id' && $events_trig_kv['event_session_id']) {
|
||||
console.log(`load__event_session_obj_id() $events_slct.event_session_id=${$events_slct.event_session_id}`);
|
||||
|
||||
$events_trigger = null;
|
||||
|
||||
if ($events_slct.event_session_id) {
|
||||
$events_trig_kv['event_session_id'] = events_func.handle_load_ae_obj_id__event_session({
|
||||
api_cfg: $ae_api,
|
||||
event_session_id: $events_slct.event_session_id,
|
||||
log_lvl: 1
|
||||
})
|
||||
.then(function (load_results) {
|
||||
console.log(`ae_event_session_get_promise:`, load_results);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -202,8 +202,6 @@ $: if ($events_trigger == 'load__event_session_obj_li' && $events_slct.event_id)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import { liveQuery } from "dexie";
|
||||
import { core_func } from '$lib/ae_core_functions';
|
||||
import { db_events } from "$lib/db_events";
|
||||
import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||
import { events_loc, events_sess, events_slct, events_trigger, events_trig_kv } from '$lib/ae_events_stores';
|
||||
import { events_func } from '$lib/ae_events_functions';
|
||||
|
||||
import Form_agree from './form_agree.svelte';
|
||||
@@ -514,9 +514,12 @@ function send_sign_in_poc_email(
|
||||
on:ae_crud_updated={e => {
|
||||
console.log(`ae_crud_updated:`, e.detail);
|
||||
|
||||
events_func.handle_load_ae_obj_id__event_session({api_cfg: $ae_api, event_session_id: $lq__event_session_obj?.event_session_id_random, log_lvl: 1});
|
||||
events_func.handle_load_ae_obj_id__event_session({api_cfg: $ae_api, event_session_id: $lq__event_session_obj?.event_session_id_random});
|
||||
// $events_trigger = 'load__event_session_obj_id';
|
||||
// $events_trig_kv['event_session_id'] = $lq__event_session_obj?.event_session_id_random;
|
||||
}}
|
||||
>
|
||||
{ae_util.iso_datetime_formatter($lq__event_session_obj.start_datetime, 'dddd')},
|
||||
{ae_util.iso_datetime_formatter($lq__event_session_obj.start_datetime, 'datetime_long')}
|
||||
</Element_ae_crud>
|
||||
-
|
||||
@@ -536,14 +539,120 @@ function send_sign_in_poc_email(
|
||||
on:ae_crud_updated={e => {
|
||||
console.log(`ae_crud_updated:`, e.detail);
|
||||
|
||||
events_func.handle_load_ae_obj_id__event_session({api_cfg: $ae_api, event_session_id: $lq__event_session_obj?.event_session_id_random, log_lvl: 1});
|
||||
events_func.handle_load_ae_obj_id__event_session({api_cfg: $ae_api, event_session_id: $lq__event_session_obj?.event_session_id_random});
|
||||
// $events_trigger = 'load__event_session_obj_id';
|
||||
// $events_trig_kv['event_session_id'] = $lq__event_session_obj?.event_session_id_random;
|
||||
}}
|
||||
>
|
||||
{ae_util.iso_datetime_formatter($lq__event_session_obj.end_datetime, 'datetime_long')}
|
||||
{ae_util.iso_datetime_formatter($lq__event_session_obj.end_datetime, 'time_short')}
|
||||
</Element_ae_crud>
|
||||
</li>
|
||||
<li>
|
||||
<strong class="text-sm">Location/Room:</strong> {$lq__event_session_obj.event_location_name ? $lq__event_session_obj.event_location_name : '-- not set --'}
|
||||
|
||||
{#if $ae_loc.trusted_access}
|
||||
<Element_ae_crud
|
||||
trigger_patch={ae_triggers.update_event_location}
|
||||
api_cfg={$ae_api}
|
||||
object_type={'event_session'}
|
||||
object_id={$lq__event_session_obj?.event_session_id_random}
|
||||
field_name={'event_location_id_random'}
|
||||
field_type={'select'}
|
||||
field_value={ae_tmp.event_location_id}
|
||||
select_option_li={$slct.event_location_obj_kv}
|
||||
allow_null={true}
|
||||
hide_edit_btn={true}
|
||||
outline_element={false}
|
||||
show_crud={ae_tmp.show__edit_event_location}
|
||||
display_inline={true}
|
||||
class_li={'m-1'}
|
||||
on:ae_crud_updated={e => {
|
||||
console.log(`ae_crud_updated:`, e.detail);
|
||||
|
||||
events_func.handle_load_ae_obj_id__event_session({api_cfg: $ae_api, event_session_id: $lq__event_session_obj?.event_session_id_random, log_lvl: 1})
|
||||
.then(function (load_results) {
|
||||
ae_tmp.event_location_id = null;
|
||||
ae_tmp.show__edit_event_location = false;
|
||||
|
||||
// Maybe reload page?
|
||||
// window.location.reload();
|
||||
});
|
||||
}}
|
||||
>
|
||||
{#if ae_tmp?.show__edit_location}
|
||||
|
||||
{#await $slct.event_location_obj_li}
|
||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||
{:then event_location_obj_li}
|
||||
<!-- {#if event_location_obj_li && event_location_obj_li.length > 0}
|
||||
|
||||
{/if} -->
|
||||
{/await}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('Cancel editing the location for the session.');
|
||||
|
||||
ae_tmp.event_location_id = null;
|
||||
ae_tmp.show__edit_event_location = false;
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
|
||||
>
|
||||
<span class="fas fa-times mx-1"></span>
|
||||
Cancel
|
||||
</button>
|
||||
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('Edit the location for the session.');
|
||||
|
||||
let params = {
|
||||
qry__limit: 50,
|
||||
}
|
||||
|
||||
// $slct.event_location_obj_li = await core_func.handle_load_ae_obj_li__event_location({api_cfg: $ae_api, account_id: $slct.account_id, params: params});
|
||||
|
||||
$slct.event_location_obj_li = events_func.handle_load_ae_obj_li__event_location({api_cfg: $ae_api, event_id: $slct.event_id, params: params, log_lvl: 1})
|
||||
.then(function (load_results) {
|
||||
console.log(`Loaded event_location_obj_li:`, load_results);
|
||||
|
||||
// We need to make this ready for the select option list. Convert the list to a key value pair with the event_location_id_random as the key. We also need to set the option text value to: name (room)
|
||||
if (load_results) {
|
||||
let event_location_obj_li = load_results;
|
||||
let event_location_obj_kv = {};
|
||||
event_location_obj_kv[''] = '-- Select a location --';
|
||||
event_location_obj_li.forEach((event_location_obj) => {
|
||||
let option_text = `${event_location_obj.name} (${event_location_obj.code})`;
|
||||
event_location_obj_kv[event_location_obj.event_location_id_random] = option_text;
|
||||
});
|
||||
$slct.event_location_obj_kv = event_location_obj_kv;
|
||||
}
|
||||
// $slct.event_location_obj_kv = $slct.event_location_obj_kv;
|
||||
console.log(`$slct.event_location_obj_kv = `, $slct.event_location_obj_kv);
|
||||
|
||||
return load_results;
|
||||
})
|
||||
.finally(function () {
|
||||
console.log(`Finally...`);
|
||||
ae_tmp.event_location_id = $lq__event_session_obj?.event_location_id_random;
|
||||
ae_tmp.show__edit_event_location = true;
|
||||
});
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
|
||||
>
|
||||
<span class="fas fa-edit mx-1"></span>
|
||||
Edit
|
||||
</button>
|
||||
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
</Element_ae_crud>
|
||||
{/if}
|
||||
</li>
|
||||
<li>
|
||||
<strong class="text-sm">Moderator/Champion:</strong>
|
||||
@@ -741,7 +850,7 @@ function send_sign_in_poc_email(
|
||||
|
||||
</li>
|
||||
|
||||
{#if $ae_loc.trusted_access}
|
||||
{#if $ae_loc.administrator_access}
|
||||
<li>
|
||||
<strong class="text-sm">Session passcode:</strong> {$lq__event_session_obj.passcode ? $lq__event_session_obj.passcode : '-- not set --'}
|
||||
</li>
|
||||
@@ -760,9 +869,15 @@ function send_sign_in_poc_email(
|
||||
hide_edit_btn={!$ae_loc.trusted_access}
|
||||
outline_element={false}
|
||||
show_crud={false}
|
||||
display_inline={false}
|
||||
display_inline={true}
|
||||
display_block_edit={true}
|
||||
textarea_rows={15}
|
||||
class_li={''}
|
||||
on:ae_crud_updated={e => {
|
||||
console.log(`ae_crud_updated:`, e.detail);
|
||||
|
||||
events_func.handle_load_ae_obj_id__event_session({api_cfg: $ae_api, event_session_id: $lq__event_session_obj?.event_session_id_random, log_lvl: 1});
|
||||
}}
|
||||
>
|
||||
<strong class="text-sm">
|
||||
Session description:
|
||||
@@ -1173,9 +1288,15 @@ function send_sign_in_poc_email(
|
||||
hide_edit_btn={!$ae_loc.trusted_access}
|
||||
outline_element={false}
|
||||
show_crud={false}
|
||||
display_inline={false}
|
||||
display_inline={true}
|
||||
display_block_edit={true}
|
||||
textarea_rows={15}
|
||||
class_li={''}
|
||||
on:ae_crud_updated={e => {
|
||||
console.log(`ae_crud_updated:`, e.detail);
|
||||
|
||||
events_func.handle_load_ae_obj_id__event_presentation({api_cfg: $ae_api, event_presentation_id: event_presentation_obj.event_presentation_id_random, log_lvl: 1});
|
||||
}}
|
||||
>
|
||||
{#if event_presentation_obj.description}
|
||||
<strong class="text-sm">
|
||||
|
||||
Reference in New Issue
Block a user