diff --git a/react-components/src/architecture/base/domainObjects/DomainObject.ts b/react-components/src/architecture/base/domainObjects/DomainObject.ts index 9d0a832ba46..b7f0d19e278 100644 --- a/react-components/src/architecture/base/domainObjects/DomainObject.ts +++ b/react-components/src/architecture/base/domainObjects/DomainObject.ts @@ -25,6 +25,7 @@ import { DeleteDomainObjectCommand } from '../concreteCommands/DeleteDomainObjec import { CopyToClipboardCommand } from '../concreteCommands/CopyToClipboardCommand'; import { type BaseCommand } from '../commands/BaseCommand'; import { type Transaction } from '../undo/Transaction'; +import { ToggleMetricUnitsCommand } from '../concreteCommands/ToggleMetricUnitsCommand'; /** * Represents an abstract base class for domain objects. @@ -369,7 +370,11 @@ export abstract class DomainObject { } public getPanelToolbar(): BaseCommand[] { - return [new DeleteDomainObjectCommand(this), new CopyToClipboardCommand()]; + return [ + new DeleteDomainObjectCommand(this), + new CopyToClipboardCommand(), + new ToggleMetricUnitsCommand() + ]; } // ================================================== diff --git a/react-components/src/architecture/concrete/measurements/MeasurementTool.ts b/react-components/src/architecture/concrete/measurements/MeasurementTool.ts index e1029decb7d..80c4d53e05a 100644 --- a/react-components/src/architecture/concrete/measurements/MeasurementTool.ts +++ b/react-components/src/architecture/concrete/measurements/MeasurementTool.ts @@ -7,7 +7,6 @@ import { type BaseCreator } from '../../base/domainObjectsHelpers/BaseCreator'; import { ShowMeasurementsOnTopCommand } from './commands/ShowMeasurementsOnTopCommand'; import { SetMeasurementTypeCommand } from './commands/SetMeasurementTypeCommand'; import { type TranslateKey } from '../../base/utilities/TranslateKey'; -import { ToggleMetricUnitsCommand } from '../../base/concreteCommands/ToggleMetricUnitsCommand'; import { PrimitiveEditTool } from '../primitives/PrimitiveEditTool'; import { MeasureLineDomainObject } from './MeasureLineDomainObject'; import { MeasureBoxDomainObject } from './MeasureBoxDomainObject'; @@ -49,7 +48,6 @@ export class MeasurementTool extends PrimitiveEditTool { new SetMeasurementTypeCommand(PrimitiveType.Box), undefined, // Separator new UndoCommand(), - new ToggleMetricUnitsCommand(), new ShowMeasurementsOnTopCommand() ]; } diff --git a/react-components/src/architecture/concrete/observations/ObservationsDomainObject.ts b/react-components/src/architecture/concrete/observations/ObservationsDomainObject.ts index c4bde335ff6..13ab1f2446d 100644 --- a/react-components/src/architecture/concrete/observations/ObservationsDomainObject.ts +++ b/react-components/src/architecture/concrete/observations/ObservationsDomainObject.ts @@ -12,6 +12,7 @@ import { PanelInfo } from '../../base/domainObjectsHelpers/PanelInfo'; import { type Observation, ObservationStatus } from './types'; import { partition, remove } from 'lodash'; import { type ObservationProperties } from './models'; +import { Quantity } from '../../base/domainObjectsHelpers/Quantity'; export class ObservationsDomainObject extends VisualDomainObject { private _selectedObservation: Observation | undefined; @@ -54,10 +55,12 @@ export class ObservationsDomainObject extends VisualDomainObject { const header = { fallback: 'Observation' }; info.setHeader(header); - info.add({ fallback: 'X', value: this._selectedObservation?.properties.positionX }); - info.add({ fallback: 'Y', value: this._selectedObservation?.properties.positionY }); - info.add({ fallback: 'Z', value: this._selectedObservation?.properties.positionZ }); - + if (this._selectedObservation !== undefined) { + const properties = this._selectedObservation.properties; + info.add({ fallback: 'X', value: properties.positionX, quantity: Quantity.Length }); + info.add({ fallback: 'Y', value: properties.positionY, quantity: Quantity.Length }); + info.add({ fallback: 'Z', value: properties.positionZ, quantity: Quantity.Length }); + } return info; } diff --git a/react-components/src/components/Architecture/DomainObjectPanel.tsx b/react-components/src/components/Architecture/DomainObjectPanel.tsx index 6b8a5176f96..eddd9050b97 100644 --- a/react-components/src/components/Architecture/DomainObjectPanel.tsx +++ b/react-components/src/components/Architecture/DomainObjectPanel.tsx @@ -37,16 +37,16 @@ export const DomainObjectPanel = (): ReactElement => { useEffect(() => { DomainObjectPanelUpdater.setDomainObjectDelegate(setCurrentDomainObjectInfo); - if (commands === undefined || info === undefined) { - return; - } - // Set in the get string on the copy command if any + }, [setCurrentDomainObjectInfo, commands]); + + // Fore the getString to be updated + if (commands !== undefined && info !== undefined) { for (const command of commands) { if (command instanceof CopyToClipboardCommand) command.getString = () => toString(info, t, unitSystem); } - }, [setCurrentDomainObjectInfo, commands]); + } const { t } = useTranslation();