From e725b52590dc06c7568c8244123cea0e950accf1 Mon Sep 17 00:00:00 2001 From: taDuc Date: Tue, 12 May 2026 21:54:56 +0700 Subject: [PATCH] editor panel improve experience --- src/app/editor/[id]/page.tsx | 21 --- .../editor/GeometryBindingPanel.tsx | 38 +++- .../editor/ProjectEntityRefsPanel.tsx | 178 +++++++++++------- .../editor/SelectedGeometryPanel.tsx | 92 +-------- 4 files changed, 145 insertions(+), 184 deletions(-) diff --git a/src/app/editor/[id]/page.tsx b/src/app/editor/[id]/page.tsx index 42b7e2b..01faece 100644 --- a/src/app/editor/[id]/page.tsx +++ b/src/app/editor/[id]/page.tsx @@ -47,13 +47,9 @@ import { } from "@/uhm/lib/editor/snapshot/editorSnapshot"; import { buildClientEntityId, - formatEntityNamesForDisplay, mergeEntitySearchResults, } from "@/uhm/lib/editor/entity/entityBinding"; import { buildFeatureEntityPatch } from "@/uhm/lib/editor/entity/entityBinding"; -import { - formatBindingIdsForDisplay, -} from "@/uhm/lib/editor/geometry/geometryMetadata"; import { loadBackgroundLayerVisibilityFromStorage, persistBackgroundLayerVisibility, @@ -826,10 +822,6 @@ export default function Page() { setGeometryMetaForm((prev) => ({ ...prev, [key]: value })); }; - const handleEntityIdsChange = (values: string[]) => { - setSelectedGeometryEntityIds(uniqueEntityIds(values)); - }; - const handleAddEntityRefToProject = useCallback((entity: Entity) => { const id = String(entity.id || "").trim(); if (!id) return; @@ -1600,19 +1592,6 @@ export default function Page() { {!wikiOnly && selectedFeature ? ( g.id === selectedGeometryId) || null; }, [rows, selectedGeometryId]); + const visibleRows = useMemo(() => { + return rows + .filter((g) => g.id !== selectedGeometryId) + .sort((a, b) => { + const aBound = bindingSet.has(a.id); + const bBound = bindingSet.has(b.id); + if (aBound !== bBound) return aBound ? -1 : 1; + return a.id.localeCompare(b.id); + }); + }, [bindingSet, rows, selectedGeometryId]); const handleFocusKeyDown = (event: KeyboardEvent, geometryId: string) => { if (!canFocusGeometry) return; @@ -174,8 +184,7 @@ export default function GeometryBindingPanel({ {collapsed ? null : rows.length ? (
- {rows - .filter((g) => g.id !== selectedGeometryId) + {visibleRows .map((g) => { const isBound = bindingSet.has(g.id); return ( @@ -184,8 +193,8 @@ export default function GeometryBindingPanel({ style={{ padding: "8px", borderRadius: "6px", - border: "1px solid #1f2937", - background: "transparent", + border: isBound ? "1px solid rgba(20, 184, 166, 0.65)" : "1px solid #1f2937", + background: isBound ? "rgba(20, 184, 166, 0.12)" : "transparent", display: "flex", alignItems: "center", gap: 10, @@ -219,6 +228,7 @@ export default function GeometryBindingPanel({ > {g.label || g.id} + {isBound ? bound : null} {g.isNew ? : null}
- {collapsed ? null : entityRefs.length ? ( + {collapsed ? null : sortedEntityRefs.length ? (
- {entityRefs.map((e) => ( -
- - {canBindToggle ? ( - ) : null} -
- ))} + {canBindToggle ? ( + + ) : null} +
+ ); + })} ) : ( @@ -358,6 +384,24 @@ const entityInputStyle: CSSProperties = { fontSize: "13px", }; +const boundBadgeStyle: CSSProperties = { + display: "inline-flex", + alignItems: "center", + justifyContent: "center", + flex: "0 0 auto", + height: 17, + padding: "0 6px", + borderRadius: 999, + border: "1px solid rgba(45, 212, 191, 0.5)", + background: "rgba(20, 184, 166, 0.18)", + color: "#99f6e4", + fontSize: 10, + fontWeight: 900, + lineHeight: 1, + textTransform: "uppercase", + letterSpacing: 0, +}; + function LockIcon() { return (
- Entity & Geometry + Geometry property
-
- ); - })} - - ) : ( -
- Chưa có entity nào được gắn. -
- )} -