docs(site-scope): anchor dropdown removal on names, not line numbers
A concurrent project Month/Week feature is landing in the same view files and has already shifted purchasing-view.tsx by ~10 lines, adding a periodFilter beside projectFilter. The removal steps now match on identifiers and snippets, and the plan header says to treat every file:line as a hint. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
67785fe2b3
commit
85692dedec
1 changed files with 59 additions and 31 deletions
|
|
@ -10,6 +10,17 @@
|
|||
|
||||
**Spec:** `docs/superpowers/specs/2026-09-11-site-scope-switcher-design.md`
|
||||
|
||||
> ### Line numbers in this plan will have drifted
|
||||
>
|
||||
> A separate "project Month/Week" feature is landing in several of the
|
||||
> same files (it added a `periodFilter` beside `projectFilter` in three of
|
||||
> the four view files, already shifting them by ~10 lines). **Treat every
|
||||
> `file:line` below as a hint, not an address.** The dropdown-removal
|
||||
> steps are written to anchor on identifier names and code snippets for
|
||||
> exactly this reason — match on the name, then check the surrounding
|
||||
> code looks like the snippet. If it doesn't, stop and re-read the file
|
||||
> rather than editing by line number.
|
||||
|
||||
---
|
||||
|
||||
## File Structure
|
||||
|
|
@ -1052,22 +1063,37 @@ Same in `src/app/dashboard/plant/equipment/page.tsx` — delete line 148, change
|
|||
|
||||
- [ ] **Step 3: Strip the dropdown from `fuel-view.tsx`**
|
||||
|
||||
In `src/app/dashboard/plant/vehicles/fuel-view.tsx`:
|
||||
In `src/app/dashboard/plant/vehicles/fuel-view.tsx`, anchored on names (line hints are from the pre-drift read — verify each before editing):
|
||||
|
||||
- Line 198: replace the `projectCodes,` destructure with `showSiteColumn,`.
|
||||
- Line 206: replace `projectCodes: string[];` with `showSiteColumn: boolean;`.
|
||||
- Line 217: delete `const [projectFilter, setProjectFilter] = React.useState<string>("all");`.
|
||||
- Lines 234 and 248: delete the `if (projectFilter !== "all" && …) return false;` predicates.
|
||||
- Lines 242, 252, 279: remove `projectFilter` from the dependency arrays.
|
||||
- Line 301: `projectFilter !== "all" ||` comes out of `filtersActive`.
|
||||
- Lines 470-488: delete the whole `<div>` holding the Project `Select` (shown at §9 of the spec).
|
||||
- Lines 748, 864, 955, 1053, 1102, 1189-1193, 1291: wrap each `{r.projectCode || "—"}` cell and its header in `{showSiteColumn && …}`.
|
||||
1. Props destructure (~198): `projectCodes,` becomes `showSiteColumn,`.
|
||||
2. Props interface (~206): `projectCodes: string[];` becomes `showSiteColumn: boolean;`.
|
||||
3. Delete the state: `const [projectFilter, setProjectFilter] = React.useState<string>("all");`
|
||||
4. Delete **both** predicates — this file has two, one over rows and one over vehicles:
|
||||
- `if (projectFilter !== "all" && r.projectCode !== projectFilter) return false;`
|
||||
- `if (projectFilter !== "all" && v.projectCode !== projectFilter) return false;`
|
||||
5. Remove `projectFilter` from **all three** dependency arrays — currently `[rows, projectFilter, statusFilter, search]`, `[vehicles, projectFilter, search]`, `[projectFilter, statusFilter, search]`.
|
||||
6. Drop `projectFilter !== "all" ||` from `filtersActive`.
|
||||
7. Delete the whole `<div>` holding `<Select value={projectFilter} onValueChange={setProjectFilter}>` — from its `<span>` Project label down past `</Select>` to the closing `</div>`.
|
||||
8. Wrap every `{… .projectCode || "—"}` display cell **and its matching header** in `{showSiteColumn && …}`. There are seven of them; find them all with
|
||||
`grep -n 'projectCode' src/app/dashboard/plant/vehicles/fuel-view.tsx`
|
||||
and skip the three row-type field declarations (`projectCode: string;`).
|
||||
|
||||
Keep the `projectCode` field on the row types (lines 54, 69, 93) — the column still renders when the scope is "all".
|
||||
Keep `projectCode` on the row types — the column still renders when the scope is "all".
|
||||
|
||||
- [ ] **Step 4: Strip the dropdown from `plant-view.tsx`**
|
||||
|
||||
Same edits in `src/app/dashboard/plant/equipment/plant-view.tsx`: lines 136, 145, 153, 187, 191, 195, 252, 399-410, and the display cells at 550, 672, 898.
|
||||
Same shape in `src/app/dashboard/plant/equipment/plant-view.tsx`, which is simpler — **one** predicate and **two** dependency arrays:
|
||||
|
||||
1. Props destructure (~136): `projectCodes,` becomes `showSiteColumn,`.
|
||||
2. Props interface (~145): `projectCodes: string[];` becomes `showSiteColumn: boolean;`.
|
||||
3. Delete the state: `const [projectFilter, setProjectFilter] = React.useState<string>("all");`
|
||||
4. Delete the predicate: `if (projectFilter !== "all" && r.projectCode !== projectFilter) return false;`
|
||||
5. Remove `projectFilter` from both dependency arrays — currently `[rows, projectFilter, search, removedIds]` and `[projectFilter, search]`.
|
||||
6. `const filtersActive = projectFilter !== "all" || search !== "";` becomes `const filtersActive = search !== "";`.
|
||||
7. Delete the `<div>` holding `<Select value={projectFilter} onValueChange={setProjectFilter}>`.
|
||||
8. Wrap the three `projectCode` display cells and their headers in `{showSiteColumn && …}`; find them with
|
||||
`grep -n 'projectCode' src/app/dashboard/plant/equipment/plant-view.tsx`
|
||||
and skip the two row-type field declarations.
|
||||
|
||||
- [ ] **Step 5: Verify**
|
||||
|
||||
|
|
@ -1122,18 +1148,18 @@ In `src/app/dashboard/workforce/workers/page.tsx`: delete line 27 (`const projec
|
|||
|
||||
- [ ] **Step 3: Strip the dropdown from `employees-view.tsx`**
|
||||
|
||||
In `src/app/dashboard/workforce/workers/employees-view.tsx`:
|
||||
In `src/app/dashboard/workforce/workers/employees-view.tsx`, anchored on names. Note this file's filter is **not** a bare `<Select>` like the others — it is a control taking `value={projectFilter}` plus an options array built with `...projectCodes.map((c) => ({ value: c, label: c }))`, so delete the whole control including that spread:
|
||||
|
||||
- Line 45: `projectCodes,` becomes `showSiteColumn,`.
|
||||
- Line 49: `projectCodes: string[];` becomes `showSiteColumn: boolean;`.
|
||||
- Line 54: delete the `projectFilter` state.
|
||||
- Line 65: delete the `projectFilter` predicate.
|
||||
- Lines 73, 88: remove `projectFilter` from the dependency arrays.
|
||||
- Line 92: `projectFilter !== "all" ||` comes out of the active-filters check.
|
||||
- Lines 146-151: delete the project `Select` block.
|
||||
- Line 269: wrap the `{r.projectCode || "—"}` cell and its header in `{showSiteColumn && …}`.
|
||||
1. Props destructure (~45): `projectCodes,` becomes `showSiteColumn,`.
|
||||
2. Props interface (~49): `projectCodes: string[];` becomes `showSiteColumn: boolean;`.
|
||||
3. Delete the state: `const [projectFilter, setProjectFilter] = React.useState<string>("all");`
|
||||
4. Delete the predicate: `if (projectFilter !== "all" && r.projectCode !== projectFilter) return false;`
|
||||
5. Remove `projectFilter` from both dependency arrays — currently `[rows, workerFilter, projectFilter, positionFilter, search]` and `[workerFilter, projectFilter, positionFilter, search]`. Keep `workerFilter` and `positionFilter`.
|
||||
6. Drop the `projectFilter !== "all" ||` line from the multi-line active-filters expression.
|
||||
7. Delete the control whose props include `value={projectFilter}` and the options array containing the `...projectCodes.map(…)` spread.
|
||||
8. Wrap the `{r.projectCode || "—"}` cell and its header in `{showSiteColumn && …}`.
|
||||
|
||||
Line 364 (`csvCell(r.projectCode)`) **stays unconditionally** — an exported CSV should carry the site even when the on-screen column is hidden, because the file outlives the scope that produced it.
|
||||
`csvCell(r.projectCode)` in the export builder **stays unconditionally** — an exported CSV should carry the site even when the on-screen column is hidden, because the file outlives the scope that produced it.
|
||||
|
||||
- [ ] **Step 4: Verify**
|
||||
|
||||
|
|
@ -1182,18 +1208,20 @@ In `src/app/dashboard/financial/purchase-orders/page.tsx`, replace line 172:
|
|||
|
||||
- [ ] **Step 3: Strip the dropdown from `purchasing-view.tsx`**
|
||||
|
||||
In `src/app/dashboard/financial/purchase-orders/purchasing-view.tsx`:
|
||||
In `src/app/dashboard/financial/purchase-orders/purchasing-view.tsx`, anchored on names rather than lines (this file has already drifted ~10 lines and now carries a `periodFilter` too — leave that alone):
|
||||
|
||||
- Line 124: `projectCodes,` becomes `showSiteColumn,`.
|
||||
- Line 128: `projectCodes: string[];` becomes `showSiteColumn: boolean;`.
|
||||
- Line 132: delete the `projectFilter` state.
|
||||
- Line 139: delete the `projectFilter` predicate.
|
||||
- Lines 150, 154: remove `projectFilter` from the dependency arrays.
|
||||
- Line 163: `projectFilter !== "all" ||` comes out of the active-filters check.
|
||||
- Lines 205-225: delete the project `Select` block.
|
||||
- Line 344: wrap the `{po.projectCode || "—"}` cell and its header in `{showSiteColumn && …}`.
|
||||
1. In the props destructure, `projectCodes,` becomes `showSiteColumn,`.
|
||||
2. In the props interface, `projectCodes: string[];` becomes `showSiteColumn: boolean;`.
|
||||
3. Delete the state line: `const [projectFilter, setProjectFilter] = React.useState("all");`
|
||||
4. Delete the predicate: `if (projectFilter !== "all" && r.projectCode !== projectFilter) return false;`
|
||||
5. Remove the bare `projectFilter` entry from both dependency arrays — they currently read `[rows, projectFilter, statusFilter, periodFilter, search]` and `[projectFilter, statusFilter, periodFilter, search]`. Keep `periodFilter`.
|
||||
6. Drop `projectFilter !== "all" ||` from the `filtersActive` expression, which currently reads `projectFilter !== "all" || statusFilter !== "all" || periodFilter !== "all" || search !== ""`.
|
||||
7. Delete the whole `<div>` wrapping `<Select value={projectFilter} onValueChange={setProjectFilter}>` — the block running from its `Filter` label down through `</Select></div>`, including the `{projectCodes.map((c) => (` body.
|
||||
8. Wrap the `{po.projectCode || "—"}` table cell and its matching `<TableHead>` in `{showSiteColumn && …}`.
|
||||
|
||||
Line 145 (`const hay = \`${r.poNumber} ${r.supplier} ${r.projectCode}\``) **stays** — free-text search over a hidden field is still useful and costs nothing.
|
||||
The search haystack line — `const hay = \`${r.poNumber} ${r.supplier} ${r.projectCode}\`` — **stays**. Free-text search over a hidden field is still useful and costs nothing.
|
||||
|
||||
Verify with `grep -n "projectFilter\|projectCodes" src/app/dashboard/financial/purchase-orders/purchasing-view.tsx` — expected: no output.
|
||||
|
||||
- [ ] **Step 4: Verify**
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue