Work on new core person list, view, and edit
This commit is contained in:
194
src/routes/core/person/[slug]/+page.svelte
Normal file
194
src/routes/core/person/[slug]/+page.svelte
Normal file
@@ -0,0 +1,194 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data: any;
|
||||
|
||||
// Imports
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils';
|
||||
// import { api } from '$lib/api';
|
||||
// import Element_ae_crud from '$lib/element_ae_crud.svelte';
|
||||
import Element_data_store from '$lib/element_data_store.svelte';
|
||||
// import Comp_event_session_obj_li from './ae_comp__event_session_obj_li.svelte';
|
||||
|
||||
import { liveQuery } from "dexie";
|
||||
// import { core_func } from '$lib/ae_core_functions';
|
||||
import { db_core } from "$lib/db_core";
|
||||
// import { db_events } from "$lib/db_events";
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
// import { events_loc, events_sess, slct, events_trigger } from '$lib/ae_events_stores';
|
||||
// import { events_func } from '$lib/ae_events_functions';
|
||||
|
||||
// import Form_agree from './../../form_agree.svelte';
|
||||
import Person_view from './../../person_view.svelte';
|
||||
|
||||
// Exports
|
||||
// export let display_mode: string = 'default'; // 'default', 'compact', 'minimal', 'launcher'
|
||||
|
||||
// Variables
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
$slct.account_id = data.account_id;
|
||||
// console.log(`$slct.account_id = `, $slct.account_id);
|
||||
let ae_acct = data[$slct.account_id];
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
$ae_loc.url_origin = data.url.origin;
|
||||
|
||||
$slct.person_id = ae_acct.slct.person_id;
|
||||
$slct.person_obj = ae_acct.slct.person_obj;
|
||||
|
||||
$ae_sess.person.show_edit__person = false;
|
||||
|
||||
let lq__person_obj = liveQuery(
|
||||
() => db_core.person.get($slct.person_id)
|
||||
);
|
||||
$slct.lq__person_obj = lq__person_obj;
|
||||
|
||||
if (!$ae_loc.person) {
|
||||
$ae_loc.person = {};
|
||||
}
|
||||
$ae_loc.person.show_content__person_page_help = false;
|
||||
|
||||
// Functions and Logic
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>
|
||||
Person: {ae_util.shorten_string({ string: $lq__person_obj?.full_name, max_length: 20, begin_length: 10, end_length: 4 })}
|
||||
({$lq__person_obj?.person_id ?? 'loading...'}) - Core - {$ae_loc?.title}
|
||||
</title>
|
||||
</svelte:head>
|
||||
|
||||
|
||||
<section
|
||||
class="ae_core__person md:container h-full mx-auto flex flex-col space-y-4 pt-0 pb-8"
|
||||
>
|
||||
|
||||
<div
|
||||
class="core__person_view_menu {ae_snip.classes__core_menu}"
|
||||
class:border-none={!$ae_loc.person.show_content__person_page_help}
|
||||
>
|
||||
|
||||
<div>
|
||||
<a href="/core" class="{ae_snip.classes__core_menu__button}">
|
||||
<span class="fas fa-arrow-left mx-1"></span>
|
||||
Back to Core
|
||||
</a>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$ae_loc.person.show_content__person_page_help = !$ae_loc.person.show_content__person_page_help;
|
||||
}}
|
||||
class="{ae_snip.classes__core_menu__button}"
|
||||
title="Help and information about the session search"
|
||||
>
|
||||
<span class="fas fa-question-circle mx-1"></span>
|
||||
{#if $ae_loc.person.show_content__person_page_help}
|
||||
Hide
|
||||
{:else}
|
||||
Show
|
||||
{/if}
|
||||
Help?
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<Element_data_store
|
||||
ds_code="events__core__person_page_help"
|
||||
ds_name="Default: Core - Person Page Help"
|
||||
ds_type="html"
|
||||
for_type="event"
|
||||
for_id={$slct.event_id}
|
||||
class_li="bg-yellow-100 p-2 rounded-md border border-yellow-200"
|
||||
show_edit={false}
|
||||
show_edit_btn={true}
|
||||
hide={!$ae_loc.person.show_content__person_page_help}
|
||||
/>
|
||||
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$ae_loc.person.show_content__person_page_help = !$ae_loc.person.show_content__person_page_help;
|
||||
}}
|
||||
class="btn btn-sm mx-1 variant-ghost-error hover:variant-filled-error"
|
||||
class:hidden={!$ae_loc.person.show_content__person_page_help}
|
||||
title="Help and information about the session search"
|
||||
>
|
||||
<span class="fas fa-question-circle mx-1"></span>
|
||||
{#if $ae_loc.person.show_content__person_page_help}
|
||||
Hide
|
||||
{:else}
|
||||
Show
|
||||
{/if}
|
||||
Help?
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if !$lq__person_obj}
|
||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||
<span>Loading...</span>
|
||||
{:else}
|
||||
<!-- {$lq__person_obj?.full_name} -->
|
||||
{/if}
|
||||
|
||||
<!-- <hr class="w-full border border-gray-200" /> -->
|
||||
|
||||
<!-- {#await $slct.person_obj}
|
||||
<span class="fas fa-spinner fa-spin text-xl text-blue-500"></span>
|
||||
{:then result} -->
|
||||
<Person_view
|
||||
person_id={$slct.person_id}
|
||||
/>
|
||||
<!-- {:catch error}
|
||||
<div class="text-red-800">
|
||||
<span class="fas fa-exclamation-triangle text-xl"></span>
|
||||
<span>Error: {error.message}</span>
|
||||
</div>
|
||||
{/await} -->
|
||||
|
||||
<!-- {$slct.person_id ?? 'Unknown ID'} -->
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<style lang="postcss">
|
||||
/* Use the div.ae_quick_modal_container to block background clicks when using the section.ae_quick_popover. */
|
||||
div.ae_quick_modal_container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 100;
|
||||
background-color: hsla(0, 0%, 50%, .75);
|
||||
/* padding: 1rem; */
|
||||
/* border: solid thick red; */
|
||||
}
|
||||
|
||||
/* The section.ae_quick_popover should be above the rest of the content and centered on the page. */
|
||||
section.ae_quick_popover {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 100;
|
||||
background-color: hsla(0, 0%, 97%, .97);
|
||||
/* margin-top: 1rem;
|
||||
margin-bottom: 2rem; */
|
||||
/* padding: 1rem;
|
||||
padding-top:4rem; */
|
||||
/* padding-bottom: 4rem; */
|
||||
border: solid thin hsla(0, 0%, 0%, .9);
|
||||
border-radius: .5rem;
|
||||
box-shadow: 0 0 1rem hsla(0, 0%, 0%, .5);
|
||||
|
||||
min-height: 30%;
|
||||
/* max-height: 100vh; */
|
||||
min-width: 80%;
|
||||
|
||||
/* overflow-y: auto; */
|
||||
}
|
||||
</style>
|
||||
53
src/routes/core/person/[slug]/+page.ts
Normal file
53
src/routes/core/person/[slug]/+page.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/** @type {import('./$types').PageLoad} */
|
||||
console.log(`ae_p_person [slug] +page.ts: start`);
|
||||
|
||||
import { core_func } from '$lib/ae_core_functions';
|
||||
|
||||
export async function load({ parent }) { // route
|
||||
let log_lvl = 0;
|
||||
// console.log(`ae_events_pres_mgmt_event +page.ts data.params:`, params);
|
||||
// console.log(`ae_events_pres_mgmt_event +page.ts data.route:`, route);
|
||||
// console.log(`ae_events_pres_mgmt_event +page.ts data.url:`, url);
|
||||
|
||||
let data = await parent();
|
||||
// console.log(`ae_events_pres_mgmt_event +page.ts data:`, data);
|
||||
data.log_lvl = log_lvl;
|
||||
let account_id = data.account_id;
|
||||
let ae_acct = data[account_id];
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
let person_id = data.params.slug;
|
||||
if (!person_id) {
|
||||
console.log(`ae_p_person [slug] +page.ts: The person_id was not found in the data.params.slug!!!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
ae_acct.slct.person_id = person_id;
|
||||
|
||||
let load_person_obj = core_func.handle_load_ae_obj_id__person({api_cfg: ae_acct.api, person_id: person_id, try_cache: false});
|
||||
|
||||
ae_acct.slct.person_obj = await load_person_obj;
|
||||
|
||||
// let load_event_file_obj_li = await core_func.handle_load_ae_obj_li__event_file({
|
||||
// api_cfg: ae_acct.api,
|
||||
// for_obj_type: 'person',
|
||||
// for_obj_id: person_id,
|
||||
// params: {enabled: 'all', qry__limit: 50},
|
||||
// try_cache: false
|
||||
// })
|
||||
// .then((event_file_obj_li) => {
|
||||
// if (log_lvl) {
|
||||
// console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
// }
|
||||
// return event_file_obj_li;
|
||||
// });
|
||||
// if (log_lvl) {
|
||||
// console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
// }
|
||||
// ae_acct.slct.event_file_obj_li = load_event_file_obj_li;
|
||||
|
||||
// WARNING: Precaution against shared data between sites and presentations.
|
||||
data[account_id] = ae_acct;
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user