Fix 500 error, add Address/Contact placeholders, and enhance Person activity view
- Fixed broken import path in /core dashboard - Simplified core layout data requirements to prevent crashes - Implemented V3 CRUD and Dexie tables for Addresses and Contacts - Created placeholder management pages for /core/addresses and /core/contacts - Added 'Linked Activity & Content' section to Person detail page to show related events and posts
This commit is contained in:
79
src/lib/ae_core/ae_core__address.ts
Normal file
79
src/lib/ae_core/ae_core__address.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { api } from '$lib/api/api';
|
||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||
import { db_core } from '$lib/ae_core/db_core';
|
||||
|
||||
const ae_promises: key_val = {};
|
||||
|
||||
export interface Address {
|
||||
id: string;
|
||||
address_id: string;
|
||||
address_id_random: string;
|
||||
account_id: string;
|
||||
account_id_random: string;
|
||||
|
||||
for_type?: string;
|
||||
for_id?: string;
|
||||
for_id_random?: string;
|
||||
|
||||
city: string;
|
||||
state_province: string;
|
||||
country: 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;
|
||||
}
|
||||
|
||||
export async function load_ae_obj_li__address({
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
for_obj_type?: string;
|
||||
for_obj_id?: string;
|
||||
enabled?: 'all' | 'enabled' | 'not_enabled';
|
||||
hidden?: 'all' | 'hidden' | 'not_hidden';
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
ae_promises.load__address_obj_li = await api.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'address',
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled,
|
||||
hidden,
|
||||
log_lvl
|
||||
}).then(async (result) => {
|
||||
if (result && Array.isArray(result)) {
|
||||
const processed = await process_ae_obj__address_props({ obj_li: result, log_lvl });
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'address',
|
||||
obj_li: processed,
|
||||
properties_to_save: ['id', 'address_id', 'address_id_random', 'city', 'state_province', 'country', 'enable'],
|
||||
log_lvl
|
||||
});
|
||||
return result;
|
||||
}
|
||||
return [];
|
||||
});
|
||||
return ae_promises.load__address_obj_li;
|
||||
}
|
||||
|
||||
export async function process_ae_obj__address_props({ obj_li, log_lvl = 0 }: { obj_li: any[], log_lvl?: number }) {
|
||||
return obj_li.map(obj => {
|
||||
const new_obj = { ...obj };
|
||||
new_obj.id = obj.address_id_random;
|
||||
return new_obj;
|
||||
});
|
||||
}
|
||||
79
src/lib/ae_core/ae_core__contact.ts
Normal file
79
src/lib/ae_core/ae_core__contact.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { api } from '$lib/api/api';
|
||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||
import { db_core } from '$lib/ae_core/db_core';
|
||||
|
||||
const ae_promises: key_val = {};
|
||||
|
||||
export interface Contact {
|
||||
id: string;
|
||||
contact_id: string;
|
||||
contact_id_random: string;
|
||||
account_id: string;
|
||||
account_id_random: string;
|
||||
|
||||
for_type?: string;
|
||||
for_id?: string;
|
||||
for_id_random?: string;
|
||||
|
||||
name: string;
|
||||
email: string;
|
||||
phone: 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;
|
||||
}
|
||||
|
||||
export async function load_ae_obj_li__contact({
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
for_obj_type?: string;
|
||||
for_obj_id?: string;
|
||||
enabled?: 'all' | 'enabled' | 'not_enabled';
|
||||
hidden?: 'all' | 'hidden' | 'not_hidden';
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
ae_promises.load__contact_obj_li = await api.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'contact',
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled,
|
||||
hidden,
|
||||
log_lvl
|
||||
}).then(async (result) => {
|
||||
if (result && Array.isArray(result)) {
|
||||
const processed = await process_ae_obj__contact_props({ obj_li: result, log_lvl });
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'contact',
|
||||
obj_li: processed,
|
||||
properties_to_save: ['id', 'contact_id', 'contact_id_random', 'name', 'email', 'phone', 'enable'],
|
||||
log_lvl
|
||||
});
|
||||
return result;
|
||||
}
|
||||
return [];
|
||||
});
|
||||
return ae_promises.load__contact_obj_li;
|
||||
}
|
||||
|
||||
export async function process_ae_obj__contact_props({ obj_li, log_lvl = 0 }: { obj_li: any[], log_lvl?: number }) {
|
||||
return obj_li.map(obj => {
|
||||
const new_obj = { ...obj };
|
||||
new_obj.id = obj.contact_id_random;
|
||||
return new_obj;
|
||||
});
|
||||
}
|
||||
@@ -173,6 +173,8 @@ export class MySubClassedDexie extends Dexie {
|
||||
account!: Table<any>;
|
||||
site!: Table<any>;
|
||||
site_domain!: Table<any>;
|
||||
address!: Table<any>;
|
||||
contact!: Table<any>;
|
||||
|
||||
constructor() {
|
||||
super('ae_core_db');
|
||||
@@ -219,6 +221,20 @@ export class MySubClassedDexie extends Dexie {
|
||||
id, site_domain_id, site_domain_id_random,
|
||||
site_id, site_id_random,
|
||||
domain,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
|
||||
address: `
|
||||
id, address_id, address_id_random,
|
||||
account_id, account_id_random,
|
||||
for_type, for_id, for_id_random,
|
||||
city, state_province, country,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
|
||||
contact: `
|
||||
id, contact_id, contact_id_random,
|
||||
account_id, account_id_random,
|
||||
for_type, for_id, for_id_random,
|
||||
name, email, phone,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user