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
@@ -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