[CLAUDE] App: menu tree inheritance mo rong Pe_* + PeWf_*
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m54s
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m54s
GetMyMenuTreeQuery truoc chi inherit Contracts (Ct_*) va Workflows (Wf_*). Extend 2 root moi PurchaseEvaluations (Pe_*) + PeWorkflows (PeWf_*) de admin co PurchaseEvaluations.Read auto thay 2 group Pe_* + 6 leaf (Danh sach/Thao tac/Duyet x 2 type) + 2 PeWf_* leaf admin designer UI, khong can add per-subitem permission row. Verify bug: /menus/me cho admin hien chi root 'PurchaseEvaluations' + 'PeWorkflows' nhung khong co Pe_DuyetNcc group / Pe_DuyetNccPhuongAn group children du DB co 12 row (sqlcmd confirm). Root cause: hardcoded 2 inherit roots trong BuildChildren switch. Fix: expand switch cover 4 inherit roots. Propagate nextInherit xuong tat ca descendants.
This commit is contained in:
@ -48,12 +48,15 @@ public class GetMyMenuTreeQueryHandler(
|
||||
|
||||
// Build tree. Descendants of certain roots inherit parent perms so
|
||||
// we don't add per-subitem permission rows for pure-navigation menus.
|
||||
// Keys: `Contracts` (Ct_* subitems) and `Workflows` (Wf_* subitems).
|
||||
// Inherit roots: Contracts (Ct_*), Workflows (Wf_*), PurchaseEvaluations
|
||||
// (Pe_*), PeWorkflows (PeWf_*).
|
||||
(bool Read, bool Create, bool Update, bool Delete) GetFlags(string key) =>
|
||||
resolved.TryGetValue(key, out var f) ? f : (false, false, false, false);
|
||||
|
||||
var contractsFlags = GetFlags(MenuKeys.Contracts);
|
||||
var workflowsFlags = GetFlags(MenuKeys.Workflows);
|
||||
var peFlags = GetFlags(MenuKeys.PurchaseEvaluations);
|
||||
var peWorkflowsFlags = GetFlags(MenuKeys.PeWorkflows);
|
||||
|
||||
List<MenuNodeDto> BuildChildren(string? parentKey, string? inheritFromKey) => menus
|
||||
.Where(m => m.ParentKey == parentKey)
|
||||
@ -62,13 +65,22 @@ public class GetMyMenuTreeQueryHandler(
|
||||
var flags = resolved.TryGetValue(m.Key, out var f) ? f : (false, false, false, false);
|
||||
if (inheritFromKey is not null && !resolved.ContainsKey(m.Key))
|
||||
{
|
||||
flags = inheritFromKey == MenuKeys.Contracts ? contractsFlags : workflowsFlags;
|
||||
flags = inheritFromKey switch
|
||||
{
|
||||
var k when k == MenuKeys.Contracts => contractsFlags,
|
||||
var k when k == MenuKeys.Workflows => workflowsFlags,
|
||||
var k when k == MenuKeys.PurchaseEvaluations => peFlags,
|
||||
var k when k == MenuKeys.PeWorkflows => peWorkflowsFlags,
|
||||
_ => flags,
|
||||
};
|
||||
}
|
||||
|
||||
// Propagate inheritance downward from Contracts/Workflows roots
|
||||
// Propagate inheritance downward from 4 inherit roots
|
||||
var nextInherit = inheritFromKey
|
||||
?? (m.Key == MenuKeys.Contracts ? MenuKeys.Contracts
|
||||
: m.Key == MenuKeys.Workflows ? MenuKeys.Workflows
|
||||
: m.Key == MenuKeys.PurchaseEvaluations ? MenuKeys.PurchaseEvaluations
|
||||
: m.Key == MenuKeys.PeWorkflows ? MenuKeys.PeWorkflows
|
||||
: null);
|
||||
|
||||
return new MenuNodeDto(m.Key, m.Label, m.ParentKey, m.Order, m.Icon,
|
||||
|
||||
Reference in New Issue
Block a user