Skip to content

Commit 1f660c1

Browse files
committed
Enable quantity formatting in editable property grid
1 parent 08bec08 commit 1f660c1

File tree

8 files changed

+135
-44
lines changed

8 files changed

+135
-44
lines changed

apps/test-viewer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@itwin/measure-tools-react": "workspace:*",
3636
"@itwin/one-click-lca-react": "workspace:*",
3737
"@itwin/presentation-common": "^5.1.1",
38-
"@itwin/presentation-components": "^5.12.5",
38+
"@itwin/presentation-components": "^5.12.6",
3939
"@itwin/presentation-frontend": "^5.1.1",
4040
"@itwin/presentation-hierarchies": "^1.7.1",
4141
"@itwin/presentation-hierarchies-react": "^1.9.1",

apps/test-viewer/pnpm-lock.yaml

Lines changed: 58 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/test-viewer/src/UiProvidersConfig.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ const configuredUiItems = new Map<string, UiItem>([
216216
getWidgets: () => {
217217
return [
218218
createPropertyGrid({
219+
editorSystem: "legacy",
219220
autoExpandChildCategories: true,
220221
ancestorsNavigationControls: (props) => <AncestorsNavigationControls {...props} />,
221222
contextMenuItems: [
@@ -231,6 +232,11 @@ const configuredUiItems = new Map<string, UiItem>([
231232
console.log(`PropertyGrid [${feature}] used`);
232233
},
233234
selectionStorage: unifiedSelectionStorage,
235+
isPropertyEditingEnabled: true,
236+
onPropertyUpdated: async ({ newValue }) => {
237+
console.log(`Updated new value`, newValue);
238+
return true;
239+
},
234240
}),
235241
];
236242
},

apps/test-viewer/src/components/Viewer.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { useCallback, useEffect, useState } from "react";
77
import { useNavigate, useSearchParams } from "react-router-dom";
88
import { IModelApp, IModelConnection } from "@itwin/core-frontend";
9-
import { SchemaFormatsProvider, SchemaKey, SchemaMatchType, SchemaUnitProvider } from "@itwin/ecschema-metadata";
9+
import { SchemaFormatsProvider, SchemaUnitProvider } from "@itwin/ecschema-metadata";
1010
import { ECSchemaRpcInterface } from "@itwin/ecschema-rpcinterface-common";
1111
import { FrontendDevTools } from "@itwin/frontend-devtools";
1212
import { ArcGisAccessClient } from "@itwin/map-layers-auth";
@@ -90,14 +90,12 @@ function ViewerWithOptions() {
9090
}
9191

9292
function onIModelConnected(imodel: IModelConnection) {
93-
// need this temporarily for e2e tests, until a fix for https://github.com/iTwin/itwinjs-core/issues/7496 is consumed
94-
setTimeout(() => {
95-
IModelConnection.onOpen.raiseEvent(imodel);
96-
}, 1000);
9793
const setupFormatsProvider = async () => {
9894
try {
99-
const schema = await imodel.schemaContext.getSchema(new SchemaKey("AecUnits", SchemaMatchType.Latest));
100-
if (!schema) throw new Error("AecUnits schema not found in iModel");
95+
// const schema = await imodel.schemaContext.getSchema(new SchemaKey("AecUnits", SchemaMatchType.Latest));
96+
// if (!schema) {
97+
// throw new Error("AecUnits schema not found in iModel");
98+
// }
10199

102100
const schemaFormatsProvider = new SchemaFormatsProvider(imodel.schemaContext, IModelApp.quantityFormatter.activeUnitSystem);
103101
const removeListener = IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener((args) => {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix quantity formatting not working in editable property grid.",
4+
"packageName": "@itwin/property-grid-react",
5+
"email": "35135765+grigasp@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/itwin/property-grid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"@itwin/imodel-components-react": "^5.13.0",
100100
"@itwin/oidc-signin-tool": "^5.0.1",
101101
"@itwin/presentation-common": "^5.1.1",
102-
"@itwin/presentation-components": "^5.12.5",
102+
"@itwin/presentation-components": "^5.12.6",
103103
"@itwin/presentation-frontend": "^5.1.1",
104104
"@itwin/webgl-compatibility": "^5.1.1",
105105
"@playwright/test": "^1.48.2",

packages/itwin/property-grid/pnpm-lock.yaml

Lines changed: 44 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/itwin/property-grid/src/property-grid-react/PropertyGridComponent.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { useActiveIModelConnection } from "@itwin/appui-react";
7+
import { SchemaMetadataContextProvider } from "@itwin/presentation-components";
78
import { MultiElementPropertyGrid } from "./components/MultiElementPropertyGrid.js";
89
import { TelemetryContextProvider } from "./hooks/UseTelemetryContext.js";
910
import { PreferencesContextProvider } from "./PropertyGridPreferencesContext.js";
1011

1112
import type { TelemetryContextProviderProps } from "./hooks/UseTelemetryContext.js";
1213
import type { MultiElementPropertyGridProps } from "./components/MultiElementPropertyGrid.js";
1314
import type { PreferencesStorage } from "./api/PreferencesStorage.js";
15+
import type { IModelConnection } from "@itwin/core-frontend";
1416

1517
/**
1618
* Props for `PropertyGridComponent`.
@@ -35,10 +37,16 @@ export function PropertyGridComponent({ preferencesStorage, onPerformanceMeasure
3537
}
3638

3739
return (
38-
<TelemetryContextProvider onPerformanceMeasured={onPerformanceMeasured} onFeatureUsed={onFeatureUsed}>
39-
<PreferencesContextProvider storage={preferencesStorage}>
40-
<MultiElementPropertyGrid {...props} imodel={imodel} />
41-
</PreferencesContextProvider>
42-
</TelemetryContextProvider>
40+
<SchemaMetadataContextProvider imodel={imodel} schemaContextProvider={getSchemaContext}>
41+
<TelemetryContextProvider onPerformanceMeasured={onPerformanceMeasured} onFeatureUsed={onFeatureUsed}>
42+
<PreferencesContextProvider storage={preferencesStorage}>
43+
<MultiElementPropertyGrid {...props} imodel={imodel} />
44+
</PreferencesContextProvider>
45+
</TelemetryContextProvider>
46+
</SchemaMetadataContextProvider>
4347
);
4448
}
49+
50+
function getSchemaContext(imodel: IModelConnection) {
51+
return imodel.schemaContext;
52+
}

0 commit comments

Comments
 (0)