@T["Shell.Error.Unexpected"]
diff --git a/src/Khaemhat.Web/Components/Pages/Dev/ComponentCatalog.razor b/src/Khaemhat.Web/Components/Pages/Dev/ComponentCatalog.razor
new file mode 100644
index 0000000..500424e
--- /dev/null
+++ b/src/Khaemhat.Web/Components/Pages/Dev/ComponentCatalog.razor
@@ -0,0 +1,315 @@
+@page "/sviluppo/componenti"
+@attribute [Authorize]
+@inject IWebHostEnvironment Environment
+@inject ToastService Toasts
+@inject DialogService Dialogs
+@inject DrawerService Drawers
+@inject TimeProvider Clock
+
+@* The catalog of the Kh components with all their states (issue #27): development only. *@
+
+
+@if (!Environment.IsDevelopment())
+{
+
+}
+else
+{
+
+
+
+
+ @switch (_section)
+ {
+ case "campi":
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @T["Pages.Catalog.Fields.States"]
+
+
+
+
+
+
+
+
+ break;
+
+ case "pannelli":
+
+
+
+ @T["Pages.Catalog.Panels.RevenueDetail"]
+
+
+
+
+
+
+
+
+ @T["Pages.Catalog.Panels.Draft"]
+ @T["Pages.Catalog.Panels.Sent"]
+ @T["Pages.Catalog.Panels.Paid"]
+ @T["Pages.Catalog.Panels.Expiring"]
+ @T["Pages.Catalog.Panels.Overdue"]
+ @T["Pages.Catalog.Panels.Issued"]
+
+
+
+
+
+
+ @if (_filter)
+ {
+
+ }
+
+
+
+
+
+
+ break;
+
+ case "navigazione":
+
+
+
+ @T.Format("Pages.Catalog.Navigation.TabShown", DemoTabs.First(t => t.Id == _demoTab).Text)
+
+
+
+
+
+
+
+
+
+
+
+
+ break;
+
+ case "finestre":
+
+
+
+
+
+
+
+
+
+ @foreach (var kind in Enum.GetValues())
+ {
+
+ }
+
+
+
+
+
+ @T["Pages.Catalog.Windows.DialogText"]
+
+
+
+
+
+
+
+ @T["Pages.Catalog.Windows.DrawerText"]
+
+
+ break;
+
+ case "toolbar":
+
+
@T["Pages.Catalog.Toolbar.Intro"]
+
+
+
+
+
+ @T["Pages.Catalog.Fields.Date"] @(_document.Date is { } d ? T.Date(d) : null)
+ @T["Pages.Catalog.Head.Section"] A
+
+ @T["Pages.Catalog.Panels.Draft"]
+
+
+
+
+
+
+
+ break;
+ }
+}
+
+@code {
+ private readonly KhValidation _validation = new();
+ private SampleDocument _document = default!;
+ private KhForm? _form;
+ private string _section = "campi";
+ private string _demoTab = "righe";
+ private string? _kind;
+ private string? _email;
+ private string? _dialogText;
+ private decimal? _amount;
+ private bool _split;
+ private bool _stamp = true;
+ private bool _readOnly;
+ private bool _filter = true;
+ private bool _dialog;
+ private bool _drawer;
+ private int _step = 1;
+
+ private IReadOnlyList
Sections =>
+ [
+ new("campi", "edit", T["Pages.Catalog.Sections.Fields"]),
+ new("pannelli", "layers", T["Pages.Catalog.Sections.Panels"]),
+ new("navigazione", "columns", T["Pages.Catalog.Sections.Navigation"]),
+ new("finestre", "layout", T["Pages.Catalog.Sections.Windows"]),
+ new("toolbar", "settings", T["Pages.Catalog.Sections.Toolbar"]),
+ ];
+
+ private IReadOnlyList> Kinds =>
+ [
+ new("TD01", T["Pages.Catalog.Fields.KindInvoice"]),
+ new("TD04", T["Pages.Catalog.Fields.KindCredit"]),
+ new("TD24", T["Pages.Catalog.Fields.KindDeferred"]),
+ ];
+
+ private IReadOnlyList Stats =>
+ [
+ new(T["Pages.Catalog.Panels.Documents"], "128"),
+ new(T["Pages.Catalog.Panels.Taxable"], T.Money(104_000m)),
+ new(T["Pages.Catalog.Panels.Collected"], T.Money(96_120m), KhTone.Ok),
+ new(T["Pages.Catalog.Panels.Overdue"], T.Money(4_870.55m), KhTone.Error),
+ ];
+
+ private IReadOnlyList DemoTabs =>
+ [
+ new("righe", "list", T["Ui.Record.Tabs.Lines"], 3),
+ new("testata", "file", T["Ui.Record.Tabs.Header"]),
+ new("allegati", "paperclip", T["Ui.Record.Tabs.Attachments"], 2),
+ new("storico", "history", T["Ui.Record.Tabs.History"]),
+ ];
+
+ private IReadOnlyList Steps =>
+ [
+ new(T["Pages.Catalog.Navigation.Step1"], T["Pages.Catalog.Navigation.Step1Detail"]),
+ new(T["Pages.Catalog.Navigation.Step2"], T["Pages.Catalog.Navigation.Step2Detail"]),
+ new(T["Pages.Catalog.Navigation.Step3"], T["Pages.Catalog.Navigation.Step3Detail"]),
+ ];
+
+ private IReadOnlyList PartyLines => [T["Pages.Catalog.Head.Address"], T["Pages.Catalog.Head.Vat"]];
+
+ private IReadOnlyList SubValues =>
+ [
+ new(T["Pages.Catalog.Panels.Taxable"], T.Money(_document.Taxable)),
+ new(T["Pages.Catalog.Head.VatAmount"], T.Money(_document.Vat)),
+ new(T["Pages.Catalog.Head.Stamp"], T.Money(2m)),
+ ];
+
+ private IReadOnlyList DemoToolbar =>
+ [
+ Item("new", "plus", "Ui.Toolbar.New", "Ctrl+N") with { Priority = 0 },
+ Item("save", "save", "Ui.Toolbar.Save", "Ctrl+S") with { Primary = true, Priority = 0 },
+ Item("cancel", "undo", "Ui.Toolbar.Cancel", null) with { Priority = 2 },
+ Item("delete", "trash", "Ui.Toolbar.Delete", "Ctrl+Delete") with { Danger = true, Priority = 3 },
+ Item("copy", "copy", "Ui.Toolbar.Duplicate", null) with { Group = 1, Priority = 4 },
+ Item("print", "printer", "Ui.Toolbar.Print", "Ctrl+P") with { Group = 1, Priority = 4 },
+ Item("mail", "mail", "Ui.Toolbar.Email", null) with { Group = 1, Priority = 5 },
+ Item("export", "download", "Ui.Toolbar.Export", null) with { Group = 1, Priority = 5 },
+ Item("attachments", "paperclip", "Ui.Toolbar.Attachments", null) with { Group = 2, Count = 2, Priority = 5 },
+ Item("history", "history", "Ui.Toolbar.History", null) with { Group = 2, Priority = 6 },
+ Item("links", "link", "Ui.Toolbar.Links", null) with { Group = 2, Count = 1, Priority = 6 },
+ Item("issue", "send", "Pages.Catalog.Toolbar.Issue", null) with { Kind = ToolbarKind.Action, Primary = true, Priority = 1 },
+ Item("xml", "file-check", "Pages.Catalog.Toolbar.Xml", null) with { Kind = ToolbarKind.Action, Priority = 3 },
+ Item("post", "book", "Pages.Catalog.Toolbar.Post", null) with { Kind = ToolbarKind.Action, Tone = KhTone.Ok, Priority = 3 },
+ Item("ddt", "truck", "Pages.Catalog.Toolbar.Ddt", null) with { Kind = ToolbarKind.Action, Priority = 4 },
+ Item("final", "lock", "Pages.Catalog.Toolbar.Final", null) with { Kind = ToolbarKind.Action, Priority = 4 },
+ Item("radar", "radar", "Ui.Toolbar.Radar", "F9") with { End = true, Priority = 6 },
+ Item("previous", "chevron-up", "Ui.Toolbar.Previous", "Ctrl+ArrowUp") with { End = true, Priority = 7 },
+ Item("next", "chevron-down", "Ui.Toolbar.Next", "Ctrl+ArrowDown") with { End = true, Priority = 7 },
+ Item("settings", "settings", "Pages.Catalog.Toolbar.Settings", null) with { Kind = ToolbarKind.Menu },
+ ];
+
+ ///
+ protected override void OnInitialized() =>
+ _document = CatalogSamples.Document(DateOnly.FromDateTime(TimeZoneInfo.ConvertTime(Clock.GetUtcNow(), TimeZoneInfo.Local).DateTime));
+
+ private ToolbarItem Item(string id, string icon, string key, string? shortcut) =>
+ new(id, icon, T[key]) { Shortcut = shortcut, OnClick = () => Clicked(key) };
+
+ private Task Clicked(string key)
+ {
+ Toasts.Show(ToastKind.Info, T.Format("Pages.Catalog.Toolbar.Clicked", T[key]));
+ return Task.CompletedTask;
+ }
+
+ private string? EmailRule(string? value) =>
+ string.IsNullOrEmpty(value) || value.Contains('@', StringComparison.Ordinal) ? null : T["Auth.Errors.email_invalid"];
+
+ private void OnValid() => Toasts.Show(ToastKind.Success, T["Pages.Catalog.Fields.Valid"]);
+
+ private void ServerError() => _validation.Add("number", T["Pages.Catalog.Fields.NumberTaken"]);
+
+ private void Radar(string text) => Toasts.Show(ToastKind.Info, T.Format("Pages.Catalog.Fields.RadarOpened", text));
+
+ private void OpenParty(SampleParty party) => Toasts.Show(ToastKind.Info, T.Format("Pages.Catalog.Fields.PartyOpened", party.Name));
+
+ private void CreateParty(string text)
+ {
+ _document.Party = new SampleParty("C9999", text);
+ Toasts.Show(ToastKind.Success, T.Format("Pages.Catalog.Fields.PartyCreated", text));
+ }
+
+ private Task ServiceDrawerAsync() => Drawers.ShowAsync(new DrawerRequest(
+ T["Pages.Catalog.Windows.DrawerService"], "sidebar",
+ @@T["Pages.Catalog.Windows.DrawerServiceText"]
,
+ @));
+
+ private async Task ConfirmAsync()
+ {
+ var yes = await Dialogs.ConfirmAsync(new(T["Ui.Record.DeleteTitle"], T["Ui.Record.DeleteText"], T["Ui.Toolbar.Delete"], T["Common.Cancel"], Danger: true));
+ Toasts.Show(yes ? ToastKind.Warning : ToastKind.Info, T[yes ? "Pages.Catalog.Windows.Confirmed" : "Pages.Catalog.Windows.Cancelled"]);
+ }
+
+ private static string KindKey(ToastKind kind) => "Pages.Catalog.Windows.Toast." + kind;
+
+ private void ShowToast(ToastKind kind) => Toasts.Show(kind, T[KindKey(kind)], T["Pages.Catalog.Windows.ToastText"]);
+}
diff --git a/src/Khaemhat.Web/Components/Pages/Dev/SampleDocumentPage.razor b/src/Khaemhat.Web/Components/Pages/Dev/SampleDocumentPage.razor
new file mode 100644
index 0000000..84259a3
--- /dev/null
+++ b/src/Khaemhat.Web/Components/Pages/Dev/SampleDocumentPage.razor
@@ -0,0 +1,194 @@
+@page "/sviluppo/documento"
+@attribute [Authorize]
+@inherits DocumentPage
+@inject IWebHostEnvironment Environment
+@inject TimeProvider Clock
+
+@* A document page built on DocumentPage (issue #29): toolbar, header, tabs with Righe first, shortcuts. Fake data,
+ development only. *@
+
+
+@if (!Environment.IsDevelopment() || Record is null)
+{
+ @T["Pages.Catalog.DevOnly"]
+}
+else
+{
+
+
+
+
+ @T["Pages.Catalog.Fields.Date"] @(Record.Date is { } d ? T.Date(d) : null)
+
+
+ @if (Record.Issued)
+ {
+ @T["Pages.Catalog.Panels.Issued"]
+ }
+ else
+ {
+ @T["Pages.Catalog.Panels.Draft"]
+ }
+ @if (IsModified)
+ {
+ @T["Pages.Catalog.Modified"]
+ }
+
+
+
+
+
+
+
+ @switch (ActiveTab)
+ {
+ case TabIds.Lines:
+
+
+
+ | @T["Pages.Catalog.Lines.Code"] |
+ @T["Pages.Catalog.Lines.Description"] |
+ @T["Pages.Catalog.Lines.Quantity"] |
+ @T["Pages.Catalog.Lines.Price"] |
+ @T["Pages.Catalog.Lines.Amount"] |
+
+
+
+ @foreach (var line in Record.Lines)
+ {
+
+ | @line.Code |
+ @line.Description |
+ @T.Number(line.Quantity ?? 0, 2) |
+ |
+ |
+
+ }
+
+
+ break;
+
+ case TabIds.Header:
+
+
+
+
+
+
+
+
+
+
+
+ break;
+
+ default:
+ @T["Pages.Catalog.TabPlaceholder"]
+ break;
+ }
+
+
+}
+
+@code {
+ private int _saved;
+
+ ///
+ public override IReadOnlyList Tabs => Record is null ? [] : StandardTabs(attachments: 2, links: 1);
+
+ ///
+ public override bool IsReadOnly => Record?.Issued == true;
+
+ ///
+ protected override IList Lines => Record?.Lines ?? [];
+
+ ///
+ protected override string? NewUrl => "sviluppo/documento";
+
+ ///
+ protected override int? AttachmentCount => 2;
+
+ ///
+ protected override bool CanMove => true;
+
+ private IReadOnlyList PartyLines => [T["Pages.Catalog.Head.Address"], T["Pages.Catalog.Head.Vat"]];
+
+ private IReadOnlyList SubValues => Record is null ? [] :
+ [
+ new(T["Pages.Catalog.Panels.Taxable"], T.Money(Record.Taxable)),
+ new(T["Pages.Catalog.Head.VatAmount"], T.Money(Record.Vat)),
+ ];
+
+ ///
+ protected override void OnInitialized()
+ {
+ base.OnInitialized();
+ Record = CatalogSamples.Document(Today);
+ }
+
+ ///
+ protected override IEnumerable ContextActions()
+ {
+ yield return new ToolbarItem("issue", "send", T["Pages.Catalog.Toolbar.Issue"])
+ {
+ Kind = ToolbarKind.Action, Primary = true, Disabled = IsReadOnly || IsModified, OnClick = IssueAsync,
+ };
+ }
+
+ ///
+ protected override Task SaveCoreAsync()
+ {
+ // A pretend rule of the service: the number must keep the year prefix.
+ if (Record is null || !Record.Number.StartsWith("2026/", StringComparison.Ordinal))
+ {
+ Validation.Add("number", T["Pages.Catalog.Fields.NumberTaken"]);
+ return Task.FromResult(false);
+ }
+
+ _saved++;
+ return Task.FromResult(true);
+ }
+
+ ///
+ protected override Task ReloadAsync()
+ {
+ Record = CatalogSamples.Document(Today);
+ return Task.CompletedTask;
+ }
+
+ ///
+ protected override Task MoveAsync(int direction)
+ {
+ Toasts.Show(ToastKind.Info, T[direction < 0 ? "Ui.Toolbar.Previous" : "Ui.Toolbar.Next"]);
+ return Task.CompletedTask;
+ }
+
+ ///
+ protected override Task RadarAsync()
+ {
+ Toasts.Show(ToastKind.Info, T["Ui.Toolbar.Radar"]);
+ return Task.CompletedTask;
+ }
+
+ private DateOnly Today => DateOnly.FromDateTime(TimeZoneInfo.ConvertTime(Clock.GetUtcNow(), TimeZoneInfo.Local).DateTime);
+
+ private void Change(Action change)
+ {
+ change();
+ MarkModified();
+ }
+
+ private Task IssueAsync()
+ {
+ if (Record is not null)
+ {
+ Record.Issued = true;
+ Toasts.Show(ToastKind.Success, T["Pages.Catalog.Panels.Issued"]);
+ }
+
+ return Task.CompletedTask;
+ }
+}
diff --git a/src/Khaemhat.Web/Components/Pages/Profile.razor b/src/Khaemhat.Web/Components/Pages/Profile.razor
index 212fcd7..33a19cb 100644
--- a/src/Khaemhat.Web/Components/Pages/Profile.razor
+++ b/src/Khaemhat.Web/Components/Pages/Profile.razor
@@ -4,6 +4,7 @@
@using Khaemhat.Application.Preferences
@using Khaemhat.Application.Security
@using Khaemhat.Web.Security
+@using Khaemhat.Web.Components.Pages.ProfileTabs
@implements IAsyncDisposable
@inject ShellSession Session
@inject ThemeService Theme
@@ -176,6 +177,14 @@
break;
+ case AccountSection:
+