refactor(centralui): SiteCallsReport adopts KeysetPager + DateTimeRangeFilter + tokenized backdrop (T35f)
This commit is contained in:
+16
-26
@@ -74,14 +74,9 @@
|
|||||||
@bind="_nodeFilter" />
|
@bind="_nodeFilter" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<label class="form-label small mb-1" for="sc-from">From</label>
|
<DateTimeRangeFilter From="_fromFilter" FromChanged="(v => _fromFilter = v)"
|
||||||
<input id="sc-from" type="datetime-local" class="form-control form-control-sm"
|
To="_toFilter" ToChanged="(v => _toFilter = v)"
|
||||||
@bind="_fromFilter" />
|
IdPrefix="sc" />
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<label class="form-label small mb-1" for="sc-to">To</label>
|
|
||||||
<input id="sc-to" type="datetime-local" class="form-control form-control-sm"
|
|
||||||
@bind="_toFilter" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label class="form-label small mb-1" for="sc-search">Target keyword</label>
|
<label class="form-label small mb-1" for="sc-search">Target keyword</label>
|
||||||
@@ -215,23 +210,18 @@
|
|||||||
|
|
||||||
@* Keyset paging — the Task 4 query response carries a (CreatedAtUtc, Id)
|
@* Keyset paging — the Task 4 query response carries a (CreatedAtUtc, Id)
|
||||||
cursor rather than page numbers, so we keep a stack of cursors to step
|
cursor rather than page numbers, so we keep a stack of cursors to step
|
||||||
backwards and the response's NextAfter* cursor to step forwards. *@
|
backwards and the response's NextAfter* cursor to step forwards. All
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
cursor logic stays in this code-behind; KeysetPager is presentational.
|
||||||
<span class="text-muted small">
|
No "of N" total: keyset paging has no cheap total-count, so the label is
|
||||||
@* No "of N" total: keyset paging has no cheap total-count, so
|
intentionally page-number-only. Do not "fix" this by adding a total —
|
||||||
the label is intentionally page-number-only. Do not "fix"
|
that would require a COUNT(*). *@
|
||||||
this by adding a total — that would require a COUNT(*). *@
|
<KeysetPager PageNumber="@(_cursorStack.Count + 1)"
|
||||||
Page @(_cursorStack.Count + 1) · @_siteCalls.Count rows
|
RowCount="_siteCalls.Count"
|
||||||
</span>
|
CanGoBack="@(_cursorStack.Count > 0)"
|
||||||
<div>
|
HasNextPage="@(_nextCursor is not null)"
|
||||||
<button class="btn btn-outline-secondary btn-sm me-1"
|
Disabled="_loading"
|
||||||
@onclick="PrevPage" disabled="@(_cursorStack.Count == 0 || _loading)"
|
OnPrevious="PrevPage"
|
||||||
data-test="site-calls-prev">Previous</button>
|
OnNext="NextPage" />
|
||||||
<button class="btn btn-outline-secondary btn-sm"
|
|
||||||
@onclick="NextPage" disabled="@(!HasNextPage || _loading)"
|
|
||||||
data-test="site-calls-next">Next</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@* ── Trends (K14: collapsible KPI-history charts) ──
|
@* ── Trends (K14: collapsible KPI-history charts) ──
|
||||||
@@ -292,7 +282,7 @@
|
|||||||
@if (_detailSiteCall != null)
|
@if (_detailSiteCall != null)
|
||||||
{
|
{
|
||||||
var d = _detailSiteCall;
|
var d = _detailSiteCall;
|
||||||
<div class="modal show d-block" tabindex="-1" style="background: rgba(0,0,0,0.4);"
|
<div class="modal show d-block sb-modal-backdrop" tabindex="-1"
|
||||||
@onclick="CloseDetail">
|
@onclick="CloseDetail">
|
||||||
<div class="modal-dialog modal-dialog-scrollable modal-lg" @onclick:stopPropagation="true">
|
<div class="modal-dialog modal-dialog-scrollable modal-lg" @onclick:stopPropagation="true">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|||||||
@@ -307,9 +307,9 @@ public class SiteCallsReportPageTests : BunitContext
|
|||||||
var cut = Render<SiteCallsReportPage>();
|
var cut = Render<SiteCallsReportPage>();
|
||||||
cut.WaitForState(() => cut.Markup.Contains("ERP.GetOrder"));
|
cut.WaitForState(() => cut.Markup.Contains("ERP.GetOrder"));
|
||||||
|
|
||||||
var next = cut.Find("[data-test='site-calls-next']");
|
var next = cut.Find("[data-test='keyset-next']");
|
||||||
Assert.True(next.HasAttribute("disabled"));
|
Assert.True(next.HasAttribute("disabled"));
|
||||||
var prev = cut.Find("[data-test='site-calls-prev']");
|
var prev = cut.Find("[data-test='keyset-prev']");
|
||||||
Assert.True(prev.HasAttribute("disabled"));
|
Assert.True(prev.HasAttribute("disabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ public class SiteCallsReportPageTests : BunitContext
|
|||||||
var cut = Render<SiteCallsReportPage>();
|
var cut = Render<SiteCallsReportPage>();
|
||||||
cut.WaitForState(() => cut.Markup.Contains("ERP.Op0"));
|
cut.WaitForState(() => cut.Markup.Contains("ERP.Op0"));
|
||||||
|
|
||||||
var next = cut.Find("[data-test='site-calls-next']");
|
var next = cut.Find("[data-test='keyset-next']");
|
||||||
Assert.False(next.HasAttribute("disabled"));
|
Assert.False(next.HasAttribute("disabled"));
|
||||||
|
|
||||||
next.Click();
|
next.Click();
|
||||||
@@ -381,7 +381,7 @@ public class SiteCallsReportPageTests : BunitContext
|
|||||||
cut.WaitForState(() => cut.Markup.Contains("ERP.Op0"));
|
cut.WaitForState(() => cut.Markup.Contains("ERP.Op0"));
|
||||||
|
|
||||||
// Step forward — query 2 carries the keyset cursor.
|
// Step forward — query 2 carries the keyset cursor.
|
||||||
var next = cut.Find("[data-test='site-calls-next']");
|
var next = cut.Find("[data-test='keyset-next']");
|
||||||
next.Click();
|
next.Click();
|
||||||
cut.WaitForAssertion(() =>
|
cut.WaitForAssertion(() =>
|
||||||
{
|
{
|
||||||
@@ -390,7 +390,7 @@ public class SiteCallsReportPageTests : BunitContext
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Previous is now live (the back-stack has one entry); click it.
|
// Previous is now live (the back-stack has one entry); click it.
|
||||||
var prev = cut.Find("[data-test='site-calls-prev']");
|
var prev = cut.Find("[data-test='keyset-prev']");
|
||||||
Assert.False(prev.HasAttribute("disabled"));
|
Assert.False(prev.HasAttribute("disabled"));
|
||||||
prev.Click();
|
prev.Click();
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ public class SiteCallsReportPageTests : BunitContext
|
|||||||
Assert.Null(_queryRequests[2].AfterCreatedAtUtc);
|
Assert.Null(_queryRequests[2].AfterCreatedAtUtc);
|
||||||
Assert.Null(_queryRequests[2].AfterId);
|
Assert.Null(_queryRequests[2].AfterId);
|
||||||
// Back on page 1, the back-stack is empty again so Previous re-disables.
|
// Back on page 1, the back-stack is empty again so Previous re-disables.
|
||||||
Assert.True(cut.Find("[data-test='site-calls-prev']").HasAttribute("disabled"));
|
Assert.True(cut.Find("[data-test='keyset-prev']").HasAttribute("disabled"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user