Skip to content

Commit 8211454

Browse files
authored
Showcase grid follow ups (#1405)
* perf(grid): Unique keys from a name counter; index-based column ordering (26112201 T-01) AddColumn counts the names already given out, so a key never repeats even if an earlier column's header text changes. GetOrderedColumns uses a key map and a set instead of repeated list scans, and the chooser computes row positions once. Chooser members are private and in coding-standard order. * fix(grid): Name unnamed sort buttons, re-announce statuses, safe translations (26112201 T-02) - A sortable column with neither header text nor property name names its button through the new UnnamedSortColumnText ("Sort column {0}", 4.1.0). - Export with no exportable column shows ExportNoDataText and downloads nothing. - The same export or chooser status twice in a row is announced again: the region is cleared and rendered before the message is set. - A translated text whose placeholders do not match falls back to the text instead of throwing while rendering (chooser, filter, and move texts). - Chooser drags carry an empty text payload so Firefox starts the drag. - Docs: saved column order and hidden columns apply whether or not the chooser is on. * fix(grid): Neutralize every text value in CSV export (26112201 T-03) Only built-in numbers, dates, times, and enums are written as values; custom IFormattable output and other text are neutralized, and a formula character after leading spaces is caught too. * refactor(demo): Share link and search helpers; one Plural and LowerFirst per site (26112201 T-04) Foundation gains ShowcaseLinks.IsSiteLink and ShowcaseSearch.Rank; the nine site states delegate to them. Each kept site keeps one Plural (display class, or the site state where services use it) and one LowerFirst. * refactor(demo): Trim unused shared options; harden saved views (26112201 T-05) ShowcaseDataState, ShowcaseGlobalSearch, and ShowcaseNotificationsMenu lose options and marker classes nobody sets. The saved-view store loads once for concurrent callers and never saves over views it could not read; a restored page size no list offers, or a page before the first, falls back to the list's defaults. Healthcare's audit names billing for Billing's edits; the account menu leaves out a blank role. * perf(demo): Store only Help Desk's changes from a fresh tab (26112201 T-06) New Foundation ShowcaseSnapshotDelta (Diff by JSON, Overlay). Help Desk's snapshot holds the records changed or added, the keys of seeded records removed, and the ID counters; the restore rebuilds the full help desk from a fresh tab and runs the existing validation. SnapshotVersion 5: an older snapshot is ignored and the site starts from its seed. * perf(demo): Store only HR's changes from a fresh tab (26112201 T-07) HrState.Snapshot.cs stores the records changed or added and the keys of seeded records removed for all nine lists, plus the ID counters; the restore rebuilds from a fresh tab and runs the existing validation. SnapshotVersion 4: an older snapshot is ignored. * perf(demo): Store only Monitoring's changes from a fresh tab (26112201 T-08) MonitoringState.Snapshot.cs stores the changed or added records and removed keys of all eleven lists, the notification preferences only when they differ, and the ID counters; the restore rebuilds from a fresh tab and runs the existing validation. SnapshotVersion 5: an older snapshot is ignored. * fix(demo): No sideways scroll at 320 px on the kept sites (26112201 T-09) On the nine kept sites the site bar's theme switcher shows only its icon (its accessible name is unchanged); Online Learning and Travel keep the label. SaaS Customers' result badge wraps, and the Pricing billing toggle is tighter below 400 px. * docs: Grid follow-up parameters and a draft 4.1.0 upgrade post (26112201 T-10) grid.mdx lists UnnamedSortColumnText and says saved column order and hidden columns apply whether or not the chooser is on. A draft (unpublished) Upgrade to v4.1.0 post lists the Grid, MindMap, and PdfViewer markup consumers may target and the new localizable texts. * fix(grid): Re-announce repeated statuses reliably; review follow-ups (26112201 rework) A shown export or chooser status stays empty for 150 ms before the next message, so the change reaches the accessibility tree. Export with no exportable column stops before reading rows. The saved-view store never caches a faulted load. Doc comment fixes in Grid and Help Desk; the upgrade post's translation note covers the listed texts only.
1 parent 2ffb32a commit 8211454

92 files changed

Lines changed: 1549 additions & 551 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Ecommerce/AdminAnalytics.razor.cs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ public void Dispose()
104104

105105
private static decimal NetOf(EcommerceOrder order) => order.Totals.Total - order.RefundedAmount;
106106

107-
private static string Plural(int count, string one, string many) => count == 1 ? $"1 {one}" : $"{Count(count)} {many}";
108-
109107
private static string StatusName(EcommerceOrderStatus status) => status.ToString();
110108

111109
private static PeriodTotals Totals(IReadOnlyList<EcommerceOrder> orders)
@@ -424,13 +422,13 @@ private IReadOnlyList<Kpi> Kpis
424422
new Kpi("net", "Net revenue", EcommerceDisplay.Money(current.Net), "Order totals minus refunds",
425423
Compare(current.Net, Previous(previous.Net))),
426424
new Kpi("orders", "Orders", Count(current.Orders),
427-
current.Cancelled == 0 ? "No cancelled orders" : $"Not counting {Plural(current.Cancelled, "cancelled order", "cancelled orders")}",
425+
current.Cancelled == 0 ? "No cancelled orders" : $"Not counting {EcommerceDisplay.Plural(current.Cancelled, "cancelled order", "cancelled orders")}",
428426
Compare(current.Orders, Previous(previous.Orders))),
429427
new Kpi("aov", "Average order value", current.Orders == 0 ? "—" : EcommerceDisplay.Money(current.AverageOrderValue), "Before refunds, with shipping and tax",
430428
Compare(current.Orders == 0 ? null : current.AverageOrderValue, Previous(previous.AverageOrderValue))),
431429
new Kpi("items", "Items sold", Count(current.Items), "Units across all orders",
432430
Compare(current.Items, Previous(previous.Items))),
433-
new Kpi("refunds", "Refunds", EcommerceDisplay.Money(current.Refunded), $"On {Plural(current.RefundCount, "order", "orders")} placed in this period",
431+
new Kpi("refunds", "Refunds", EcommerceDisplay.Money(current.Refunded), $"On {EcommerceDisplay.Plural(current.RefundCount, "order", "orders")} placed in this period",
434432
Compare(current.Refunded, Previous(previous.Refunded))),
435433
};
436434
}
@@ -453,7 +451,7 @@ private string RevenueSummary
453451
var quiet = report.Daily.Count(day => day.Net == 0);
454452

455453
return $"{EcommerceDisplay.Money(total)} net over the {RangeDescription}. Best day: {DayLabel(best.Day)}, {EcommerceDisplay.Money(best.Net)}. "
456-
+ (quiet == 0 ? "Every day had sales." : $"{Plural(quiet, "day", "days")} without sales.");
454+
+ (quiet == 0 ? "Every day had sales." : $"{EcommerceDisplay.Plural(quiet, "day", "days")} without sales.");
457455
}
458456
}
459457

@@ -468,7 +466,7 @@ private string StatusSummary
468466
if (total == 0)
469467
return $"No orders in the {RangeDescription}.";
470468

471-
return $"{Plural(total, "order", "orders")} placed: " + string.Join(", ", report.Statuses.Select(row => $"{Count(row.Orders)} {StatusName(row.Status).ToLowerInvariant()}")) + ".";
469+
return $"{EcommerceDisplay.Plural(total, "order", "orders")} placed: " + string.Join(", ", report.Statuses.Select(row => $"{Count(row.Orders)} {StatusName(row.Status).ToLowerInvariant()}")) + ".";
472470
}
473471
}
474472

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Fintech/AmlAlerts.razor.cs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ protected override void OnInitialized()
124124

125125
private static string Count(int value) => value.ToString("#,0", CultureInfo.InvariantCulture);
126126

127-
private static string Plural(int count, string one, string many) => count == 1 ? $"1 {one}" : $"{Count(count)} {many}";
128-
129127
/// <summary>Applies the bulk bar's action once the form is valid; opening a case goes to the new case.</summary>
130128
private async Task ApplyBulkAsync()
131129
{
@@ -158,8 +156,8 @@ private async Task ApplyBulkAsync()
158156
var assigned = State.AssignAlerts(ids, bulkForm.AssigneeId);
159157
message = assigned.Result switch
160158
{
161-
FintechResult.Ok => $"Assigned {Plural(assigned.Changed, "alert", "alerts")} to {AmlDisplay.StaffText(bulkForm.AssigneeId)}."
162-
+ (assigned.Unchanged > 0 ? $" {Plural(assigned.Unchanged, "alert was", "alerts were")} left as they were: already dismissed, in a case, or with them." : string.Empty),
159+
FintechResult.Ok => $"Assigned {FintechDisplay.Plural(assigned.Changed, "alert", "alerts")} to {AmlDisplay.StaffText(bulkForm.AssigneeId)}."
160+
+ (assigned.Unchanged > 0 ? $" {FintechDisplay.Plural(assigned.Unchanged, "alert was", "alerts were")} left as they were: already dismissed, in a case, or with them." : string.Empty),
163161
FintechResult.NoChange => "No alerts changed: they're already dismissed, in a case, or assigned to that person.",
164162
_ => AmlDisplay.ResultText(assigned.Result),
165163
};
@@ -170,8 +168,8 @@ private async Task ApplyBulkAsync()
170168
var dismissed = State.DismissAlerts(ids, bulkForm.Reason ?? string.Empty);
171169
message = dismissed.Result switch
172170
{
173-
FintechResult.Ok => $"Dismissed {Plural(dismissed.Changed, "alert", "alerts")} as false positives."
174-
+ (dismissed.Unchanged > 0 ? $" {Plural(dismissed.Unchanged, "alert was", "alerts were")} left as they were: already dismissed or in a case." : string.Empty),
171+
FintechResult.Ok => $"Dismissed {FintechDisplay.Plural(dismissed.Changed, "alert", "alerts")} as false positives."
172+
+ (dismissed.Unchanged > 0 ? $" {FintechDisplay.Plural(dismissed.Unchanged, "alert was", "alerts were")} left as they were: already dismissed or in a case." : string.Empty),
175173
FintechResult.NoChange => "No alerts changed: they're already dismissed or in a case.",
176174
_ => AmlDisplay.ResultText(dismissed.Result),
177175
};

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Fintech/FintechDisplay.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,9 @@ public static async Task FocusAsync(ElementReference? element)
5151

5252
#endregion
5353

54+
/// <summary>Formats a count with its noun, like "1 ticket" or "1,204 tickets"; <paramref name="plural" /> defaults to the noun plus "s".</summary>
55+
public static string Plural(int count, string noun, string? plural = null) =>
56+
count == 1 ? $"1 {noun}" : $"{count.ToString("#,0", CultureInfo.InvariantCulture)} {plural ?? noun + "s"}";
57+
5458
#endregion
5559
}

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Fintech/OpsQueue.razor.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ internal static string WaitText(DateTime since, DateTime now)
151151

152152
private static string CountText(int count) => $"{Count(count)} waiting";
153153

154-
private static string Plural(int count, string one, string many) => count == 1 ? $"1 {one}" : $"{Count(count)} {many}";
155-
156154
/// <summary>
157155
/// Applies the bulk bar's action to the selected transfers in one call, once the form is valid, then refreshes the grid
158156
/// and clears the selection; the bar closes, so focus moves to the announcement.
@@ -176,8 +174,8 @@ private async Task ApplyBulkAsync()
176174
var done = action switch { ReleaseAction => "Released", RejectAction => "Rejected", _ => "Held for review" };
177175
var message = outcome.Result switch
178176
{
179-
FintechResult.Ok => $"{done}: {Plural(outcome.Changed, "transfer", "transfers")}. The customers are told."
180-
+ (outcome.Unchanged > 0 ? $" {Plural(outcome.Unchanged, "transfer was", "transfers were")} left as they were: already decided, or the account no longer holds the money." : string.Empty),
177+
FintechResult.Ok => $"{done}: {FintechDisplay.Plural(outcome.Changed, "transfer", "transfers")}. The customers are told."
178+
+ (outcome.Unchanged > 0 ? $" {FintechDisplay.Plural(outcome.Unchanged, "transfer was", "transfers were")} left as they were: already decided, or the account no longer holds the money." : string.Empty),
181179
FintechResult.NoChange => "No transfers changed: they were already decided meanwhile, or the accounts no longer hold the money.",
182180
FintechResult.NotAllowed => "Sign in again as operations, with a one-time code, to change transfers. Nothing changed.",
183181
_ => "Those changes couldn't be saved. Nothing changed.",

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Fintech/Transfer.razor.cs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ public void Dispose()
136136

137137
private static string IsoDate(DateOnly date) => date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
138138

139-
/// <summary>Lower-cases the first letter of a sentence fragment used mid-sentence.</summary>
140-
private static string LowerFirst(string text) => text.Length == 0 ? text : char.ToLowerInvariant(text[0]) + text[1..];
141-
142139
/// <summary>Says how a payee's name check went, so the customer knows why a payment may be held.</summary>
143140
private static string MatchHint(FintechPayee payee) => payee.Match switch
144141
{
@@ -243,7 +240,7 @@ private void UpdateLimits()
243240

244241
/// <summary>Gets the hint that the transfer will be held for a check, or <see langword="null" />.</summary>
245242
private string? HoldHint => form.Amount is > 0 && ExpectedHoldReason(State, form.ToId, form.Amount.Value) is { } reason
246-
? $"This payment will be held for a routine check before it's sent ({LowerFirst(reason)}). We usually check within one business day; the money is set aside meanwhile."
243+
? $"This payment will be held for a routine check before it's sent ({FintechSeedData.LowerFirst(reason)}). We usually check within one business day; the money is set aside meanwhile."
247244
: null;
248245

249246
private DateOnly LastDate => State.Today.AddDays(FintechState.MaxScheduleDays);

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Healthcare/CheckIn.razor.cs‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ protected override void OnInitialized()
133133

134134
#region Private Methods
135135

136-
private static string Plural(int count, string one, string many) => count == 1 ? $"1 {one}" : string.Create(CultureInfo.InvariantCulture, $"{count} {many}");
137-
138136
private static string SummaryText(int shown, int total)
139137
{
140138
var count = total == 1 ? "1 appointment" : FormattableString.Invariant($"{total} appointments");
@@ -160,7 +158,7 @@ private async Task BulkCheckInAsync()
160158
var ids = selected.Where(row => row.StatusValue == HcAppointmentStatus.Booked).Select(row => row.Id).ToList();
161159
var outcome = State.BulkCheckIn(ids);
162160

163-
await FinishBulkAsync(outcome, $"Checked in {Plural(outcome.Changed, "patient", "patients")}: they're in the waiting room, and their doctors can see them.",
161+
await FinishBulkAsync(outcome, $"Checked in {HcDisplay.Plural(outcome.Changed, "patient", "patients")}: they're in the waiting room, and their doctors can see them.",
164162
"No one was checked in: the selected patients are checked in already, or their appointments are closed.", "already checked in or closed");
165163
}
166164

@@ -243,7 +241,7 @@ private async Task FinishBulkAsync(HcBulkOutcome outcome, string changedText, st
243241
{
244242
var message = outcome.Result switch
245243
{
246-
HcResult.Ok => changedText + (outcome.Unchanged > 0 ? $" {Plural(outcome.Unchanged, "appointment was", "appointments were")} left as they were: {unchangedReason}." : string.Empty),
244+
HcResult.Ok => changedText + (outcome.Unchanged > 0 ? $" {HcDisplay.Plural(outcome.Unchanged, "appointment was", "appointments were")} left as they were: {unchangedReason}." : string.Empty),
247245
HcResult.NoChange => noChangeText,
248246
HcResult.NotAllowed => "Only the front desk can check patients in. Sign in again; nothing changed.",
249247
_ => "Those changes couldn't be saved. Nothing changed.",
@@ -332,7 +330,7 @@ private void OnNoShowHidden()
332330
return;
333331
}
334332

335-
_ = InvokeAsync(() => FinishBulkAsync(State.BulkMarkNoShow(ids), $"Marked {Plural(ids.Count, "patient", "patients")} as no-shows.",
333+
_ = InvokeAsync(() => FinishBulkAsync(State.BulkMarkNoShow(ids), $"Marked {HcDisplay.Plural(ids.Count, "patient", "patients")} as no-shows.",
336334
"No one was marked: the selected appointments haven't started yet, or they aren't booked any more.", "not started yet or not booked"));
337335
}
338336

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Healthcare/Claims.razor.cs‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ protected override void OnInitialized()
152152

153153
#region Private Methods
154154

155-
private static string Plural(int count, string one, string many) => count == 1 ? $"1 {one}" : string.Create(CultureInfo.InvariantCulture, $"{count} {many}");
156-
157155
/// <summary>Returns the age bucket of a claim by days since its visit.</summary>
158156
private string BucketOf(HcClaim claim) => AgeDays(claim) switch
159157
{
@@ -197,7 +195,7 @@ private string CountText(int total)
197195
{
198196
var shown = Shown.Count;
199197

200-
return string.Create(CultureInfo.InvariantCulture, $"Showing {shown:#,0} of {Plural(total, "claim", "claims")}.");
198+
return string.Create(CultureInfo.InvariantCulture, $"Showing {shown:#,0} of {HcDisplay.Plural(total, "claim", "claims")}.");
201199
}
202200

203201
/// <summary>A filter changed: back to the first page of the filtered claims.</summary>
@@ -365,8 +363,8 @@ private async Task SubmitSelectedAsync()
365363

366364
SetStatus(outcome.Result switch
367365
{
368-
HcResult.Ok => $"Submitted {Plural(outcome.Changed, "claim", "claims")} to the plans."
369-
+ (outcome.Unchanged > 0 ? $" {Plural(outcome.Unchanged, "claim was", "claims were")} left as they were: past the filing deadline, or already sent." : string.Empty),
366+
HcResult.Ok => $"Submitted {HcDisplay.Plural(outcome.Changed, "claim", "claims")} to the plans."
367+
+ (outcome.Unchanged > 0 ? $" {HcDisplay.Plural(outcome.Unchanged, "claim was", "claims were")} left as they were: past the filing deadline, or already sent." : string.Empty),
370368
HcResult.NoChange => "No claims were sent: they're past the filing deadline, or already sent.",
371369
HcResult.NotAllowed => "Only billing can submit claims. Sign in again; nothing was sent.",
372370
_ => "Those claims couldn't be sent. Nothing changed.",

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Healthcare/HcDisplay.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,9 @@ public static async Task FocusAsync(ElementReference? element)
133133

134134
#endregion
135135

136+
/// <summary>Formats a count with its noun, like "1 ticket" or "1,204 tickets"; <paramref name="plural" /> defaults to the noun plus "s".</summary>
137+
public static string Plural(int count, string noun, string? plural = null) =>
138+
count == 1 ? $"1 {noun}" : $"{count.ToString("#,0", CultureInfo.InvariantCulture)} {plural ?? noun + "s"}";
139+
136140
#endregion
137141
}

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Healthcare/Labs.razor.cs‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ public static string RangeText(HcAnalyte analyte) =>
141141

142142
#region Private Methods
143143

144-
private static string Plural(int count, string one, string many) => count == 1 ? $"1 {one}" : string.Create(CultureInfo.InvariantCulture, $"{count} {many}");
145-
146144
private async Task AskReleaseAsync()
147145
{
148146
releaseIds = selected.Where(row => row.StatusValue == HcLabStatus.Resulted).Select(row => row.Id).ToList();
@@ -183,7 +181,7 @@ private string CountText(int total)
183181
{
184182
var shown = Shown.Count;
185183

186-
return shown == total ? $"{Plural(total, "order", "orders")}." : $"Showing {shown.ToString(CultureInfo.InvariantCulture)} of {Plural(total, "order", "orders")}.";
184+
return shown == total ? $"{HcDisplay.Plural(total, "order", "orders")}." : $"Showing {shown.ToString(CultureInfo.InvariantCulture)} of {HcDisplay.Plural(total, "order", "orders")}.";
187185
}
188186

189187
/// <summary>A filter changed: back to the first page of the filtered orders.</summary>
@@ -213,8 +211,8 @@ private async Task OnReleaseHiddenAsync()
213211

214212
SetStatus(outcome.Result switch
215213
{
216-
HcResult.Ok => $"Released {Plural(outcome.Changed, "result", "results")}: each patient sees theirs in Lab reports and was billed {HcDisplay.Money(HcSeedData.LabFeeCents)}."
217-
+ (outcome.Unchanged > 0 ? $" {Plural(outcome.Unchanged, "order was", "orders were")} left as they were: released already, or the storage for this demo tab is full." : string.Empty),
214+
HcResult.Ok => $"Released {HcDisplay.Plural(outcome.Changed, "result", "results")}: each patient sees theirs in Lab reports and was billed {HcDisplay.Money(HcSeedData.LabFeeCents)}."
215+
+ (outcome.Unchanged > 0 ? $" {HcDisplay.Plural(outcome.Unchanged, "order was", "orders were")} left as they were: released already, or the storage for this demo tab is full." : string.Empty),
218216
HcResult.NoChange => "Nothing was released: those orders were released already, or the storage for this demo tab is full.",
219217
HcResult.NotAllowed => "Only the ordering doctor can release results. Sign in again; nothing was released.",
220218
_ => "Those results couldn't be released. Nothing changed.",

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/Healthcare/Patients.razor.cs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ protected override void OnInitialized()
8383

8484
#region Private Methods
8585

86-
private static string Plural(int count) => count == 1 ? "1 patient" : string.Create(CultureInfo.InvariantCulture, $"{count:#,0} patients");
87-
8886
/// <summary>The link disappears with the filters it clears, so focus moves to the count, which also announces the new total.</summary>
8987
private async Task ClearFiltersAsync()
9088
{
@@ -97,7 +95,7 @@ private string CountText(int total)
9795
{
9896
var shown = Shown.Count;
9997

100-
return shown == total ? $"{Plural(total)}." : $"Showing {shown.ToString("#,0", CultureInfo.InvariantCulture)} of {Plural(total)}.";
98+
return shown == total ? $"{HcDisplay.Plural(total, "patient")}." : $"Showing {shown.ToString("#,0", CultureInfo.InvariantCulture)} of {HcDisplay.Plural(total, "patient")}.";
10199
}
102100

103101
/// <summary>A filter changed: back to the first page of the filtered patients.</summary>

0 commit comments

Comments
 (0)