diff --git a/src/Backend/SolutionErp.Application/Permissions/Queries/GetMyMenuTree/GetMyMenuTreeQuery.cs b/src/Backend/SolutionErp.Application/Permissions/Queries/GetMyMenuTree/GetMyMenuTreeQuery.cs index 278ac28..e3c2099 100644 --- a/src/Backend/SolutionErp.Application/Permissions/Queries/GetMyMenuTree/GetMyMenuTreeQuery.cs +++ b/src/Backend/SolutionErp.Application/Permissions/Queries/GetMyMenuTree/GetMyMenuTreeQuery.cs @@ -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 contractsFlags = GetFlags(MenuKeys.Contracts); + var workflowsFlags = GetFlags(MenuKeys.Workflows); + var peFlags = GetFlags(MenuKeys.PurchaseEvaluations); + var peWorkflowsFlags = GetFlags(MenuKeys.PeWorkflows); List 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.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,