feat(junction): add stage2 object selection scope controls
This commit is contained in:
1 parent
b89c5fd174
commit
de6ef8e64b
8 files changed
+131
-5
No files matched your search
@@ -0,0 +1,2 @@
|
||||
{"file":".trellis/spec/frontend/direct-edit-client.md","reason":"Verify shared edit protocol and reset semantics."}
|
||||
{"file":".trellis/spec/frontend/quality-guidelines.md","reason":"Run client checks and preserve component boundaries."}
|
||||
@@ -0,0 +1,7 @@
|
||||
# 技术设计
|
||||
|
||||
`JunctionWorkspace` 持有路口级选择键,`App` 仍是组合根,现有 `EditSession` 继续拥有约束、预览和撤销历史。新增的选择适配器只把设施/诊断/handle 映射到结构对象键,不复制几何或保存协议。
|
||||
|
||||
作用域覆盖使用现有 handle 的 `constraintId` 和 `affects` 集合:全局操作选择同类 handle 组,局部操作只发送当前对象 handle;恢复全局调用现有 `onReset`,由 EditSession 记录禁用约束。UI 显示继承来源,不另建一套 draft。
|
||||
|
||||
所有新状态都必须兼容旧 state 缺失结构字段;旧路口继续使用现有参数面板。
|
||||
@@ -0,0 +1,4 @@
|
||||
{"file":".trellis/spec/frontend/direct-edit-client.md","reason":"Reuse EditSession, handle and preview ownership."}
|
||||
{"file":".trellis/spec/frontend/state-management.md","reason":"Follow state ownership and selection update patterns."}
|
||||
{"file":".trellis/spec/frontend/component-guidelines.md","reason":"Keep JunctionWorkspace composition and controls consistent."}
|
||||
{"file":".trellis/spec/guides/cross-layer-thinking-guide.md","reason":"Avoid duplicating compiler-owned object identity."}
|
||||
@@ -0,0 +1,6 @@
|
||||
# 实施清单
|
||||
|
||||
1. 建立对象选择键与结构对象到设施/handle/诊断的归一化工具。
|
||||
2. 将 `JunctionWorkspace` 的设施选择、诊断定位和参数高亮统一到 `selectedObjectKey`。
|
||||
3. 为当前对象参数增加全局继承、局部调整和恢复全局控件,复用现有 EditSession 回调。
|
||||
4. 增加选择与覆盖交互单测,运行完整前后端质量门禁。
|
||||
@@ -0,0 +1,44 @@
|
||||
# JunctionTools Stage 2 选择与作用域覆盖
|
||||
|
||||
## Goal
|
||||
|
||||
TBD.
|
||||
|
||||
## Requirements
|
||||
|
||||
- TBD
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] TBD
|
||||
|
||||
## Notes
|
||||
|
||||
- Keep `prd.md` focused on requirements, constraints, and acceptance criteria.
|
||||
- Lightweight tasks can remain PRD-only.
|
||||
- For complex tasks, add `design.md` for technical design and `implement.md` for execution planning before `task.py start`.
|
||||
# JunctionTools Stage 2:对象选择与作用域覆盖
|
||||
|
||||
## 目标
|
||||
|
||||
让路口对象在列表、地图设施、手柄和诊断之间共享唯一选择键,并让稳定的 direct-edit 参数明确显示全局继承或局部覆盖状态。
|
||||
|
||||
## 范围
|
||||
|
||||
- 增加 `selectedObjectKey` 状态,列表/设施/诊断定位统一写入它。
|
||||
- 对道路臂、角部、横道和停止线显示当前对象的参数归属。
|
||||
- 提供“使用全局值 / 单独调整 / 恢复全局值”交互;局部调整只作用于当前对象。
|
||||
- 保持现有预览、撤销/重做、重置对象、放弃草稿和版本冲突协议。
|
||||
|
||||
## 非范围
|
||||
|
||||
- 不实现新的几何算法或高级设施。
|
||||
- 不根据客户端节点数量推断路口形态。
|
||||
- 不把 warning/blocking 标准诊断变成新的保存门禁。
|
||||
|
||||
## 验收标准
|
||||
|
||||
1. 列表、地图设施和诊断定位使用同一个 `selectedObjectKey`,切换对象不会残留旧表单。
|
||||
2. 未单独调整的对象显示全局继承;局部修改只影响当前对象,并能恢复全局。
|
||||
3. 当前对象重置与放弃全部草稿行为保持现有语义,预览请求仍经过同一 EditSession。
|
||||
4. 单测覆盖选择归一化、作用域切换和恢复全局;客户端类型检查、单测、构建、格式检查及后端回归通过。
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"id": "junctiontools-stage2-selection-overrides",
|
||||
"name": "junctiontools-stage2-selection-overrides",
|
||||
"title": "JunctionTools Stage 2 选择与作用域覆盖",
|
||||
"description": "",
|
||||
"status": "in_progress",
|
||||
"dev_type": null,
|
||||
"scope": null,
|
||||
"package": null,
|
||||
"priority": "P2",
|
||||
"creator": "dingkang",
|
||||
"assignee": "dingkang",
|
||||
"createdAt": "2026-09-07",
|
||||
"completedAt": null,
|
||||
"branch": null,
|
||||
"base_branch": "main",
|
||||
"worktree_path": null,
|
||||
"commit": null,
|
||||
"pr_url": null,
|
||||
"subtasks": [],
|
||||
"children": [],
|
||||
"parent": null,
|
||||
"relatedFiles": [],
|
||||
"notes": "",
|
||||
"meta": {}
|
||||
}
|
||||
@@ -94,6 +94,7 @@ function App() {
|
||||
const [status, setStatus] = useState('正在加载工作台...');
|
||||
const [filter, setFilter] = useState<'all' | 'candidates' | 'other'>('all');
|
||||
const [marking, setMarking] = useState<Record<string, unknown> | null>(null);
|
||||
const [selectedObjectKey, setSelectedObjectKey] = useState<string | null>(null);
|
||||
const [junctionRoute, setJunctionRoute] = useState<JunctionRef | null>(() => {
|
||||
if (typeof window === 'undefined') return null;
|
||||
const match = window.location.pathname.match(/^\/junction\/(node|cluster)\/([^/]+)$/);
|
||||
@@ -900,6 +901,14 @@ function App() {
|
||||
};
|
||||
const handleFeature = (properties: Record<string, unknown>) => {
|
||||
setMarking(properties);
|
||||
const objectKey = properties.signal_uid
|
||||
? `signal:${String(properties.signal_uid)}`
|
||||
: properties.crossing_node_id
|
||||
? `${properties.provenance === 'stop-line' ? 'stop-line' : 'crossing'}:${String(properties.crossing_node_id)}`
|
||||
: properties.road_id
|
||||
? `road-arm:${String(properties.road_id)}`
|
||||
: null;
|
||||
setSelectedObjectKey(objectKey);
|
||||
// A crosswalk is six features but one editable thing; a stop line is one.
|
||||
// `provenance` picks which, and therefore which layer holds its siblings —
|
||||
// the two share `crossing_node_id`, so keying on that alone would merge a
|
||||
@@ -1156,6 +1165,8 @@ function App() {
|
||||
dirty={Boolean(junctionSession.dirty || signalDirty)}
|
||||
state={state}
|
||||
diagnostics={junctionDiagnostics}
|
||||
selectedObjectKey={selectedObjectKey}
|
||||
onSelectObject={(key) => setSelectedObjectKey(key)}
|
||||
facilitySummary={junctionFacilitySummary}
|
||||
onClose={closeJunction}
|
||||
onEnableComplex={
|
||||
@@ -1236,6 +1247,9 @@ function App() {
|
||||
onSignalStatus={setStatus}
|
||||
onUpdateSignal={updateSignal}
|
||||
onSelectFacility={(facility) => {
|
||||
setSelectedObjectKey(
|
||||
`${facility.kind === 'crosswalk' ? 'crossing' : facility.kind}:${facility.id.split(':').slice(1).join(':')}`,
|
||||
);
|
||||
const source =
|
||||
facility.kind === 'crosswalk'
|
||||
? state.layers.crosswalks
|
||||
|
||||
@@ -17,6 +17,8 @@ interface Props {
|
||||
session: JunctionSession;
|
||||
dirty?: boolean;
|
||||
diagnostics?: Array<{ id: string; message: string; rule: string; severity?: string }>;
|
||||
selectedObjectKey?: string | null;
|
||||
onSelectObject?: (key: string) => void;
|
||||
facilitySummary?: { crosswalks: number; stopLines: number; signals: number };
|
||||
state?: WorkbenchState;
|
||||
onClose: () => void;
|
||||
@@ -59,6 +61,8 @@ export function JunctionWorkspace({
|
||||
onUpdateComplexNodes,
|
||||
onCandidateMarkersChange,
|
||||
diagnostics = [],
|
||||
selectedObjectKey = null,
|
||||
onSelectObject,
|
||||
facilitySummary = { crosswalks: 0, stopLines: 0, signals: 0 },
|
||||
state,
|
||||
handles = [],
|
||||
@@ -228,7 +232,24 @@ export function JunctionWorkspace({
|
||||
</p>
|
||||
<dl>
|
||||
<dt>道路臂</dt>
|
||||
<dd>{structure.arms.map((arm) => arm.label).join('、') || '无'}</dd>
|
||||
<dd>
|
||||
{structure.arms.length ? (
|
||||
<span className="junction-workspace__object-list">
|
||||
{structure.arms.map((arm) => (
|
||||
<button
|
||||
type="button"
|
||||
key={arm.key}
|
||||
className={selectedObjectKey === arm.key ? 'is-selected' : undefined}
|
||||
onClick={() => onSelectObject?.(arm.key)}
|
||||
>
|
||||
{arm.label}
|
||||
</button>
|
||||
))}
|
||||
</span>
|
||||
) : (
|
||||
'无'
|
||||
)}
|
||||
</dd>
|
||||
<dt>角部</dt>
|
||||
<dd>{structure.corners.length ? structure.corners.map((corner) => corner.label).join('、') : '无'}</dd>
|
||||
<dt>设施</dt>
|
||||
@@ -242,10 +263,12 @@ export function JunctionWorkspace({
|
||||
<ul aria-label="标准诊断">
|
||||
{standardDiagnostics.map((item) => (
|
||||
<li key={item.id} className={item.severity === 'blocking' ? 'blocking' : undefined}>
|
||||
<strong>
|
||||
{item.severity === 'pass' ? '通过' : item.severity === 'warning' ? '警告' : '阻塞'}
|
||||
</strong>{' '}
|
||||
{item.message}
|
||||
<button type="button" onClick={() => onSelectObject?.(item.objectKey)}>
|
||||
<strong>
|
||||
{item.severity === 'pass' ? '通过' : item.severity === 'warning' ? '警告' : '阻塞'}
|
||||
</strong>{' '}
|
||||
{item.message}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
Reference in new issue
Block a user