Files
DOSSIER/src/UnitsSettingsApp.jsx
T
karim 375487c10c i18n DE/EN + DossierSettings panel + English file renames
i18n:
- src/i18n/de.json + en.json: 200+ keys covering all main panels
- src/i18n/index.js: t(key, vars) reads window.DOSSIER_LANG
- panel_base.py: injects window.DOSSIER_LANG from dossier_settings.json
- EbenenManager, GeschossManager, AusschnitteApp, LayoutsApp: all
  context menus and main labels use t()

DossierSettings panel:
- DossierSettingsApp.jsx: language toggle (DE/EN pill) + launcher status
- toolbar.py: OPEN_SETTINGS opens new Rhino-hosted satellite window,
  SAVE_LANG writes lang to dossier_settings.json + reloads all panels

File renames (JSX → English):
- ZeichnungsebenenApp → DrawingLevelsApp
- GeschossManager/Dialog/Settings → Floor*
- AusschnitteApp/Settings → Viewports*
- EbenenManager/Settings → Layer*
- GestaltungApp → StylesApp, OberleisteApp → ToolbarApp
- WerkzeugeApp → ToolsApp, DimensionenApp → DimensionsApp
- MassstabApp → ScaleApp, KameraApp → CameraApp
- MasseSettingsApp → UnitsSettingsApp
- ConfirmDeleteEbene → ConfirmDeleteLayer
- AusschnittLayerDialog → ViewportLayerDialog

Python module renames:
- rhinopanel.py → layers_panel.py
- oberleiste.py → toolbar.py
- gestaltung.py → styles.py
- werkzeuge.py → tools.py
- dimensionen.py → dimensions.py
- startup.py _MODULE_TO_PY updated, all cross-imports fixed
2026-06-06 11:09:33 +02:00

180 lines
5.7 KiB
React

// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2026 Karim Gabriele Varano
import { useEffect, useState } from 'react'
import Icon from './components/Icon'
import { BarButton, BarCombo, BAR_H } from './components/BarControls'
import { onMessage, notifyReady,
masseSetActive as setActive,
masseSavePreset as savePreset,
masseDeletePreset as deletePreset } from './lib/rhinoBridge'
const RAUM_RUNDUNGS_LABELS = {
'exakt': 'Exakt (2 Nachk.)',
'0.01': 'auf 0.01 m²',
'0.1': 'auf 0.1 m²',
'0.5': 'auf 0.5 m²',
'1': 'auf 1 m²',
}
const labelXs = {
fontSize: 9, color: 'var(--text-muted)',
textTransform: 'uppercase', letterSpacing: '0.06em',
fontWeight: 600,
}
const pillInput = {
height: BAR_H,
background: 'var(--bg-input)',
border: '1px solid var(--border)',
borderRadius: 999,
color: 'var(--text-primary)',
fontSize: 11, fontFamily: 'var(--font)',
padding: '0 10px',
outline: 'none',
boxSizing: 'border-box',
}
function Row({ label, children }) {
return (
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{ ...labelXs, width: 130, flexShrink: 0 }}>{label}</span>
<div style={{ flex: 1 }}>{children}</div>
</div>
)
}
export default function MasseSettingsApp() {
const [presets, setPresets] = useState([])
const [activeId, setActiveId] = useState(null)
useEffect(() => {
onMessage('STATE', (s) => {
setPresets(s.presets || [])
setActiveId(s.activeId || null)
})
notifyReady()
}, [])
const active = presets.find(p => p.id === activeId) || presets[0]
const update = (patch) => {
if (!active) return
savePreset({ ...active, ...patch })
}
const addNew = () => {
const name = (window.prompt('Name für neues Mass:') || '').trim()
if (!name) return
const tmpl = active || { raumRundung: '0.1', dimDezimalstellen: 2, dimEinheit: 'm' }
savePreset({
name,
raumRundung: tmpl.raumRundung,
dimDezimalstellen: tmpl.dimDezimalstellen,
dimEinheit: tmpl.dimEinheit,
})
}
const remove = () => {
if (!active) return
if (presets.length <= 1) {
window.alert('Mindestens ein Mass muss erhalten bleiben.')
return
}
if (!window.confirm(`Mass "${active.name}" löschen?`)) return
deletePreset(active.id)
}
return (
<div style={{
padding: 16,
display: 'flex', flexDirection: 'column', gap: 14,
fontFamily: 'var(--font)', color: 'var(--text-primary)',
background: 'var(--bg-panel)', minHeight: '100vh',
boxSizing: 'border-box',
}}>
{/* Header */}
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<Icon name="straighten" size={14} style={{ color: 'var(--accent)' }} />
<span style={{ fontSize: 13, fontWeight: 600 }}>Masse</span>
<span style={{ fontSize: 10, color: 'var(--text-muted)', flex: 1 }}>
Globale Vorgaben für Raum-Rundung und Mass-Linien
</span>
</div>
{/* Picker + Aktionen */}
<Row label="Aktiv">
<div style={{ display: 'flex', gap: 4 }}>
<BarCombo stretch
value={activeId || (active?.id || '')}
onChange={(v) => setActive(v)}>
{presets.map(p => (
<option key={p.id} value={p.id}>{p.name}</option>
))}
</BarCombo>
<BarButton icon="add"
onClick={addNew}
title="Neues Mass anlegen (mit aktuellen Werten als Vorlage)" />
<BarButton icon="delete"
onClick={remove}
disabled={presets.length <= 1}
title="Aktives Mass löschen" />
</div>
</Row>
{active && (
<div style={{
display: 'flex', flexDirection: 'column', gap: 10,
padding: 12, borderRadius: 'var(--r-lg)',
background: 'var(--bg-section)',
border: '1px solid var(--border-light)',
}}>
<Row label="Name">
<input
type="text"
value={active.name}
onChange={(e) => update({ name: e.target.value })}
style={{ ...pillInput, width: '100%' }}
/>
</Row>
<Row label="Raum-Rundung">
<BarCombo stretch
value={active.raumRundung}
onChange={(v) => update({ raumRundung: v })}>
{Object.entries(RAUM_RUNDUNGS_LABELS).map(([v, l]) => (
<option key={v} value={v}>{l}</option>
))}
</BarCombo>
</Row>
<Row label="Mass-Dezimalstellen">
<BarCombo stretch
value={String(active.dimDezimalstellen)}
onChange={(v) => update({ dimDezimalstellen: parseInt(v, 10) })}>
{[0, 1, 2, 3, 4].map(n => (
<option key={n} value={n}>{n} {n === 1 ? 'Stelle' : 'Stellen'}</option>
))}
</BarCombo>
</Row>
<Row label="Mass-Einheit">
<BarCombo stretch
value={active.dimEinheit}
onChange={(v) => update({ dimEinheit: v })}>
<option value="m">m (Meter)</option>
<option value="cm">cm (Zentimeter)</option>
<option value="mm">mm (Millimeter)</option>
</BarCombo>
</Row>
</div>
)}
<div style={{ fontSize: 10, color: 'var(--text-muted)',
padding: '6px 8px',
background: 'var(--bg-section)',
borderRadius: 4, lineHeight: 1.5 }}>
Änderungen werden sofort auf alle Räume angewendet. Pro-Raum gesetzte
Rundungen (im Element-Panel) haben Vorrang vor dem aktiven Mass.
Mass-Linien-Anwendung kommt im nächsten Schritt.
</div>
</div>
)
}