[CLAUDE] FE-Admin+Domain+Infra+App: Workflows tab → sidebar menu items
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m37s
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m37s
User request: 7 tab trong /system/workflows thành menu items riêng. Domain: - MenuKeys.WorkflowTypeLeaf(code) helper — `Wf_<TypeCode>` pattern Infrastructure (DbInitializer): - Seed 7 leaves dưới Workflows group (order 95..101), label matches ContractType (HĐ Thầu phụ / Giao khoán / NCC / Dịch vụ / Mua bán / Nguyên tắc NCC / Nguyên tắc Dịch vụ). Idempotent. Application (GetMyMenuTreeQuery): - Generalized inherit-perm logic: descendants of Contracts AND Workflows inherit parent CanRead flag. Single Workflows.Read grant → all 7 Wf_* leaves visible; no per-leaf permission rows needed. FE Layout (admin): - resolvePath: Wf_<Code> → /system/workflows/<code>. Ct_* still hidden on admin side. FE App.tsx: - New route /system/workflows/:typeCode? FE WorkflowsPage: - Removed horizontal tab bar; type selection now comes từ URL param. - Landing view (no param): 3-col grid card per type với active version badge — so admin có visual overview khi click top-level Workflows group without selecting a type. - TYPE_CODE_TO_INT map drives URL→int conversion. Result: click `Quy trình HĐ > HĐ Mua bán` trong sidebar → opens /system/workflows/MuaBan directly với designer scoped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -46,31 +46,38 @@ public class GetMyMenuTreeQueryHandler(
|
||||
Update: g.Any(p => p.CanUpdate),
|
||||
Delete: g.Any(p => p.CanDelete)));
|
||||
|
||||
// Build tree. Children of `Contracts` (type submenu) inherit parent's
|
||||
// permission so we don't need per-subitem permission rows. This keeps
|
||||
// the permission matrix clean while allowing deep menu structures for
|
||||
// pure navigation.
|
||||
var (contractsRead, contractsCreate, contractsUpdate, contractsDelete) =
|
||||
resolved.TryGetValue(MenuKeys.Contracts, out var cf) ? cf : (false, false, false, false);
|
||||
// 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).
|
||||
(bool Read, bool Create, bool Update, bool Delete) GetFlags(string key) =>
|
||||
resolved.TryGetValue(key, out var f) ? f : (false, false, false, false);
|
||||
|
||||
List<MenuNodeDto> BuildChildren(string? parentKey, bool inheritContractsPerm) => menus
|
||||
var contractsFlags = GetFlags(MenuKeys.Contracts);
|
||||
var workflowsFlags = GetFlags(MenuKeys.Workflows);
|
||||
|
||||
List<MenuNodeDto> BuildChildren(string? parentKey, string? inheritFromKey) => menus
|
||||
.Where(m => m.ParentKey == parentKey)
|
||||
.Select(m =>
|
||||
{
|
||||
var flags = resolved.TryGetValue(m.Key, out var f) ? f : (false, false, false, false);
|
||||
// If this node is a descendant of Contracts and has no explicit
|
||||
// perms, take parent Contracts perms.
|
||||
if (inheritContractsPerm && !resolved.ContainsKey(m.Key))
|
||||
flags = (contractsRead, contractsCreate, contractsUpdate, contractsDelete);
|
||||
if (inheritFromKey is not null && !resolved.ContainsKey(m.Key))
|
||||
{
|
||||
flags = inheritFromKey == MenuKeys.Contracts ? contractsFlags : workflowsFlags;
|
||||
}
|
||||
|
||||
// Propagate inheritance downward from Contracts/Workflows roots
|
||||
var nextInherit = inheritFromKey
|
||||
?? (m.Key == MenuKeys.Contracts ? MenuKeys.Contracts
|
||||
: m.Key == MenuKeys.Workflows ? MenuKeys.Workflows
|
||||
: null);
|
||||
|
||||
var childInherits = inheritContractsPerm || m.Key == MenuKeys.Contracts;
|
||||
return new MenuNodeDto(m.Key, m.Label, m.ParentKey, m.Order, m.Icon,
|
||||
flags.Item1, flags.Item2, flags.Item3, flags.Item4,
|
||||
BuildChildren(m.Key, childInherits));
|
||||
BuildChildren(m.Key, nextInherit));
|
||||
})
|
||||
.ToList();
|
||||
|
||||
var tree = BuildChildren(null, inheritContractsPerm: false);
|
||||
var tree = BuildChildren(null, inheritFromKey: null);
|
||||
|
||||
// Filter: chỉ trả về node có CanRead=true (hoặc có child CanRead=true)
|
||||
static bool HasAccess(MenuNodeDto n) => n.CanRead || n.Children.Any(HasAccess);
|
||||
|
||||
@ -31,6 +31,10 @@ public static class MenuKeys
|
||||
public static string ContractTypeCreate(string typeCode) => $"Ct_{typeCode}_Create";
|
||||
public static string ContractTypePending(string typeCode) => $"Ct_{typeCode}_Pending";
|
||||
|
||||
// Workflow admin per ContractType — sub-menu dưới `Workflows`, click leaf
|
||||
// → mở /system/workflows/{typeCode} (filter theo type thay vì tab).
|
||||
public static string WorkflowTypeLeaf(string typeCode) => $"Wf_{typeCode}";
|
||||
|
||||
public static readonly string[] All =
|
||||
[
|
||||
Dashboard,
|
||||
|
||||
@ -207,6 +207,15 @@ public static class DbInitializer
|
||||
tree.Add((MenuKeys.ContractTypePending(code),"Duyệt", MenuKeys.ContractTypeGroup(code), order++, "CheckCircle2"));
|
||||
}
|
||||
|
||||
// Per-type workflow admin leaves dưới `Workflows` — mỗi loại là 1
|
||||
// menu item, click vào → mở designer scoped cho loại đó.
|
||||
var wfOrder = 95;
|
||||
foreach (var code in MenuKeys.ContractTypeCodes)
|
||||
{
|
||||
var label = typeLabels.GetValueOrDefault(code, code);
|
||||
tree.Add((MenuKeys.WorkflowTypeLeaf(code), label, MenuKeys.Workflows, wfOrder++, "FileText"));
|
||||
}
|
||||
|
||||
var existingKeys = await db.MenuItems.Select(m => m.Key).ToListAsync();
|
||||
var added = 0;
|
||||
foreach (var (key, label, parent, o, icon) in tree)
|
||||
|
||||
Reference in New Issue
Block a user