mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 08:03:22 +00:00
fix(work-orders): clarify search scope with advanced filters
This commit is contained in:
parent
dace388633
commit
2b2b24f2e3
4 changed files with 24 additions and 5 deletions
|
|
@ -13,6 +13,8 @@ type WorkOrdersListHeaderProps = {
|
||||||
/** Omit until wizard shell slice mounts New WO. */
|
/** Omit until wizard shell slice mounts New WO. */
|
||||||
onNewWorkOrder?: () => void;
|
onNewWorkOrder?: () => void;
|
||||||
activeFilterCount: number;
|
activeFilterCount: number;
|
||||||
|
/** True while Advanced Filters are applied; results are global and the keyword box is inert. */
|
||||||
|
advancedFiltersActive?: boolean;
|
||||||
isFetching?: boolean;
|
isFetching?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -23,6 +25,7 @@ export function WorkOrdersListHeader({
|
||||||
onOpenAdvancedFilters,
|
onOpenAdvancedFilters,
|
||||||
onNewWorkOrder,
|
onNewWorkOrder,
|
||||||
activeFilterCount,
|
activeFilterCount,
|
||||||
|
advancedFiltersActive = false,
|
||||||
isFetching = false,
|
isFetching = false,
|
||||||
}: WorkOrdersListHeaderProps) {
|
}: WorkOrdersListHeaderProps) {
|
||||||
return (
|
return (
|
||||||
|
|
@ -34,8 +37,8 @@ export function WorkOrdersListHeader({
|
||||||
placeholder="Search this week…"
|
placeholder="Search this week…"
|
||||||
aria-label="Search work orders"
|
aria-label="Search work orders"
|
||||||
/>
|
/>
|
||||||
{/* SH-194: keyword search is scoped to the active week; make that scope visible. */}
|
{/* Keyword search is scoped to the active week; make that scope visible. */}
|
||||||
{search.trim() !== "" && Boolean(weekLabel) && (
|
{!advancedFiltersActive && search.trim() !== "" && Boolean(weekLabel) && (
|
||||||
<span
|
<span
|
||||||
role="status"
|
role="status"
|
||||||
className="absolute left-0 whitespace-nowrap"
|
className="absolute left-0 whitespace-nowrap"
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export function useWorkOrdersBoardSource(filters: FiltersReturn): WorkOrdersBoar
|
||||||
() =>
|
() =>
|
||||||
buildResolvedBoardSearchParams({
|
buildResolvedBoardSearchParams({
|
||||||
advApplied: filters.advApplied,
|
advApplied: filters.advApplied,
|
||||||
// SH-194: Advanced Filters are global by design; the week-scoped keyword box has no effect.
|
// Advanced Filters are global by design; the week-scoped keyword box has no effect.
|
||||||
search: "",
|
search: "",
|
||||||
page: filters.page,
|
page: filters.page,
|
||||||
pageSize: filters.pageSize,
|
pageSize: filters.pageSize,
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ export default function WorkOrdersListPage() {
|
||||||
onOpenAdvancedFilters={() => filters.setAdvOpen(true)}
|
onOpenAdvancedFilters={() => filters.setAdvOpen(true)}
|
||||||
onNewWorkOrder={() => page.setWizardOpen(true)}
|
onNewWorkOrder={() => page.setWizardOpen(true)}
|
||||||
activeFilterCount={filters.activeFilterCount}
|
activeFilterCount={filters.activeFilterCount}
|
||||||
|
advancedFiltersActive={filters.advApplied != null}
|
||||||
isFetching={tableData.isFetching && !tableData.isLoading}
|
isFetching={tableData.isFetching && !tableData.isLoading}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ function renderBoardSource() {
|
||||||
return renderHook(() => useBoardWithFilters(), { wrapper });
|
return renderHook(() => useBoardWithFilters(), { wrapper });
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("SH-194 keyword search scope indicator", () => {
|
describe("keyword search scope indicator", () => {
|
||||||
it("shows no scope badge while the search box is empty", () => {
|
it("shows no scope badge while the search box is empty", () => {
|
||||||
renderWithProviders(
|
renderWithProviders(
|
||||||
<WorkOrdersListHeader
|
<WorkOrdersListHeader
|
||||||
|
|
@ -75,9 +75,24 @@ describe("SH-194 keyword search scope indicator", () => {
|
||||||
|
|
||||||
expect(screen.getByText("Searching within 5/4–5/8")).toBeInTheDocument();
|
expect(screen.getByText("Searching within 5/4–5/8")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("hides the scope label while Advanced Filters are active", () => {
|
||||||
|
renderWithProviders(
|
||||||
|
<WorkOrdersListHeader
|
||||||
|
search="hvac"
|
||||||
|
weekLabel="5/4–5/8"
|
||||||
|
onSearchChange={vi.fn()}
|
||||||
|
activeFilterCount={1}
|
||||||
|
advancedFiltersActive
|
||||||
|
/>,
|
||||||
|
{ withAuth: false },
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.queryByText(/searching within/i)).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("SH-194 keyword search vs Advanced Filters scope", () => {
|
describe("keyword search vs Advanced Filters scope", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
searchBoard.mockReset().mockResolvedValue(EMPTY_RESULT);
|
searchBoard.mockReset().mockResolvedValue(EMPTY_RESULT);
|
||||||
getBoard.mockReset().mockResolvedValue(EMPTY_RESULT);
|
getBoard.mockReset().mockResolvedValue(EMPTY_RESULT);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue