Scope git commit to current diagram + fix complete JSON export/import

- Git commit: "Current diagram only" checkbox stages only that diagram's
  JSON file instead of all diagrams
- JSON export now includes: waypoints, twisted_pair, twist_pitch, shielded,
  show_size_label, bundle_id, bundle_label, sheet_id, sheets, wire_bundles
- JSON import reconstructs sheets and bundles with remapped IDs so restored
  diagrams are exact copies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-24 20:02:19 -04:00
parent 7ae79bc9aa
commit 072e620d56
6 changed files with 130 additions and 21 deletions
+21 -2
View File
@@ -283,13 +283,25 @@ def export_json(diagram_id: int, db: Session = Depends(get_db)):
if not diagram:
raise HTTPException(status_code=404, detail="Diagram not found")
# Build bundle id→label map for wire export
bundle_label = {b.id: b.label for b in diagram.wire_bundles}
data = {
"id": diagram.id,
"name": diagram.name,
"description": diagram.description,
"sheets": [
{"id": s.id, "name": s.name, "position": s.position}
for s in diagram.sheets
],
"wire_bundles": [
{"id": b.id, "label": b.label, "jacket_color": b.jacket_color}
for b in diagram.wire_bundles
],
"devices": [
{
"id": d.id, "device_type": d.device_type, "label": d.label,
"id": d.id, "sheet_id": d.sheet_id,
"device_type": d.device_type, "label": d.label,
"reference": d.reference, "x": d.x, "y": d.y,
"width": d.width, "height": d.height,
"properties": d.properties, "pins": d.pins,
@@ -298,12 +310,19 @@ def export_json(diagram_id: int, db: Session = Depends(get_db)):
],
"wires": [
{
"id": w.id, "label": w.label,
"id": w.id, "sheet_id": w.sheet_id, "label": w.label,
"from_device_id": w.from_device_id, "from_pin": w.from_pin,
"to_device_id": w.to_device_id, "to_pin": w.to_pin,
"color_primary": w.color_primary, "color_stripe": w.color_stripe,
"gauge": w.gauge, "length": w.length, "length_unit": w.length_unit,
"notes": w.notes,
"waypoints": w.waypoints or [],
"twisted_pair": bool(w.twisted_pair),
"twist_pitch": w.twist_pitch,
"shielded": bool(w.shielded),
"show_size_label": bool(w.show_size_label),
"bundle_id": w.bundle_id,
"bundle_label": bundle_label.get(w.bundle_id),
}
for w in diagram.wires
],