Stabilized hierarchical permissions and implemented strict visibility gating.
Standardized access level hierarchy (super > manager > administrator > trusted) and added hierarchical comparison utilities to 'ae_util'. Refactored IDAA layout to use an 'Upgrade-Only' permission strategy, preventing context-specific identifications from downgrading global Manager privileges. Implemented strict gated filtering in the Journal Entry list: hidden and disabled items now correctly require both the appropriate hierarchical role (Trusted/Admin) AND active Edit Mode.
This commit is contained in:
@@ -286,11 +286,11 @@ async function _refresh_journal_li_background({
|
||||
let promise;
|
||||
if (qry_person_id) {
|
||||
const search_query: any = {
|
||||
and: [{ field: 'person_id_random', op: 'eq', value: qry_person_id }]
|
||||
and: [{ field: 'person_id', op: 'eq', value: qry_person_id }]
|
||||
};
|
||||
if (for_obj_id)
|
||||
search_query.and.push({
|
||||
field: `${for_obj_type}_id_random`,
|
||||
field: `${for_obj_type}_id`,
|
||||
op: 'eq',
|
||||
value: for_obj_id
|
||||
});
|
||||
@@ -344,7 +344,7 @@ async function _refresh_journal_li_background({
|
||||
load_ae_obj_li__journal_entry({
|
||||
api_cfg,
|
||||
for_obj_type: 'journal',
|
||||
for_obj_id: journal.journal_id_random,
|
||||
for_obj_id: journal.journal_id,
|
||||
enabled,
|
||||
hidden,
|
||||
limit,
|
||||
@@ -396,7 +396,7 @@ export async function create_ae_obj__journal({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
account_id: account_id,
|
||||
...data_kv
|
||||
},
|
||||
params: params,
|
||||
@@ -613,7 +613,7 @@ export async function qry__journal({
|
||||
if (journal_id) {
|
||||
// Assuming journal_id here is actually the account_id as per original usage context
|
||||
search_query.and.push({
|
||||
field: 'account_id_random',
|
||||
field: 'account_id',
|
||||
op: 'eq',
|
||||
value: journal_id
|
||||
});
|
||||
@@ -797,7 +797,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
@@ -805,7 +804,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
const randomIdKey = `${obj_type}_id`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
@@ -396,13 +396,13 @@ export async function qry__journal_entry({
|
||||
// Context scoping: Prefer journal_id if provided, otherwise fallback to person_id (global search)
|
||||
if (journal_id) {
|
||||
search_query.and.push({
|
||||
field: 'journal_id_random',
|
||||
field: 'journal_id',
|
||||
op: 'eq',
|
||||
value: journal_id
|
||||
});
|
||||
} else if (person_id) {
|
||||
search_query.and.push({
|
||||
field: 'person_id_random',
|
||||
field: 'person_id',
|
||||
op: 'eq',
|
||||
value: person_id
|
||||
});
|
||||
@@ -621,7 +621,7 @@ export async function update_ae_obj__journal_entry({
|
||||
// }
|
||||
|
||||
// if (obj_li && obj_li.length) {
|
||||
// // let obj_li_id = obj_li.map((obj: any) => obj.journal_entry_id_random);
|
||||
// // let obj_li_id = obj_li.map((obj: any) => obj.journal_entry_id);
|
||||
// const obj_li_id: string[] = [];
|
||||
|
||||
// for (const obj of obj_li) {
|
||||
@@ -785,7 +785,7 @@ export async function update_ae_obj__journal_entry({
|
||||
// try {
|
||||
// id_random = await db_journals.journal_entry.put(obj_record);
|
||||
// } catch (error) {
|
||||
// console.log(`Error: Failed to put ${obj.journal_entry_id_random}: ${error}`);
|
||||
// console.log(`Error: Failed to put ${obj.journal_entry_id}: ${error}`);
|
||||
// }
|
||||
// } else {
|
||||
// if (log_lvl) {
|
||||
@@ -926,7 +926,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
@@ -934,7 +933,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
const randomIdKey = `${obj_type}_id`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
@@ -982,7 +981,7 @@ export async function process_ae_obj__journal_entry_props({
|
||||
// Inject journal_id if provided and missing
|
||||
if (journal_id) {
|
||||
if (!obj.journal_id) obj.journal_id = journal_id;
|
||||
if (!obj.journal_id_random) obj.journal_id_random = journal_id;
|
||||
// if (!obj.journal_id_random) obj.journal_id_random = journal_id;
|
||||
}
|
||||
|
||||
// Content processing
|
||||
|
||||
@@ -39,11 +39,11 @@ export interface Journal extends ae_Journal {
|
||||
export const journal_field_li = [
|
||||
'id',
|
||||
'journal_id',
|
||||
'journal_id_random',
|
||||
// 'journal_id_random',
|
||||
'account_id',
|
||||
'account_id_random',
|
||||
// 'account_id_random',
|
||||
'person_id',
|
||||
'person_id_random',
|
||||
// 'person_id_random',
|
||||
'code',
|
||||
'name',
|
||||
'short_name',
|
||||
@@ -88,11 +88,11 @@ export interface Journal_Entry extends ae_JournalEntry {
|
||||
export const journal_entry_field_li = [
|
||||
'id',
|
||||
'journal_entry_id',
|
||||
'journal_entry_id_random',
|
||||
// 'journal_entry_id_random',
|
||||
'journal_id',
|
||||
'journal_id_random',
|
||||
// 'journal_id_random',
|
||||
'person_id',
|
||||
'person_id_random',
|
||||
// 'person_id_random',
|
||||
'code',
|
||||
'name',
|
||||
'short_name',
|
||||
@@ -122,16 +122,16 @@ export class MySubClassedDexie extends Dexie {
|
||||
super('ae_journals_db');
|
||||
this.version(5).stores({
|
||||
journal: `
|
||||
id, journal_id, journal_id_random,
|
||||
id, journal_id,
|
||||
code,
|
||||
account_id, account_id_random,
|
||||
person_id, person_id_random,
|
||||
account_id,
|
||||
person_id,
|
||||
name,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
journal_entry: `
|
||||
id, journal_entry_id, journal_entry_id_random,
|
||||
journal_id, journal_id_random,
|
||||
person_id, person_id_random,
|
||||
id, journal_entry_id,
|
||||
journal_id,
|
||||
person_id,
|
||||
code,
|
||||
template,
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user