Repository navigation
Commit 152cd1f
fix(plugin-gantt): a lookup parentField nests its tasks (#34455)
Fixes #34395
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:甘特图的「父任务字段」是查找(lookup)字段时,子任务重新挂到父任务下面显示,不再全部平铺。
- 为什么改:甘特图读记录时会自动展开查找字段,父字段拿到的是整条父记录而不是它的 id;任务树按 id
找父任务,于是一个都对不上。HotCRM 项目任务(`parent_task` 自查找)实测命中。
- 风险与回滚:风险低,只改一处取值:展开后的对象取 `id`(没有再取 `_id`),原本就是 id
的值原样通过,空值仍是顶层。回滚即还原这一个提交。
- 先看:`ui/packages/plugin-gantt/src/ObjectGantt.tsx` 的 `taskParentId`
及其唯一调用处(`parent:` 那一行);再看 `ObjectGantt.harness.test.tsx` 末尾新增的
`ObjectGantt.lookupParent-34395` 块。
- 两分钟验证:`pnpm --dir ui exec vitest run -t lookupParent
packages/plugin-gantt/src/ObjectGantt.harness.test.tsx`,预期 4 个用例全部通过。
- 需要你做的:无,席位落地。
## What changes
`ObjectGantt` builds each task's `parent` from the record's
`parentField`. The record query auto-`$expand`s every lookup, so for a
lookup (or self-lookup) `parentField` the value is the related row, not
its id; the task tree keys parents by id, so no child matched its parent
and every task drew flat, on both the object-gantt block and the gantt
list view.
A new local helper, `taskParentId`, reads an object parent down to `id`,
falling back to `_id`, the same read `normalizeDependencies` already
makes of an expanded predecessor (and `ObjectTree`'s `parentIdOf` makes
of the same rows). A scalar id passes through unchanged and a null or
missing parent stays `null`, so a `parentField` that already held a bare
id behaves exactly as before. No existing exported helper fit:
`extractLookupId` in `@object-ui/plugin-detail` is not part of that
package's public entry and also falls back to `.value` and maps arrays.
The quick-filter ancestor walk in the same component reads `task.parent`
too, so a quick filter on a lookup-parent gantt now keeps a matching
child's ancestors as it already did for scalar parents.
Changeset: `.changeset/34395-gantt-lookup-parent-nests.md`
(`@object-ui/plugin-gantt` patch), at the repository root, where
`ui/AGENTS.md` (Housekeeping) puts every new changeset; the root config
does not read `ui/.changeset/`.
## Tests
New top-level block `ObjectGantt.lookupParent-34395` in the shared
harness `ui/packages/plugin-gantt/src/ObjectGantt.harness.test.tsx` (a
new `ObjectGantt` pin joins that file rather than opening a new one). It
renders the real `ObjectGantt` over a `psa_task` object with a
`parent_task` self-lookup and reads the tasks handed to the `GanttView`
stand-in:
- an expanded lookup parent (`{ id: 'p1', … }`) gives the child `parent
=== 'p1'`, the parent task's own id; the case also asserts the query
asked for `$expand` of `parent_task`;
- an expanded parent carrying only `_id` resolves through it;
- CONTROL: a scalar id parent still nests;
- CONTROL: a null and a missing parent stay top-level.
That the tree nests a task whose `parent` equals another task's id is
the other half, already pinned in `GanttView.tree.test.tsx`.
<details><summary>Full harness file at 4028dbb: 58/58</summary>
```
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-gantt/src/ObjectGantt.harness.test.tsx
Test Files 1 passed (1)
Tests 58 passed (58)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation: the fix reverted, the two lookup cases go
red, the controls stay green</summary>
Prediction written before the run: the two expanded-lookup cases red,
both CONTROLs green. Observed: exactly that. Mutation through
`scripts/ablation-replace.mjs` (anchor hit 1 time, on-disk blob moved),
restored by blob hash. `ObjectGantt` is imported by the test through its
relative source path, so no build leg applies.
```
ablation-replace: anchor "parent: parentField ? taskParentId(record[parentField]) : undefined," x1 (before)
ablation-replace: replace "parent: parentField ? record[parentField] ?? null : undefined," x0 -> x1
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 40ac121 -> d81d034c3a3b
× ObjectGantt.lookupParent-34395 > an expanded lookup parent hands the tree the parent task id, so the child nests
× ObjectGantt.lookupParent-34395 > an expanded lookup parent that carries only `_id` resolves through it
✓ ObjectGantt.lookupParent-34395 > CONTROL: a scalar id parent still nests, passed through as it is
✓ ObjectGantt.lookupParent-34395 > CONTROL: a null or missing parent stays top-level
AssertionError: expected { id: 'p1', subject: 'Phase 1' } to be 'p1' // Object.is equality
AssertionError: expected { _id: 'p1', subject: 'Phase 1' } to be 'p1' // Object.is equality
Tests 2 failed | 2 passed | 54 skipped (58)
ablation-replace: ok restored: blob == HEAD (40ac121) and `git diff HEAD` is empty
```
</details>
## Acceptance notes
- None filed. No out-of-scope defect found on the touched lines.
## Verification
Merged `origin/main` (merge, no rebase) before the final push; the
incoming commits touch no `ui/` path.
<details><summary>Local subset at 4db9832</summary>
- `pnpm --filter @object-ui/plugin-gantt type-check` (`tsc --noEmit &&
tsc -p tsconfig.test.json`, the second program includes
`src/**/*.test.tsx`): exit 0.
- `pnpm --dir ui exec eslint` on the two touched source files: 0 errors
(warnings are the file's existing `no-explicit-any` class).
- `pnpm --dir ui check:new-line-citations`: `0 new citation(s)`.
- `node scripts/pm/dispatch-gates.mjs --commands`: 38 derived commands,
all run under the shared verify lock, each exit recorded before any
pipe; `--ran` reconciliation: `38 derived, 38 run, 0 NOT-MEASURED, 0
UNRUN`, every exit 0.
- Not local, declared to CI: the five type-check programs
`dispatch-gates` names as CI-only, `Test UI`, `Lint UI`, `Type Check
UI`, `Build & E2E UI`. No full dogfood run: the title carries no `!` and
no `(narrowing)` arm.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5obaLbqgzRUR9xXfft)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3a08833 commit 152cd1f
3 files changed
Lines changed: 134 additions & 1 deletion
File tree
- .changeset
- ui/packages/plugin-gantt/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2056 | 2056 | | |
2057 | 2057 | | |
2058 | 2058 | | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
302 | 319 | | |
303 | 320 | | |
304 | 321 | | |
| |||
1545 | 1562 | | |
1546 | 1563 | | |
1547 | 1564 | | |
1548 | | - | |
| 1565 | + | |
1549 | 1566 | | |
1550 | 1567 | | |
1551 | 1568 | | |
| |||
0 commit comments