Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(react-components): Move m/ft button to the domain object card #4731

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
];
}

// ==================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -49,7 +48,6 @@ export class MeasurementTool extends PrimitiveEditTool {
new SetMeasurementTypeCommand(PrimitiveType.Box),
undefined, // Separator
new UndoCommand(),
new ToggleMetricUnitsCommand(),
new ShowMeasurementsOnTopCommand()
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

nilscognite marked this conversation as resolved.
Show resolved Hide resolved
const { t } = useTranslation();

Expand Down
Loading