Work on new core person list, view, and edit
This commit is contained in:
@@ -6,6 +6,112 @@ import { db_core } from "$lib/db_core";
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_load_ae_obj_id__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
try_cache=false,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__person() *** person_id=${person_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__person_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_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
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_get_result) {
|
||||
if (person_obj_get_result) {
|
||||
// This is expecting a list
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: [person_obj_get_result]});
|
||||
return person_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__person_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_load_ae_obj_li__person(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__person() *** account_id=${account_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 ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__person_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: account_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: {'given_name': 'ASC', 'family_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_li_get_result) {
|
||||
if (person_obj_li_get_result) {
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: person_obj_li_get_result});
|
||||
return person_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__person_obj_li:', ae_promises.load__person_obj_li);
|
||||
return ae_promises.load__person_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-24
|
||||
export async function handle_create_ae_obj__person(
|
||||
{
|
||||
@@ -59,6 +165,57 @@ export async function handle_create_ae_obj__person(
|
||||
return ae_promises.create__person;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_update_ae_obj__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_update_ae_obj__person() *** person_id=${person_id}`);
|
||||
|
||||
ae_promises.update__person_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_update_result) {
|
||||
if (person_obj_update_result) {
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: [person_obj_update_result]});
|
||||
return person_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__person_obj:', ae_promises.update__person_obj);
|
||||
}
|
||||
return ae_promises.update__person_obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
export function handle_db_save_ae_obj_li__person(
|
||||
{
|
||||
@@ -83,9 +240,11 @@ export function handle_db_save_ae_obj_li__person(
|
||||
person_id_random: obj.person_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
external_sys_id: obj.external_sys_id,
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon...
|
||||
@@ -129,6 +288,13 @@ export function handle_db_save_ae_obj_li__person(
|
||||
|
||||
// From SQL view
|
||||
username: obj.username,
|
||||
user_name: obj.user_name,
|
||||
user_email: obj.user_email,
|
||||
user_allow_auth_key: obj.user_allow_auth_key, // For sign in without password
|
||||
user_super: obj.user_super,
|
||||
user_manager: obj.user_manager,
|
||||
user_administrator: obj.user_administrator,
|
||||
user_public: obj.user_public,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.person_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -4,8 +4,8 @@ import { api } from '$lib/api';
|
||||
|
||||
|
||||
import {
|
||||
// handle_load_ae_obj_id__person,
|
||||
// handle_load_ae_obj_li__person,
|
||||
handle_load_ae_obj_id__person,
|
||||
handle_load_ae_obj_li__person,
|
||||
handle_create_ae_obj__person,
|
||||
// handle_update_ae_obj__person,
|
||||
// handle_db_save_ae_obj_li__person
|
||||
@@ -234,70 +234,6 @@ async function handle_load_ae_obj_code__data_store(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Updated 2024-05-24
|
||||
async function handle_load_ae_obj_li__person(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__person() *** account_id=${account_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 ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__person_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: account_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: {'given_name': 'ASC', 'family_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_li_get_result) {
|
||||
if (person_obj_li_get_result) {
|
||||
// handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: person_obj_li_get_result});
|
||||
return person_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__person_obj_li:', ae_promises.load__person_obj_li);
|
||||
return ae_promises.load__person_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-03-27
|
||||
async function handle_update_ae_obj_id_crud(
|
||||
{
|
||||
@@ -432,6 +368,7 @@ async function handle_download_export__obj_type(
|
||||
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_load_ae_obj_id__person: handle_load_ae_obj_id__person,
|
||||
handle_load_ae_obj_li__person: handle_load_ae_obj_li__person,
|
||||
handle_create_ae_obj__person: handle_create_ae_obj__person,
|
||||
handle_update_ae_obj_id_crud: handle_update_ae_obj_id_crud,
|
||||
|
||||
@@ -161,6 +161,10 @@ export let ae_app_local_data_struct: key_val = {
|
||||
|
||||
'testing': {},
|
||||
},
|
||||
|
||||
'person': {
|
||||
show_content__person_page_help: false,
|
||||
},
|
||||
}
|
||||
// console.log(`AE Stores - App Local Storage Data:`, ae_app_local_data_struct);
|
||||
|
||||
@@ -211,6 +215,11 @@ export let ae_app_session_data_struct: key_val = {
|
||||
'testing': {},
|
||||
},
|
||||
|
||||
'person': {
|
||||
show_report__person_li: false,
|
||||
},
|
||||
|
||||
|
||||
'download': {},
|
||||
// For API download and upload progress status per file.
|
||||
'api_download_kv': {},
|
||||
|
||||
@@ -9,6 +9,12 @@ string_snippets['html__not_set'] = `
|
||||
</span>
|
||||
`;
|
||||
|
||||
string_snippets['classes__core_menu'] = 'flex flex-col items-center space-y-1 border border-blue-200 rounded-md py-1 px-2 hover:bg-blue-100';
|
||||
|
||||
string_snippets['classes__core_menu__button'] = 'btn btn-sm mx-1 variant-soft-tertiary text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__core_menu__button_highlight'] = 'btn btn-sm mx-1 variant-filled-tertiary text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__core_menu__button_warning'] = 'btn btn-sm mx-1 variant-soft-warning text-info-300 hover:text-info-800';
|
||||
|
||||
string_snippets['classes__events_pres_mgmt_menu'] = 'flex flex-col items-center space-y-1 border border-blue-200 rounded-md py-1 px-2 hover:bg-blue-100';
|
||||
|
||||
string_snippets['classes__events_pres_mgmt_menu__button'] = 'btn btn-sm mx-1 variant-soft-tertiary text-info-300 hover:text-info-800';
|
||||
|
||||
@@ -3,18 +3,19 @@ import Dexie, { type Table } from 'dexie';
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
// Updated 2024-06-10
|
||||
// Updated 2024-07-17
|
||||
export interface Person {
|
||||
id: string;
|
||||
// id_random: string;
|
||||
person_id: string;
|
||||
person_id_random?: string;
|
||||
person_id_random: string;
|
||||
|
||||
external_id?: string;
|
||||
external_sys_id?: string; // Generated by an external system
|
||||
code?: string;
|
||||
|
||||
account_id: string;
|
||||
account_id_random?: string;
|
||||
account_id?: string; // Technically this is not required for global users.
|
||||
account_id_random?: string; // Technically this is not required for global users.
|
||||
|
||||
person_profile_id?: null|string;
|
||||
person_profile_id_random?: null|string; // The new table person_profile will be used soon...
|
||||
@@ -57,7 +58,14 @@ export interface Person {
|
||||
updated_on?: null|Date;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
username?: null|string;
|
||||
username?: string;
|
||||
user_name?: null|string;
|
||||
user_email?: null|string;
|
||||
user_allow_auth_key?: null|boolean; // For sign in without password
|
||||
user_super?: boolean;
|
||||
user_manager?: boolean;
|
||||
user_administrator?: boolean;
|
||||
user_public?: boolean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user