feat: application shell, localized texts and user preferences (M3, part 1)
The pages built so far now live inside the shell of the mockups instead of the M0 placeholder, every interface text comes from Resources/it-IT, and each user keeps their own look and start page. - Shell: top bar, collapsible side menu with fly-out sub-menus, status bar and tabs that keep each page alive (page type and route values per tab, so a tab never shows another page); at most 12 tabs, least-used clean tab evicted. - One shortcut table with Alt variants for the combinations browsers keep (Ctrl+W, Ctrl+Tab, Ctrl+N); command palette for pages and commands. - ITexts over embedded JSON; tests forbid literal texts in .razor components and check that every key used exists. - User settings in sys_user_settings / user_settings; theme written on the server; profile page with live preview, start page, sessions and shortcuts. - Home, coming-soon pages for later milestones, localized sign-in and error pages; ADR 0020; wiki, CHANGELOG, STATUS and data model updated. Refs #25 #26 #31 #33 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c30054e3d
commit
cf6f849cc1
72 files changed
+5785
-259
No files matched your search
@@ -0,0 +1,128 @@
|
||||
using Khaemhat.Application.Modules;
|
||||
|
||||
namespace Khaemhat.Web.Shell;
|
||||
|
||||
/// <summary>Who may see a menu entry besides module and permission.</summary>
|
||||
public enum MenuAudience
|
||||
{
|
||||
/// <summary>Everybody with the module and the permission.</summary>
|
||||
Everyone = 0,
|
||||
|
||||
/// <summary>Only instance accounts (super user and administrators).</summary>
|
||||
InstanceAccounts = 1,
|
||||
}
|
||||
|
||||
/// <summary>An entry of the side menu (SPEC §10.2).</summary>
|
||||
/// <param name="Key">The text key of the label (<c>Shell.Menu.*</c>) and the identity of the entry.</param>
|
||||
/// <param name="Icon">The icon in <c>icons/sprite.svg</c>.</param>
|
||||
/// <param name="Href">The address.</param>
|
||||
/// <param name="Module">The licence module that must be active.</param>
|
||||
/// <param name="Permission">The permission needed, or <see langword="null"/>.</param>
|
||||
/// <param name="Milestone">The milestone that delivers the page, shown while it is not there yet (<c>M4</c>...); <see langword="null"/> once delivered.</param>
|
||||
/// <param name="Audience">Who may see it.</param>
|
||||
public sealed record MenuItem(string Key, string Icon, string Href, string Module, string? Permission, string? Milestone,
|
||||
MenuAudience Audience = MenuAudience.Everyone)
|
||||
{
|
||||
/// <summary>The sub-entries shown under the active module or in the pop-up of the collapsed menu.</summary>
|
||||
public IReadOnlyList<MenuItem> Children { get; init; } = [];
|
||||
|
||||
/// <summary>Whether an address belongs to this entry or to one of its children.</summary>
|
||||
/// <param name="path">The path, without query.</param>
|
||||
/// <returns><see langword="true"/> when it matches.</returns>
|
||||
public bool Matches(string path) =>
|
||||
Href == "/" ? path == "/" : path.Equals(Href, StringComparison.OrdinalIgnoreCase) || path.StartsWith(Href + "/", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>A titled group of the side menu.</summary>
|
||||
/// <param name="Key">The text key of the title.</param>
|
||||
/// <param name="Items">The entries.</param>
|
||||
public sealed record MenuSection(string Key, IReadOnlyList<MenuItem> Items);
|
||||
|
||||
/// <summary>
|
||||
/// The side menu of SPEC §10.2, in its order: Home; Anagrafiche, CRM, Vendite, Acquisti, Magazzino, Contabilità,
|
||||
/// Scadenzario, Fatturazione elettronica, Cespiti, Servizi, Canali e-commerce, Report; Tabelle azienda,
|
||||
/// Automazioni, Amministrazione. Entries appear only with the licensed module and the permission.
|
||||
/// </summary>
|
||||
public static class MenuCatalog
|
||||
{
|
||||
/// <summary>The sections.</summary>
|
||||
public static IReadOnlyList<MenuSection> Sections { get; } =
|
||||
[
|
||||
new("Shell.Menu.Section.Main",
|
||||
[
|
||||
new("Shell.Menu.Home", "home", "/", ModuleCodes.Core, null, null),
|
||||
]),
|
||||
new("Shell.Menu.Section.Operations",
|
||||
[
|
||||
Area("Shell.Menu.Parties", "users", "/anagrafiche", ModuleCodes.Core, "parties.party.read", "M4",
|
||||
("Shell.Menu.Parties.Customers", "clienti"), ("Shell.Menu.Parties.Suppliers", "fornitori"), ("Shell.Menu.Parties.Contacts", "contatti"),
|
||||
("Shell.Menu.Parties.Items", "articoli"), ("Shell.Menu.Parties.PriceLists", "listini"), ("Shell.Menu.Parties.Categories", "categorie")),
|
||||
Area("Shell.Menu.Crm", "target", "/crm", ModuleCodes.Crm, "crm.lead.read", "M11",
|
||||
("Shell.Menu.Crm.Dashboard", "cruscotto"), ("Shell.Menu.Crm.Leads", "lead"), ("Shell.Menu.Crm.Pipeline", "pipeline"),
|
||||
("Shell.Menu.Crm.Agenda", "agenda"), ("Shell.Menu.Crm.Tickets", "ticket"), ("Shell.Menu.Crm.Campaigns", "campagne")),
|
||||
Area("Shell.Menu.Sales", "cart", "/vendite", ModuleCodes.Core, "sales.invoice.read", "M5",
|
||||
("Shell.Menu.Sales.Quotes", "preventivi"), ("Shell.Menu.Sales.Orders", "ordini"), ("Shell.Menu.Sales.DeliveryNotes", "ddt"),
|
||||
("Shell.Menu.Sales.Invoices", "fatture"), ("Shell.Menu.Sales.CreditNotes", "note-credito")),
|
||||
Area("Shell.Menu.Purchases", "truck", "/acquisti", ModuleCodes.Core, "purchases.order.read", "M6",
|
||||
("Shell.Menu.Purchases.Orders", "ordini"), ("Shell.Menu.Purchases.Receipts", "ricevimenti"), ("Shell.Menu.Purchases.Invoices", "fatture")),
|
||||
Area("Shell.Menu.Inventory", "box", "/magazzino", ModuleCodes.Core, "inventory.stock.read", "M6",
|
||||
("Shell.Menu.Inventory.Stock", "giacenze"), ("Shell.Menu.Inventory.Entries", "movimenti"), ("Shell.Menu.Inventory.StockTake", "inventario"),
|
||||
("Shell.Menu.Inventory.Reorder", "riordino")),
|
||||
Area("Shell.Menu.Ledger", "book", "/contabilita", ModuleCodes.Accounting, "ledger.entry.read", "M7",
|
||||
("Shell.Menu.Ledger.Journal", "prima-nota"), ("Shell.Menu.Ledger.Accounts", "piano-dei-conti"), ("Shell.Menu.Ledger.VatRegisters", "registri-iva"),
|
||||
("Shell.Menu.Ledger.VatSettlement", "liquidazione-iva"), ("Shell.Menu.Ledger.Statements", "bilancio")),
|
||||
Area("Shell.Menu.Finance", "coins", "/scadenzario", ModuleCodes.Finance, "finance.schedule.read", "M9",
|
||||
("Shell.Menu.Finance.OpenItems", "scadenze"), ("Shell.Menu.Finance.Remittances", "distinte"), ("Shell.Menu.Finance.Dunning", "solleciti"),
|
||||
("Shell.Menu.Finance.Reconciliation", "riconciliazione")),
|
||||
Area("Shell.Menu.EInvoicing", "file-check", "/fatturazione-elettronica", ModuleCodes.EInvoicing, "einvoice.document.read", "M8",
|
||||
("Shell.Menu.EInvoicing.Dashboard", "cruscotto"), ("Shell.Menu.EInvoicing.Channels", "canali"), ("Shell.Menu.EInvoicing.StampDuty", "bollo"),
|
||||
("Shell.Menu.EInvoicing.IntentDeclarations", "dichiarazioni-intento")),
|
||||
Area("Shell.Menu.Assets", "building", "/cespiti", ModuleCodes.Assets, "assets.asset.read", "M10",
|
||||
("Shell.Menu.Assets.Register", "registro"), ("Shell.Menu.Assets.Depreciation", "ammortamenti")),
|
||||
Area("Shell.Menu.Services", "wrench", "/servizi", ModuleCodes.Services, null, "M12",
|
||||
("Shell.Menu.Services.Contracts", "contratti"), ("Shell.Menu.Services.Interventions", "interventi")),
|
||||
Area("Shell.Menu.Channels", "globe", "/canali", ModuleCodes.Channels, null, "M12",
|
||||
("Shell.Menu.Channels.Orders", "ordini")),
|
||||
Area("Shell.Menu.Reports", "chart", "/report", ModuleCodes.Reports, "reports.report.read", "M13"),
|
||||
]),
|
||||
new("Shell.Menu.Section.System",
|
||||
[
|
||||
Area("Shell.Menu.CompanyTables", "layers", "/tabelle", ModuleCodes.Core, "company.settings.read", "M4",
|
||||
("Shell.Menu.CompanyTables.Profile", "profilo-azienda"), ("Shell.Menu.CompanyTables.FiscalYears", "esercizi"),
|
||||
("Shell.Menu.CompanyTables.TaxCodes", "codici-iva"), ("Shell.Menu.CompanyTables.Payments", "pagamenti")),
|
||||
Area("Shell.Menu.Automation", "zap", "/automazioni", ModuleCodes.Automation, null, "M12",
|
||||
("Shell.Menu.Automation.Rules", "regole"), ("Shell.Menu.Automation.Procedures", "procedure")),
|
||||
Area("Shell.Menu.Admin", "shield", "/amministrazione", ModuleCodes.Core, null, "M13",
|
||||
MenuAudience.InstanceAccounts,
|
||||
("Shell.Menu.Admin.Companies", "aziende"), ("Shell.Menu.Admin.Users", "utenti"), ("Shell.Menu.Admin.Roles", "ruoli"),
|
||||
("Shell.Menu.Admin.Licenses", "licenze"), ("Shell.Menu.Admin.Jobs", "attivita"), ("Shell.Menu.Admin.Log", "log"),
|
||||
("Shell.Menu.Admin.Status", "stato")),
|
||||
]),
|
||||
];
|
||||
|
||||
/// <summary>Every entry with its children, in menu order.</summary>
|
||||
public static IEnumerable<MenuItem> All => Sections.SelectMany(s => s.Items).SelectMany(i => i.Children.Prepend(i));
|
||||
|
||||
/// <summary>The entry that best matches an address: the deepest one whose address is a prefix.</summary>
|
||||
/// <param name="path">The path, without query.</param>
|
||||
/// <returns>The entry, or <see langword="null"/>.</returns>
|
||||
public static MenuItem? Find(string path) =>
|
||||
All.Where(i => i.Matches(path)).OrderByDescending(i => i.Href.Length).FirstOrDefault();
|
||||
|
||||
/// <summary>The top-level entry an address belongs to.</summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>The entry, or <see langword="null"/>.</returns>
|
||||
public static MenuItem? FindArea(string path) =>
|
||||
Sections.SelectMany(s => s.Items).Where(i => i.Matches(path)).OrderByDescending(i => i.Href.Length).FirstOrDefault();
|
||||
|
||||
private static MenuItem Area(string key, string icon, string href, string module, string? permission, string? milestone,
|
||||
params (string Key, string Slug)[] children) =>
|
||||
Area(key, icon, href, module, permission, milestone, MenuAudience.Everyone, children);
|
||||
|
||||
private static MenuItem Area(string key, string icon, string href, string module, string? permission, string? milestone, MenuAudience audience,
|
||||
params (string Key, string Slug)[] children) =>
|
||||
new(key, icon, href, module, permission, milestone, audience)
|
||||
{
|
||||
Children = [.. children.Select(c => new MenuItem(c.Key, icon, href + "/" + c.Slug, module, permission, milestone, audience))],
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user