@itwin/grouping-mapping-widget 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/decorators/BboxDimensionsDecorator.js +14 -17
- package/lib/cjs/decorators/BboxDimensionsDecorator.js.map +1 -1
- package/lib/cjs/formula/FormulaDataTypeResolver.js +1 -2
- package/lib/cjs/formula/FormulaDataTypeResolver.js.map +1 -1
- package/lib/cjs/formula/FormulaFunctionProvider.js +2 -3
- package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/cjs/test/GroupingMappingCustomUI.test.js +1 -2
- package/lib/cjs/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/cjs/test/PropertyFieldsHelpers.js +4 -7
- package/lib/cjs/test/PropertyFieldsHelpers.js.map +1 -1
- package/lib/cjs/test/QueryBuilder.test.js +3 -4
- package/lib/cjs/test/QueryBuilder.test.js.map +1 -1
- package/lib/cjs/widget/GroupingMappingWidget.d.ts +2 -2
- package/lib/cjs/widget/GroupingMappingWidget.js +1 -3
- package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/cjs/widget/components/ActionPanel.scss +2 -3
- package/lib/cjs/widget/components/BlockingOverlay.scss +4 -5
- package/lib/cjs/widget/components/CalculatedPropertyAction.js +3 -4
- package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyAction.scss +1 -2
- package/lib/cjs/widget/components/CalculatedPropertyActionWithVisuals.js +6 -8
- package/lib/cjs/widget/components/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyActionWithVisuals.scss +1 -2
- package/lib/cjs/widget/components/ConfirmMappingsImport.js +4 -5
- package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/widget/components/ConfirmMappingsImport.scss +7 -8
- package/lib/cjs/widget/components/CustomCalculationAction.js +10 -14
- package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationAction.scss +1 -2
- package/lib/cjs/widget/components/DeleteModal.js +1 -1
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.scss +1 -2
- package/lib/cjs/widget/components/GroupAction.js +5 -7
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.scss +0 -1
- package/lib/cjs/widget/components/GroupColorLegend.scss +0 -1
- package/lib/cjs/widget/components/GroupColorToggle.d.ts +2 -2
- package/lib/cjs/widget/components/GroupColorToggle.js.map +1 -1
- package/lib/cjs/widget/components/GroupDetails.js +1 -1
- package/lib/cjs/widget/components/GroupDetails.js.map +1 -1
- package/lib/cjs/widget/components/GroupDetailsStep.scss +1 -2
- package/lib/cjs/widget/components/GroupMenuActions.scss +1 -2
- package/lib/cjs/widget/components/GroupPropertyAction.js +5 -6
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.scss +13 -16
- package/lib/cjs/widget/components/GroupPropertyUtils.js +2 -3
- package/lib/cjs/widget/components/GroupPropertyUtils.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.js +3 -4
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.scss +9 -11
- package/lib/cjs/widget/components/GroupingMapping.js +16 -20
- package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMapping.scss +2 -3
- package/lib/cjs/widget/components/GroupingMappingContext.js +9 -13
- package/lib/cjs/widget/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMappingRouter.js +5 -5
- package/lib/cjs/widget/components/GroupingMappingRouter.js.map +1 -1
- package/lib/cjs/widget/components/GroupsAddButton.scss +1 -2
- package/lib/cjs/widget/components/GroupsVisualization.js +1 -1
- package/lib/cjs/widget/components/GroupsVisualization.js.map +1 -1
- package/lib/cjs/widget/components/GroupsVisualization.scss +3 -3
- package/lib/cjs/widget/components/GroupsVisualizationActions.scss +0 -1
- package/lib/cjs/widget/components/HorizontalTile.js +4 -1
- package/lib/cjs/widget/components/HorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/HorizontalTile.scss +16 -15
- package/lib/cjs/widget/components/Mapping.js +27 -31
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/Mapping.scss +6 -12
- package/lib/cjs/widget/components/MappingAction.js +7 -9
- package/lib/cjs/widget/components/MappingAction.js.map +1 -1
- package/lib/cjs/widget/components/MappingAction.scss +1 -2
- package/lib/cjs/widget/components/MappingImportWizardModal.js +3 -2
- package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -1
- package/lib/cjs/widget/components/MappingImportWizardModal.scss +4 -5
- package/lib/cjs/widget/components/PropertyAction.js +4 -5
- package/lib/cjs/widget/components/PropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/PropertyMenu.js +3 -3
- package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
- package/lib/cjs/widget/components/PropertyMenu.scss +2 -2
- package/lib/cjs/widget/components/PropertyMenuWithVisualization.scss +1 -2
- package/lib/cjs/widget/components/PropertyTable.d.ts +1 -1
- package/lib/cjs/widget/components/PropertyTable.js +3 -4
- package/lib/cjs/widget/components/PropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/PropertyTable.scss +1 -2
- package/lib/cjs/widget/components/QueryBuilder.js +19 -29
- package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
- package/lib/cjs/widget/components/QueryBuilderCustomUI.js +1 -1
- package/lib/cjs/widget/components/QueryBuilderCustomUI.js.map +1 -1
- package/lib/cjs/widget/components/QueryBuilderStep.scss +1 -2
- package/lib/cjs/widget/components/SelectIModel.scss +0 -1
- package/lib/cjs/widget/components/SelectITwin.js +1 -1
- package/lib/cjs/widget/components/SelectITwin.js.map +1 -1
- package/lib/cjs/widget/components/SelectITwin.scss +1 -2
- package/lib/cjs/widget/components/SelectMapping.scss +0 -1
- package/lib/cjs/widget/components/SortableHorizontalTile.js +2 -1
- package/lib/cjs/widget/components/SortableHorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/StatusIcon.d.ts +5 -6
- package/lib/cjs/widget/components/StatusIcon.scss +4 -8
- package/lib/cjs/widget/components/ToggleGroupVisibility.scss +1 -2
- package/lib/cjs/widget/components/WidgetHeader.js +1 -1
- package/lib/cjs/widget/components/WidgetHeader.js.map +1 -1
- package/lib/cjs/widget/components/WidgetHeader.scss +4 -12
- package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.js +1 -1
- package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.js.map +1 -1
- package/lib/cjs/widget/components/customUI/GroupQueryBuilderCustomUI.js +2 -2
- package/lib/cjs/widget/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -1
- package/lib/cjs/widget/components/customUI/GroupQueryBuilderCustomUI.scss +1 -2
- package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.js +1 -1
- package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.js.map +1 -1
- package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.scss +2 -3
- package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.scss +2 -3
- package/lib/cjs/widget/components/groupsHelpers.js +1 -2
- package/lib/cjs/widget/components/groupsHelpers.js.map +1 -1
- package/lib/cjs/widget/components/utils.scss +1 -4
- package/lib/cjs/widget/components/viewerUtils.js +1 -2
- package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
- package/lib/cjs/widget/hooks/useFetchData.js +1 -1
- package/lib/cjs/widget/hooks/useFetchData.js.map +1 -1
- package/lib/cjs/widget/hooks/useFormulaValidation.js +1 -2
- package/lib/cjs/widget/hooks/useFormulaValidation.js.map +1 -1
- package/lib/esm/decorators/BboxDimensionsDecorator.js +14 -17
- package/lib/esm/decorators/BboxDimensionsDecorator.js.map +1 -1
- package/lib/esm/formula/FormulaDataTypeResolver.js +1 -2
- package/lib/esm/formula/FormulaDataTypeResolver.js.map +1 -1
- package/lib/esm/formula/FormulaFunctionProvider.js +2 -3
- package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/esm/test/GroupingMappingCustomUI.test.js +1 -2
- package/lib/esm/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/esm/test/PropertyFieldsHelpers.js +4 -7
- package/lib/esm/test/PropertyFieldsHelpers.js.map +1 -1
- package/lib/esm/test/QueryBuilder.test.js +3 -4
- package/lib/esm/test/QueryBuilder.test.js.map +1 -1
- package/lib/esm/widget/GroupingMappingWidget.d.ts +2 -2
- package/lib/esm/widget/GroupingMappingWidget.js +1 -3
- package/lib/esm/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/esm/widget/components/ActionPanel.scss +2 -3
- package/lib/esm/widget/components/BlockingOverlay.scss +4 -5
- package/lib/esm/widget/components/CalculatedPropertyAction.js +4 -5
- package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyAction.scss +1 -2
- package/lib/esm/widget/components/CalculatedPropertyActionWithVisuals.js +7 -9
- package/lib/esm/widget/components/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyActionWithVisuals.scss +1 -2
- package/lib/esm/widget/components/ConfirmMappingsImport.js +4 -5
- package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/esm/widget/components/ConfirmMappingsImport.scss +7 -8
- package/lib/esm/widget/components/CustomCalculationAction.js +11 -15
- package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationAction.scss +1 -2
- package/lib/esm/widget/components/DeleteModal.js +2 -2
- package/lib/esm/widget/components/DeleteModal.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.scss +1 -2
- package/lib/esm/widget/components/GroupAction.js +5 -7
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.scss +0 -1
- package/lib/esm/widget/components/GroupColorLegend.scss +0 -1
- package/lib/esm/widget/components/GroupColorToggle.d.ts +2 -2
- package/lib/esm/widget/components/GroupColorToggle.js.map +1 -1
- package/lib/esm/widget/components/GroupDetails.js +2 -2
- package/lib/esm/widget/components/GroupDetails.js.map +1 -1
- package/lib/esm/widget/components/GroupDetailsStep.scss +1 -2
- package/lib/esm/widget/components/GroupMenuActions.scss +1 -2
- package/lib/esm/widget/components/GroupPropertyAction.js +6 -7
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.scss +13 -16
- package/lib/esm/widget/components/GroupPropertyUtils.js +2 -3
- package/lib/esm/widget/components/GroupPropertyUtils.js.map +1 -1
- package/lib/esm/widget/components/Grouping.js +4 -5
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/Grouping.scss +9 -11
- package/lib/esm/widget/components/GroupingMapping.js +16 -20
- package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
- package/lib/esm/widget/components/GroupingMapping.scss +2 -3
- package/lib/esm/widget/components/GroupingMappingContext.js +9 -13
- package/lib/esm/widget/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/widget/components/GroupingMappingRouter.js +5 -5
- package/lib/esm/widget/components/GroupingMappingRouter.js.map +1 -1
- package/lib/esm/widget/components/GroupsAddButton.scss +1 -2
- package/lib/esm/widget/components/GroupsVisualization.js +1 -1
- package/lib/esm/widget/components/GroupsVisualization.js.map +1 -1
- package/lib/esm/widget/components/GroupsVisualization.scss +3 -3
- package/lib/esm/widget/components/GroupsVisualizationActions.scss +0 -1
- package/lib/esm/widget/components/HorizontalTile.js +5 -2
- package/lib/esm/widget/components/HorizontalTile.js.map +1 -1
- package/lib/esm/widget/components/HorizontalTile.scss +16 -15
- package/lib/esm/widget/components/Mapping.js +28 -32
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/Mapping.scss +6 -12
- package/lib/esm/widget/components/MappingAction.js +8 -10
- package/lib/esm/widget/components/MappingAction.js.map +1 -1
- package/lib/esm/widget/components/MappingAction.scss +1 -2
- package/lib/esm/widget/components/MappingImportWizardModal.js +3 -2
- package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -1
- package/lib/esm/widget/components/MappingImportWizardModal.scss +4 -5
- package/lib/esm/widget/components/PropertyAction.js +4 -5
- package/lib/esm/widget/components/PropertyAction.js.map +1 -1
- package/lib/esm/widget/components/PropertyMenu.js +3 -3
- package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
- package/lib/esm/widget/components/PropertyMenu.scss +2 -2
- package/lib/esm/widget/components/PropertyMenuWithVisualization.scss +1 -2
- package/lib/esm/widget/components/PropertyTable.d.ts +1 -1
- package/lib/esm/widget/components/PropertyTable.js +3 -4
- package/lib/esm/widget/components/PropertyTable.js.map +1 -1
- package/lib/esm/widget/components/PropertyTable.scss +1 -2
- package/lib/esm/widget/components/QueryBuilder.js +19 -29
- package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
- package/lib/esm/widget/components/QueryBuilderCustomUI.js +1 -1
- package/lib/esm/widget/components/QueryBuilderCustomUI.js.map +1 -1
- package/lib/esm/widget/components/QueryBuilderStep.scss +1 -2
- package/lib/esm/widget/components/SelectIModel.scss +0 -1
- package/lib/esm/widget/components/SelectITwin.js +2 -2
- package/lib/esm/widget/components/SelectITwin.js.map +1 -1
- package/lib/esm/widget/components/SelectITwin.scss +1 -2
- package/lib/esm/widget/components/SelectMapping.scss +0 -1
- package/lib/esm/widget/components/SortableHorizontalTile.js +2 -1
- package/lib/esm/widget/components/SortableHorizontalTile.js.map +1 -1
- package/lib/esm/widget/components/StatusIcon.d.ts +5 -6
- package/lib/esm/widget/components/StatusIcon.scss +4 -8
- package/lib/esm/widget/components/ToggleGroupVisibility.scss +1 -2
- package/lib/esm/widget/components/WidgetHeader.js +2 -2
- package/lib/esm/widget/components/WidgetHeader.js.map +1 -1
- package/lib/esm/widget/components/WidgetHeader.scss +4 -12
- package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.js +1 -1
- package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.js.map +1 -1
- package/lib/esm/widget/components/customUI/GroupQueryBuilderCustomUI.js +2 -2
- package/lib/esm/widget/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -1
- package/lib/esm/widget/components/customUI/GroupQueryBuilderCustomUI.scss +1 -2
- package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.js +1 -1
- package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.js.map +1 -1
- package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.scss +2 -3
- package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.scss +2 -3
- package/lib/esm/widget/components/groupsHelpers.js +1 -2
- package/lib/esm/widget/components/groupsHelpers.js.map +1 -1
- package/lib/esm/widget/components/utils.scss +1 -4
- package/lib/esm/widget/components/viewerUtils.js +1 -2
- package/lib/esm/widget/components/viewerUtils.js.map +1 -1
- package/lib/esm/widget/hooks/useFetchData.js +1 -1
- package/lib/esm/widget/hooks/useFetchData.js.map +1 -1
- package/lib/esm/widget/hooks/useFormulaValidation.js +1 -2
- package/lib/esm/widget/hooks/useFormulaValidation.js.map +1 -1
- package/package.json +32 -30
|
@@ -27,7 +27,7 @@ describe("QueryBuilder", () => {
|
|
|
27
27
|
const createFieldDescriptor = (pathToClass, fieldProperties, type, fieldName) => {
|
|
28
28
|
switch (type) {
|
|
29
29
|
case FieldDescriptorType.Properties:
|
|
30
|
-
const pathFromSelectToPropertyClass = (pathToClass
|
|
30
|
+
const pathFromSelectToPropertyClass = (pathToClass ?? []).map((x) => ({
|
|
31
31
|
sourceClassName: x.sourceClassInfo.name,
|
|
32
32
|
targetClassName: x.targetClassInfo.name,
|
|
33
33
|
relationshipName: x.relationshipInfo.name,
|
|
@@ -45,7 +45,7 @@ describe("QueryBuilder", () => {
|
|
|
45
45
|
case FieldDescriptorType.Name:
|
|
46
46
|
return {
|
|
47
47
|
type,
|
|
48
|
-
fieldName: fieldName
|
|
48
|
+
fieldName: fieldName ?? "",
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
};
|
|
@@ -60,9 +60,8 @@ describe("QueryBuilder", () => {
|
|
|
60
60
|
return prop;
|
|
61
61
|
};
|
|
62
62
|
const executeTest = async (queryBuilder, expectedResult, operations) => {
|
|
63
|
-
var _a;
|
|
64
63
|
for (const op of operations) {
|
|
65
|
-
const fieldDescriptor = createFieldDescriptor(
|
|
64
|
+
const fieldDescriptor = createFieldDescriptor(op.propertiesField.parent?.pathToPrimaryClass, op.propertiesField.properties, op.fieldDescriptorType, op.fieldDescriptorName);
|
|
66
65
|
const prop = createPropertyRecord(op.propertyRecord, op.propertiesField, fieldDescriptor);
|
|
67
66
|
if (op.operationType === "addProperty") {
|
|
68
67
|
const result = await queryBuilder.addProperty(prop);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.test.js","sourceRoot":"","sources":["../../../src/test/QueryBuilder.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElF,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,GAAiB,CAAC;IACtB,IAAI,YAA2D,CAAC;IAEhE,UAAU,CAAC,GAAG,EAAE;QACd,YAAY,GAAG,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AAI,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,KAAK,EAAE,YAA0B,EAAE,cAAsB,EAAE,UAA+B,EAAE,EAAE;QAChH,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE;YAC3B,MAAM,eAAe,GAAG,qBAAqB,CAC3C,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAC7C,EAAE,CAAC,eAAe,CAAC,UAAU,EAC7B,EAAE,CAAC,mBAAmB,EACtB,EAAE,CAAC,mBAAmB,CACvB,CAAC;YAEF,MAAM,IAAI,GAAG,oBAAoB,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,eAAkC,EAAE,eAAe,CAAC,CAAC;YAE7G,IAAI,EAAE,CAAC,aAAa,KAAK,aAAa,EAAE;gBACtC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACpD,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC;aAC/C;YACD,IAAI,EAAE,CAAC,aAAa,KAAK,gBAAgB,EAAE;gBACzC,MAAM,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;aACzC;SACF;QAED,MAAM,MAAM,GAAG,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAC/C,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { FieldDescriptorType, PropertiesField } from \"@itwin/presentation-common\";\nimport type { FieldDescriptor, RelationshipPath, StrippedRelatedClassInfo } from \"@itwin/presentation-common\";\nimport { PresentationPropertyDataProvider } from \"@itwin/presentation-components\";\nimport { assert } from \"chai\";\nimport { QueryBuilder } from \"../widget/components/QueryBuilder\";\nimport { MockFactory } from \"./MockFactory\";\nimport type { StubbedType } from \"./MockFactory\";\nimport type { OperationTestData, PropertiesTestData, PropertyRecordTestData, QueryBuilderTestData } from \"./QueryBuilderTestData\";\nimport { testCases } from \"./QueryBuilder.testdata\";\n\ndescribe(\"QueryBuilder\", () => {\n let sut: QueryBuilder;\n let dataProvider: StubbedType<PresentationPropertyDataProvider>;\n\n beforeEach(() => {\n dataProvider = MockFactory.create(PresentationPropertyDataProvider);\n MockFactory.stubProperty(dataProvider, \"getContentDescriptor\", () => () => true);\n\n sut = new QueryBuilder(dataProvider);\n });\n\n afterEach(() => {\n dataProvider.getFieldByPropertyRecord.restore();\n });\n\n const testData: QueryBuilderTestData = testCases;\n testData.testCases.forEach((testCase) => {\n it(testCase.name, async () => executeTest(\n sut,\n testCase.expectedResult,\n testCase.operations,\n ));\n });\n\n const createFieldDescriptor = (\n pathToClass: RelationshipPath | undefined,\n fieldProperties: PropertiesTestData[],\n type: FieldDescriptorType,\n fieldName: string | undefined\n ): FieldDescriptor => {\n switch (type) {\n case FieldDescriptorType.Properties:\n const pathFromSelectToPropertyClass: StrippedRelatedClassInfo[] = (pathToClass ?? []).map((x) => ({\n sourceClassName: x.sourceClassInfo.name,\n targetClassName: x.targetClassInfo.name,\n relationshipName: x.relationshipInfo.name,\n isForwardRelationship: x.isForwardRelationship,\n }));\n\n const properties = fieldProperties.map((x) => ({\n class: x.property.classInfo.name,\n name: x.property.name,\n }));\n\n return {\n pathFromSelectToPropertyClass,\n properties,\n type,\n };\n case FieldDescriptorType.Name:\n return {\n type,\n fieldName: fieldName ?? \"\",\n };\n }\n };\n\n const createPropertyRecord = (propertyRecord: PropertyRecordTestData, propertiesField: PropertiesField, fieldDescriptor: FieldDescriptor) => {\n const propertiesFieldMock: StubbedType<PropertiesField> = MockFactory.create(PropertiesField);\n\n MockFactory.stubProperty(propertiesFieldMock, \"parent\", () => propertiesField.parent);\n MockFactory.stubProperty(propertiesFieldMock, \"properties\", () => propertiesField.properties);\n MockFactory.stubProperty(propertiesFieldMock, \"type\", () => propertiesField.type);\n MockFactory.stubProperty(propertiesFieldMock, \"getFieldDescriptor\", () => () => fieldDescriptor);\n\n const prop: PropertyRecord = new PropertyRecord(propertyRecord.value, propertyRecord.property);\n dataProvider.getFieldByPropertyRecord.withArgs(prop).resolves(propertiesFieldMock);\n return prop;\n };\n\n const executeTest = async (queryBuilder: QueryBuilder, expectedResult: string, operations: OperationTestData[]) => {\n for (const op of operations) {\n const fieldDescriptor = createFieldDescriptor(\n op.propertiesField.parent?.pathToPrimaryClass,\n op.propertiesField.properties,\n op.fieldDescriptorType,\n op.fieldDescriptorName\n );\n\n const prop = createPropertyRecord(op.propertyRecord, op.propertiesField as PropertiesField, fieldDescriptor);\n\n if (op.operationType === \"addProperty\") {\n const result = await queryBuilder.addProperty(prop);\n assert.strictEqual(result, op.expectedResult);\n }\n if (op.operationType === \"removeProperty\") {\n await queryBuilder.removeProperty(prop);\n }\n }\n\n const result = queryBuilder.buildQueryString();\n assert.strictEqual(result, expectedResult);\n };\n});\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UiItemsProvider, Widget } from "@itwin/appui-react";
|
|
2
2
|
import { StagePanelLocation, StagePanelSection } from "@itwin/appui-react";
|
|
3
3
|
import type { GroupingMappingProps } from "./components/GroupingMapping";
|
|
4
4
|
export declare class GroupingMappingProvider implements UiItemsProvider {
|
|
5
5
|
private readonly _props;
|
|
6
6
|
readonly id = "GroupingMappingProvider";
|
|
7
7
|
constructor(_props?: GroupingMappingProps);
|
|
8
|
-
provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection): ReadonlyArray<
|
|
8
|
+
provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection): ReadonlyArray<Widget>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=GroupingMappingWidget.d.ts.map
|
|
@@ -14,9 +14,7 @@ export class GroupingMappingProvider {
|
|
|
14
14
|
const GroupingMappingWidget = {
|
|
15
15
|
id: "GroupingMappingWidget",
|
|
16
16
|
label: "Grouping & Mapping",
|
|
17
|
-
|
|
18
|
-
return React.createElement(GroupingMapping, { ...this._props });
|
|
19
|
-
},
|
|
17
|
+
content: React.createElement(GroupingMapping, { ...this._props }),
|
|
20
18
|
};
|
|
21
19
|
widgets.push(GroupingMappingWidget);
|
|
22
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,OAAO,uBAAuB;IAGlC,YAA6B,SAA+B,EAAE;QAAjC,WAAM,GAAN,MAAM,CAA2B;QAF9C,OAAE,GAAG,yBAAyB,CAAC;IAEmB,CAAC;IAE5D,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B;QAE3B,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,OAAO,uBAAuB;IAGlC,YAA6B,SAA+B,EAAE;QAAjC,WAAM,GAAN,MAAM,CAA2B;QAF9C,OAAE,GAAG,yBAAyB,CAAC;IAEmB,CAAC;IAE5D,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B;QAE3B,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,QAAQ,KAAK,kBAAkB,CAAC,IAAI;YACpC,OAAO,KAAK,iBAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,UAAU,CAAC,OAAO,EACnC;YACA,MAAM,qBAAqB,GAAW;gBACpC,EAAE,EAAE,uBAAuB;gBAC3B,KAAK,EAAE,oBAAoB;gBAC3B,OAAO,EAAE,oBAAC,eAAe,OAAK,IAAI,CAAC,MAAM,GAAI;aAC9C,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACrC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type {\n UiItemsProvider,\n Widget,\n} from \"@itwin/appui-react\";\nimport {\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-react\";\nimport React from \"react\";\nimport type { GroupingMappingProps } from \"./components/GroupingMapping\";\nimport GroupingMapping from \"./components/GroupingMapping\";\n\nexport class GroupingMappingProvider implements UiItemsProvider {\n public readonly id = \"GroupingMappingProvider\";\n\n constructor(private readonly _props: GroupingMappingProps = {}) { }\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n ): ReadonlyArray<Widget> {\n const widgets: Widget[] = [];\n if (location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General\n ) {\n const GroupingMappingWidget: Widget = {\n id: \"GroupingMappingWidget\",\n label: \"Grouping & Mapping\",\n content: <GroupingMapping {...this._props} />,\n };\n\n widgets.push(GroupingMappingWidget);\n }\n\n return widgets;\n }\n}\n"]}
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
@import '~@itwin/itwinui-css/scss/variables';
|
|
6
5
|
|
|
7
6
|
.gmw-action-panel {
|
|
8
7
|
display: flex;
|
|
9
8
|
justify-content: right;
|
|
10
|
-
padding:
|
|
11
|
-
gap:
|
|
9
|
+
padding: calc(var(--iui-size-s) * 2) var(--iui-size-m) var(--iui-size-s);
|
|
10
|
+
gap: var(--iui-size-xs);
|
|
12
11
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
@import "~@itwin/itwinui-css/scss/variables";
|
|
6
5
|
|
|
7
6
|
.gmw-group-mapping-blocking-overlay {
|
|
8
7
|
background-color: black;
|
|
@@ -10,10 +9,10 @@
|
|
|
10
9
|
display: flex;
|
|
11
10
|
justify-content: center;
|
|
12
11
|
align-items: center;
|
|
13
|
-
top:
|
|
14
|
-
bottom:
|
|
15
|
-
right:
|
|
16
|
-
left:
|
|
12
|
+
top: var(--iui-size-s);
|
|
13
|
+
bottom: var(--iui-size-s);
|
|
14
|
+
right: var(--iui-size-xs);
|
|
15
|
+
left: var(--iui-size-xs);
|
|
17
16
|
opacity: 60%;
|
|
18
17
|
z-index: 9999;
|
|
19
18
|
visibility: hidden;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { Fieldset,
|
|
5
|
+
import { Fieldset, Text, } from "@itwin/itwinui-react";
|
|
6
6
|
import React, { useState } from "react";
|
|
7
7
|
import ActionPanel from "./ActionPanel";
|
|
8
8
|
import useValidator from "../hooks/useValidator";
|
|
@@ -13,11 +13,10 @@ import { useGroupingMappingApiConfig } from "./context/GroupingApiConfigContext"
|
|
|
13
13
|
import { CalculatedPropertyType } from "@itwin/insights-client";
|
|
14
14
|
import { SharedCalculatedPropertyForms } from "./SharedCalculatedPropertyForms";
|
|
15
15
|
export const CalculatedPropertyAction = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
16
|
-
var _a;
|
|
17
16
|
const { getAccessToken, iModelId } = useGroupingMappingApiConfig();
|
|
18
17
|
const mappingClient = useMappingClient();
|
|
19
|
-
const [propertyName, setPropertyName] = useState(
|
|
20
|
-
const [type, setType] = useState(calculatedProperty
|
|
18
|
+
const [propertyName, setPropertyName] = useState(calculatedProperty?.propertyName ?? "");
|
|
19
|
+
const [type, setType] = useState(calculatedProperty?.type);
|
|
21
20
|
const [isLoading, setIsLoading] = useState(false);
|
|
22
21
|
const [validator, showValidationMessage] = useValidator();
|
|
23
22
|
const onSave = async () => {
|
|
@@ -52,7 +51,7 @@ export const CalculatedPropertyAction = ({ mappingId, group, calculatedProperty,
|
|
|
52
51
|
React.createElement("div", { className: 'gmw-calculated-properties-action-container' },
|
|
53
52
|
React.createElement(Fieldset, { legend: 'Calculated Property Details', className: 'gmw-details-form' },
|
|
54
53
|
React.createElement("div", { className: 'gmw-field-legend-container' },
|
|
55
|
-
React.createElement(
|
|
54
|
+
React.createElement(Text, { variant: 'small', as: 'small', className: 'gmw-field-legend' }, "Asterisk * indicates mandatory fields.")),
|
|
56
55
|
React.createElement(SharedCalculatedPropertyForms, { validator: validator, propertyName: propertyName, setPropertyName: setPropertyName, type: type, setType: setType }))),
|
|
57
56
|
React.createElement(ActionPanel, { onSave: onSave, onCancel: onClickCancel, isSavingDisabled: !(type && propertyName), isLoading: isLoading })));
|
|
58
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,QAAQ,EACR,IAAI,GACL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAUhF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,SAAS,EACT,KAAK,EACL,kBAAkB,EAClB,aAAa,EACb,aAAa,GACiB,EAAE,EAAE;IAClC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,2BAA2B,EAAE,CAAC;IACnE,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,kBAAkB,EAAE,YAAY,IAAI,EAAE,CACvC,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAqC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IAC/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O,EAAC,SAAS,EAAC,kBAAkB,6CAEtD,CACH;gBACN,oBAAC,6BAA6B,IAC5B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,GAChB,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Fieldset,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport type { CalculatedProperty, Group } from \"@itwin/insights-client\";\nimport { CalculatedPropertyType } from \"@itwin/insights-client\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\n\nexport interface CalculatedPropertyActionProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: CalculatedProperty;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const CalculatedPropertyAction = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.type);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [validator, showValidationMessage] = useValidator();\n\n const onSave = async () => {\n if (!validator.allValid() || !type) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const accessToken = await getAccessToken();\n\n calculatedProperty\n ? await mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n calculatedProperty.id,\n {\n propertyName,\n type,\n },\n )\n : await mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n {\n propertyName,\n type,\n },\n );\n onSaveSuccess();\n setPropertyName(\"\");\n setType(CalculatedPropertyType.Undefined);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n };\n\n return (\n <>\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <div className='gmw-field-legend-container'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n </div>\n <SharedCalculatedPropertyForms\n validator={validator}\n propertyName={propertyName}\n setPropertyName={setPropertyName}\n type={type}\n setType={setType}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
@import "~@itwin/itwinui-css/scss/variables";
|
|
6
5
|
|
|
7
6
|
.gmw-calculated-properties-action-container {
|
|
8
7
|
overflow-x: auto;
|
|
@@ -11,6 +10,6 @@
|
|
|
11
10
|
.gmw-details-form {
|
|
12
11
|
display: flex;
|
|
13
12
|
flex-direction: column;
|
|
14
|
-
gap:
|
|
13
|
+
gap: var(--iui-size-s);
|
|
15
14
|
}
|
|
16
15
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { IModelApp } from "@itwin/core-frontend";
|
|
6
|
-
import { Fieldset, MenuItem,
|
|
6
|
+
import { Fieldset, MenuItem, Text, ToggleSwitch, } from "@itwin/itwinui-react";
|
|
7
7
|
import React, { useEffect, useState } from "react";
|
|
8
8
|
import ActionPanel from "./ActionPanel";
|
|
9
9
|
import { BboxDimension, BboxDimensionsDecorator, } from "../../decorators/BboxDimensionsDecorator";
|
|
@@ -17,11 +17,10 @@ import { useGroupHilitedElementsContext } from "./context/GroupHilitedElementsCo
|
|
|
17
17
|
import { getHiliteIdsAndKeysetFromGroup } from "./groupsHelpers";
|
|
18
18
|
import { SharedCalculatedPropertyForms } from "./SharedCalculatedPropertyForms";
|
|
19
19
|
export const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
20
|
-
var _a;
|
|
21
20
|
const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();
|
|
22
21
|
const mappingClient = useMappingClient();
|
|
23
|
-
const [propertyName, setPropertyName] = useState(
|
|
24
|
-
const [type, setType] = useState(calculatedProperty
|
|
22
|
+
const [propertyName, setPropertyName] = useState(calculatedProperty?.propertyName ?? "");
|
|
23
|
+
const [type, setType] = useState(calculatedProperty?.type);
|
|
25
24
|
const [bboxDecorator, setBboxDecorator] = useState();
|
|
26
25
|
const [isLoading, setIsLoading] = useState(false);
|
|
27
26
|
const { hilitedElementsQueryCache } = useGroupHilitedElementsContext();
|
|
@@ -105,15 +104,14 @@ export const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculat
|
|
|
105
104
|
setIsLoading(false);
|
|
106
105
|
}
|
|
107
106
|
};
|
|
108
|
-
const getSpatialData = (value) => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
107
|
+
const getSpatialData = (value) => inferredSpatialData?.has(BboxDimension[value]) && (React.createElement("div", null, `${inferredSpatialData
|
|
108
|
+
?.get(BboxDimension[value])
|
|
109
|
+
?.toPrecision(4)}m`));
|
|
112
110
|
return (React.createElement(React.Fragment, null,
|
|
113
111
|
React.createElement("div", { className: 'gmw-calculated-properties-action-container' },
|
|
114
112
|
React.createElement(Fieldset, { legend: 'Calculated Property Details', className: 'gmw-details-form' },
|
|
115
113
|
React.createElement("div", { className: 'gmw-field-legend-container' },
|
|
116
|
-
React.createElement(
|
|
114
|
+
React.createElement(Text, { variant: 'small', as: 'small', className: 'gmw-field-legend' }, "Asterisk * indicates mandatory fields."),
|
|
117
115
|
React.createElement(ToggleSwitch, { label: 'Visualize Dimensions', labelPosition: 'left', disabled: isLoading, checked: colorProperty, onChange: () => setColorProperty((b) => !b) })),
|
|
118
116
|
React.createElement(SharedCalculatedPropertyForms, { validator: validator, propertyName: propertyName, setPropertyName: setPropertyName, type: type, setType: setType, itemRenderer: (option) => (React.createElement(MenuItem, null,
|
|
119
117
|
React.createElement("div", { className: 'gmw-gr-cp-menu-item' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyActionWithVisuals.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyActionWithVisuals.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,aAAa,EACb,uBAAuB,GACxB,MAAM,0CAA0C,CAAC;AAClD,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,O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M,EACpB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAC7B,CACZ;gBACN,oBAAC,6BAA6B,IAC5B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CAC9C,oBAAC,QAAQ;wBACP,6BAAK,SAAS,EAAC,qBAAqB;4BAClC,iCAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,6BAAK,SAAS,EAAC,iBAAiB;wBAC9B,iCAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,GACD,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n MenuItem,\n Small,\n ToggleSwitch,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport { clearEmphasizedOverriddenElements, visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyActionWithVisuals.scss\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport type { CalculatedProperty, CalculatedPropertyType, Group } from \"@itwin/insights-client\";\nimport { useGroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport { getHiliteIdsAndKeysetFromGroup } from \"./groupsHelpers\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\n\nexport interface CalculatedPropertyActionWithVisualsProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: CalculatedProperty;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const CalculatedPropertyActionWithVisuals = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionWithVisualsProps) => {\n const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.type);\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const { hilitedElementsQueryCache } = useGroupHilitedElementsContext();\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n const [resolvedHiliteIds, setResolvedHiliteIds] = useState<string[]>([]);\n const [colorProperty, setColorProperty] = useState<boolean>(false);\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n const initialize = async () => {\n if (!iModelConnection) return;\n clearEmphasizedOverriddenElements();\n if (!colorProperty) return;\n setIsLoading(true);\n const result = await getHiliteIdsAndKeysetFromGroup(iModelConnection, group, hilitedElementsQueryCache);\n setResolvedHiliteIds(result.ids);\n setIsLoading(false);\n };\n void initialize();\n }, [iModelConnection, hilitedElementsQueryCache, group, colorProperty]);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n visualizeElements([resolvedHiliteIds[0]], \"red\");\n void zoomToElements([resolvedHiliteIds[0]]);\n }, [colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(resolvedHiliteIds[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension]) && colorProperty\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, colorProperty, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid() || !type) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const accessToken = await getAccessToken();\n\n calculatedProperty\n ? await mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n calculatedProperty.id,\n {\n propertyName,\n type,\n },\n )\n : await mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n {\n propertyName,\n type,\n },\n );\n onSaveSuccess();\n setPropertyName(\"\");\n setType(undefined);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <div className='gmw-field-legend-container'>\n <Small className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <ToggleSwitch\n label='Visualize Dimensions'\n labelPosition='left'\n disabled={isLoading}\n checked={colorProperty}\n onChange={() => setColorProperty((b) => !b)}\n ></ToggleSwitch>\n </div>\n <SharedCalculatedPropertyForms\n validator={validator}\n propertyName={propertyName}\n setPropertyName={setPropertyName}\n type={type}\n setType={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gmw-gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='gmw-select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyActionWithVisuals.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyActionWithVisuals.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,a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,SAAS,EACnB,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAC7B,CACZ;gBACN,oBAAC,6BAA6B,IAC5B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CAC9C,oBAAC,QAAQ;wBACP,6BAAK,SAAS,EAAC,qBAAqB;4BAClC,iCAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,6BAAK,SAAS,EAAC,iBAAiB;wBAC9B,iCAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,GACD,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n MenuItem,\n Text,\n ToggleSwitch,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport { clearEmphasizedOverriddenElements, visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyActionWithVisuals.scss\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport type { CalculatedProperty, CalculatedPropertyType, Group } from \"@itwin/insights-client\";\nimport { useGroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport { getHiliteIdsAndKeysetFromGroup } from \"./groupsHelpers\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\n\nexport interface CalculatedPropertyActionWithVisualsProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: CalculatedProperty;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const CalculatedPropertyActionWithVisuals = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionWithVisualsProps) => {\n const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.type);\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const { hilitedElementsQueryCache } = useGroupHilitedElementsContext();\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n const [resolvedHiliteIds, setResolvedHiliteIds] = useState<string[]>([]);\n const [colorProperty, setColorProperty] = useState<boolean>(false);\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n const initialize = async () => {\n if (!iModelConnection) return;\n clearEmphasizedOverriddenElements();\n if (!colorProperty) return;\n setIsLoading(true);\n const result = await getHiliteIdsAndKeysetFromGroup(iModelConnection, group, hilitedElementsQueryCache);\n setResolvedHiliteIds(result.ids);\n setIsLoading(false);\n };\n void initialize();\n }, [iModelConnection, hilitedElementsQueryCache, group, colorProperty]);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n visualizeElements([resolvedHiliteIds[0]], \"red\");\n void zoomToElements([resolvedHiliteIds[0]]);\n }, [colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(resolvedHiliteIds[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension]) && colorProperty\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, colorProperty, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid() || !type) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const accessToken = await getAccessToken();\n\n calculatedProperty\n ? await mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n calculatedProperty.id,\n {\n propertyName,\n type,\n },\n )\n : await mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n {\n propertyName,\n type,\n },\n );\n onSaveSuccess();\n setPropertyName(\"\");\n setType(undefined);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <div className='gmw-field-legend-container'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n <ToggleSwitch\n label='Visualize Dimensions'\n labelPosition='left'\n disabled={isLoading}\n checked={colorProperty}\n onChange={() => setColorProperty((b) => !b)}\n ></ToggleSwitch>\n </div>\n <SharedCalculatedPropertyForms\n validator={validator}\n propertyName={propertyName}\n setPropertyName={setPropertyName}\n type={type}\n setType={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gmw-gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='gmw-select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
@import "~@itwin/itwinui-css/scss/variables";
|
|
6
5
|
|
|
7
6
|
.gmw-calculated-properties-action-container {
|
|
8
7
|
overflow-x: auto;
|
|
@@ -11,7 +10,7 @@
|
|
|
11
10
|
.gmw-details-form {
|
|
12
11
|
display: flex;
|
|
13
12
|
flex-direction: column;
|
|
14
|
-
gap:
|
|
13
|
+
gap: var(--iui-size-s);
|
|
15
14
|
|
|
16
15
|
.gmw-select-item {
|
|
17
16
|
display: flex;
|
|
@@ -36,7 +36,6 @@ const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, set
|
|
|
36
36
|
setSelectedMappings(newState);
|
|
37
37
|
};
|
|
38
38
|
const onImport = async () => {
|
|
39
|
-
var _a, _b, _c;
|
|
40
39
|
if (!validator.allValid()) {
|
|
41
40
|
showValidationMessage(true);
|
|
42
41
|
return;
|
|
@@ -44,11 +43,11 @@ const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, set
|
|
|
44
43
|
setImporting(true);
|
|
45
44
|
try {
|
|
46
45
|
for (const selectedMapping of selectedMappings) {
|
|
47
|
-
setCurrentlyImporting(
|
|
46
|
+
setCurrentlyImporting(selectedMapping.mappingName ?? "");
|
|
48
47
|
const accessToken = await getAccessToken();
|
|
49
|
-
await mappingClient.copyMapping(accessToken, sourceiModelId,
|
|
50
|
-
targetIModelId: iModelId
|
|
51
|
-
mappingName:
|
|
48
|
+
await mappingClient.copyMapping(accessToken, sourceiModelId, selectedMapping.id ?? "", {
|
|
49
|
+
targetIModelId: iModelId ?? "",
|
|
50
|
+
mappingName: selectedMapping.mappingName ?? "",
|
|
52
51
|
});
|
|
53
52
|
setImportCount((importCount) => importCount + 1);
|
|
54
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmMappingsImport.js","sourceRoot":"","sources":["../../../../src/widget/components/ConfirmMappingsImport.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,IAAI,GACL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,YAAY,EAAE,EAAE,iBA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K,EAAE,KAAK,CAAC,CAAC;4BAC3B,SAAS,CAAC,cAAc,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,EACD,OAAO,EAAE,SAAS,CAAC,OAAO,CACxB,WAAW,OAAO,CAAC,EAAE,EAAE,EACvB,OAAO,CAAC,WAAW,EACnB,iBAAiB,CAClB,EACD,MAAM,EACJ,SAAS,CAAC,OAAO,CACf,WAAW,OAAO,CAAC,EAAE,EAAE,EACvB,OAAO,CAAC,WAAW,EACnB,iBAAiB,CAClB;4BACC,CAAC,CAAC,UAAU;4BACZ,CAAC,CAAC,SAAS,EAEf,MAAM,EAAE,GAAG,EAAE;4BACX,SAAS,CAAC,cAAc,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,EACD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;4BACvB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;4BAC3B,SAAS,CAAC,cAAc,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,GACD;oBACF,iCAAM,OAAO,CAAC,WAAW,CAAO,CAC5B;gBACN,6BAAK,SAAS,EAAC,gBAAgB,GAAG,CAC9B,CACP,CAAC,CACE,CACF;QACN,6BAAK,SAAS,EAAC,yBAAyB;YACtC,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,oBAAC,MAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,aAE1D;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Button,\n LabeledInput,\n MiddleTextTruncation,\n ProgressLinear,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport type { IMappingTyped } from \"./Mapping\";\nimport \"./ConfirmMappingsImport.scss\";\nimport { SvgStatusSuccessHollow } from \"@itwin/itwinui-icons-react\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\nconst defaultDisplayStrings = {\n mappings: \"Mappings\",\n};\n\ninterface ConfirmMappingImportProps {\n sourceiModelId: string;\n selectedMappings: IMappingTyped[];\n importing: boolean;\n setImporting: React.Dispatch<React.SetStateAction<boolean>>;\n setSelectedMappings: React.Dispatch<React.SetStateAction<IMappingTyped[]>>;\n backFn: () => void;\n onCancel: () => void;\n onFinish: () => void;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n}\n\nconst ConfirmMappingImport = ({\n sourceiModelId,\n selectedMappings,\n importing,\n setImporting,\n setSelectedMappings,\n backFn,\n onCancel,\n onFinish,\n displayStrings: userDisplayStrings,\n}: ConfirmMappingImportProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n\n const [importCount, setImportCount] = useState<number>(0);\n const [currentlyImporting, setCurrentlyImporting] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [errored, setErrored] = useState<boolean>(false);\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n useEffect(() => {\n setSelectedMappings((selectedMappings) =>\n selectedMappings.map((mapping) => ({\n ...mapping,\n mappingName: `${mapping.mappingName}_Copy`,\n })),\n );\n }, [setSelectedMappings]);\n\n const handleChange = (\n e: React.ChangeEvent<HTMLInputElement>,\n index: number,\n ) => {\n const newState = [...selectedMappings];\n newState[index] = {\n ...newState[index],\n mappingName: e.target.value,\n };\n setSelectedMappings(newState);\n };\n\n const onImport = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setImporting(true);\n try {\n for (const selectedMapping of selectedMappings) {\n setCurrentlyImporting(selectedMapping.mappingName ?? \"\");\n const accessToken = await getAccessToken();\n await mappingClient.copyMapping(\n accessToken,\n sourceiModelId,\n selectedMapping.id ?? \"\",\n {\n targetIModelId: iModelId ?? \"\",\n mappingName: selectedMapping.mappingName ?? \"\",\n },\n );\n setImportCount((importCount) => importCount + 1);\n }\n } catch (error: any) {\n handleError(error);\n setErrored(true);\n }\n };\n\n return (\n <>\n {importing ? (\n <div className='gmw-import-progress-container'>\n <div className='gmw-import-progress-bar'>\n <div className='gmw-import-progress-bar-description'>\n {\n !errored ? importCount !== selectedMappings.length ? (\n <>\n <Text variant='title'>Importing</Text>\n <Text>{`We are currently importing the ${displayStrings.mappings.toLocaleLowerCase()}.`}</Text>\n </>\n ) : (\n <>\n <Text variant='title'>Done!</Text>\n <Text>{`Your imported ${displayStrings.mappings.toLocaleLowerCase()} are ready.`}</Text>\n </>\n ) :\n <>\n <Text variant='title'>Error!</Text>\n <Text>{`Sorry, there was an error importing some or all ${displayStrings.mappings}.`}</Text>\n </>}\n </div>\n <ProgressLinear\n value={(importCount / selectedMappings.length) * 100}\n labels={\n importCount === selectedMappings.length\n ? [\"Import done!\", <SvgStatusSuccessHollow key='0' />]\n : [\n <>\n <Text>Copying</Text>\n <MiddleTextTruncation text={currentlyImporting} />\n </>,\n `${importCount}/${selectedMappings.length}`,\n ]\n }\n status={\n !errored ?\n importCount === selectedMappings.length ? \"positive\" : undefined : \"negative\"\n }\n />\n </div>\n <div className='gmw-import-action-panel'>\n <Button\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => {\n setImporting(false);\n setImportCount(0);\n setCurrentlyImporting(\"\");\n setErrored(false);\n }}\n >\n Back\n </Button>\n <Button\n styleType='high-visibility'\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => onFinish()}\n >\n Close\n </Button>\n </div>\n </div>\n ) : (\n <div className='gmw-rename-confirm-container '>\n <div className='gmw-mapping-rename-container'>\n <div className='gmw-mapping-row-header-container'>\n <div className='gmw-mapping-row'>\n <Text variant='leading'>{displayStrings.mappings}</Text>\n <Text variant='leading'>Description</Text>\n </div>\n </div>\n <div className='gmw-mapping-row-body'>\n {selectedMappings.map((mapping, index) => (\n <div className='gmw-mapping-row-container' key={mapping.id}>\n <div className='gmw-mapping-row'>\n <LabeledInput\n value={mapping.mappingName}\n name={`mapping_${mapping.id}`}\n required\n onChange={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n message={validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )}\n status={\n validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n onBlurCapture={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n />\n <div>{mapping.description}</div>\n </div>\n <div className='gmw-border-div' />\n </div>\n ))}\n </div>\n </div>\n <div className='gmw-import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button styleType='high-visibility' onClick={async () => onImport()}>\n Import\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport default ConfirmMappingImport;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfirmMappingsImport.js","sourceRoot":"","sources":["../../../../src/widget/components/ConfirmMappingsImport.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,IAAI,GACL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,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["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Button,\n LabeledInput,\n MiddleTextTruncation,\n ProgressLinear,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport type { IMappingTyped } from \"./Mapping\";\nimport \"./ConfirmMappingsImport.scss\";\nimport { SvgStatusSuccessHollow } from \"@itwin/itwinui-icons-react\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\nconst defaultDisplayStrings = {\n mappings: \"Mappings\",\n};\n\ninterface ConfirmMappingImportProps {\n sourceiModelId: string;\n selectedMappings: IMappingTyped[];\n importing: boolean;\n setImporting: React.Dispatch<React.SetStateAction<boolean>>;\n setSelectedMappings: React.Dispatch<React.SetStateAction<IMappingTyped[]>>;\n backFn: () => void;\n onCancel: () => void;\n onFinish: () => void;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n}\n\nconst ConfirmMappingImport = ({\n sourceiModelId,\n selectedMappings,\n importing,\n setImporting,\n setSelectedMappings,\n backFn,\n onCancel,\n onFinish,\n displayStrings: userDisplayStrings,\n}: ConfirmMappingImportProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n\n const [importCount, setImportCount] = useState<number>(0);\n const [currentlyImporting, setCurrentlyImporting] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [errored, setErrored] = useState<boolean>(false);\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n useEffect(() => {\n setSelectedMappings((selectedMappings) =>\n selectedMappings.map((mapping) => ({\n ...mapping,\n mappingName: `${mapping.mappingName}_Copy`,\n })),\n );\n }, [setSelectedMappings]);\n\n const handleChange = (\n e: React.ChangeEvent<HTMLInputElement>,\n index: number,\n ) => {\n const newState = [...selectedMappings];\n newState[index] = {\n ...newState[index],\n mappingName: e.target.value,\n };\n setSelectedMappings(newState);\n };\n\n const onImport = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setImporting(true);\n try {\n for (const selectedMapping of selectedMappings) {\n setCurrentlyImporting(selectedMapping.mappingName ?? \"\");\n const accessToken = await getAccessToken();\n await mappingClient.copyMapping(\n accessToken,\n sourceiModelId,\n selectedMapping.id ?? \"\",\n {\n targetIModelId: iModelId ?? \"\",\n mappingName: selectedMapping.mappingName ?? \"\",\n },\n );\n setImportCount((importCount) => importCount + 1);\n }\n } catch (error: any) {\n handleError(error);\n setErrored(true);\n }\n };\n\n return (\n <>\n {importing ? (\n <div className='gmw-import-progress-container'>\n <div className='gmw-import-progress-bar'>\n <div className='gmw-import-progress-bar-description'>\n {\n !errored ? importCount !== selectedMappings.length ? (\n <>\n <Text variant='title'>Importing</Text>\n <Text>{`We are currently importing the ${displayStrings.mappings.toLocaleLowerCase()}.`}</Text>\n </>\n ) : (\n <>\n <Text variant='title'>Done!</Text>\n <Text>{`Your imported ${displayStrings.mappings.toLocaleLowerCase()} are ready.`}</Text>\n </>\n ) :\n <>\n <Text variant='title'>Error!</Text>\n <Text>{`Sorry, there was an error importing some or all ${displayStrings.mappings}.`}</Text>\n </>}\n </div>\n <ProgressLinear\n value={(importCount / selectedMappings.length) * 100}\n labels={\n importCount === selectedMappings.length\n ? [\"Import done!\", <SvgStatusSuccessHollow key='0' />]\n : [\n <>\n <Text>Copying</Text>\n <MiddleTextTruncation text={currentlyImporting} />\n </>,\n `${importCount}/${selectedMappings.length}`,\n ]\n }\n status={\n !errored ?\n importCount === selectedMappings.length ? \"positive\" : undefined : \"negative\"\n }\n />\n </div>\n <div className='gmw-import-action-panel'>\n <Button\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => {\n setImporting(false);\n setImportCount(0);\n setCurrentlyImporting(\"\");\n setErrored(false);\n }}\n >\n Back\n </Button>\n <Button\n styleType='high-visibility'\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => onFinish()}\n >\n Close\n </Button>\n </div>\n </div>\n ) : (\n <div className='gmw-rename-confirm-container '>\n <div className='gmw-mapping-rename-container'>\n <div className='gmw-mapping-row-header-container'>\n <div className='gmw-mapping-row'>\n <Text variant='leading'>{displayStrings.mappings}</Text>\n <Text variant='leading'>Description</Text>\n </div>\n </div>\n <div className='gmw-mapping-row-body'>\n {selectedMappings.map((mapping, index) => (\n <div className='gmw-mapping-row-container' key={mapping.id}>\n <div className='gmw-mapping-row'>\n <LabeledInput\n value={mapping.mappingName}\n name={`mapping_${mapping.id}`}\n required\n onChange={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n message={validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )}\n status={\n validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n onBlurCapture={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n />\n <div>{mapping.description}</div>\n </div>\n <div className='gmw-border-div' />\n </div>\n ))}\n </div>\n </div>\n <div className='gmw-import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button styleType='high-visibility' onClick={async () => onImport()}>\n Import\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport default ConfirmMappingImport;\n"]}
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
@import '~@itwin/itwinui-css/scss/variables';
|
|
6
5
|
|
|
7
6
|
.gmw-border-div {
|
|
8
|
-
border-bottom: 1px solid var(--iui-color-background
|
|
7
|
+
border-bottom: 1px solid var(--iui-color-background);
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
.gmw-mapping-row {
|
|
12
11
|
display: grid;
|
|
13
12
|
grid-template-columns: 1fr 1fr;
|
|
14
|
-
grid-column-gap:
|
|
13
|
+
grid-column-gap: var(--iui-size-xl);
|
|
15
14
|
justify-items: stretch;
|
|
16
15
|
align-items: center;
|
|
17
|
-
padding:
|
|
16
|
+
padding: var(--iui-size-s) var(--iui-size-m) var(--iui-size-s) var(--iui-size-m);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
.gmw-import-progress-container {
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
flex-grow: 1;
|
|
31
30
|
justify-content: center;
|
|
32
31
|
align-items: center;
|
|
33
|
-
gap:
|
|
32
|
+
gap: calc(var(--iui-size-s) * 2);
|
|
34
33
|
|
|
35
34
|
.gmw-import-progress-bar-description {
|
|
36
35
|
display: flex;
|
|
@@ -44,7 +43,7 @@
|
|
|
44
43
|
span:first-of-type {
|
|
45
44
|
display: flex;
|
|
46
45
|
width: 80%;
|
|
47
|
-
gap:
|
|
46
|
+
gap: var(--iui-size-2xs);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -65,14 +64,14 @@
|
|
|
65
64
|
.gmw-mapping-row-header-container {
|
|
66
65
|
position: sticky;
|
|
67
66
|
top: 0;
|
|
68
|
-
background-color: var(--iui-color-background
|
|
67
|
+
background-color: var(--iui-color-background);
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
.gmw-mapping-row-body {
|
|
72
71
|
overflow-y: auto;
|
|
73
72
|
|
|
74
73
|
.gmw-mapping-row-container {
|
|
75
|
-
background-color: var(--iui-color-background-
|
|
74
|
+
background-color: var(--iui-color-background-backdrop);
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { Fieldset, LabeledInput, LabeledSelect, LabeledTextarea,
|
|
5
|
+
import { Fieldset, LabeledInput, LabeledSelect, LabeledTextarea, Text, } from "@itwin/itwinui-react";
|
|
6
6
|
import React, { useCallback, useEffect, useState } from "react";
|
|
7
7
|
import ActionPanel from "./ActionPanel";
|
|
8
8
|
import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
|
|
@@ -16,7 +16,7 @@ import { useGroupingMappingApiConfig } from "./context/GroupingApiConfigContext"
|
|
|
16
16
|
import { QuantityType } from "@itwin/insights-client";
|
|
17
17
|
import { usePropertiesContext } from "./context/PropertiesContext";
|
|
18
18
|
const stringToPossibleDataType = (str) => {
|
|
19
|
-
switch (str
|
|
19
|
+
switch (str?.toLowerCase()) {
|
|
20
20
|
case "double":
|
|
21
21
|
case "number": return "Number";
|
|
22
22
|
case "string": return "String";
|
|
@@ -26,35 +26,31 @@ const stringToPossibleDataType = (str) => {
|
|
|
26
26
|
};
|
|
27
27
|
const convertToPropertyMap = (groupProperties, calculatedProperties, customCalculations, selectedPropertyName) => {
|
|
28
28
|
const map = {};
|
|
29
|
-
const selectedLowerName = selectedPropertyName
|
|
29
|
+
const selectedLowerName = selectedPropertyName?.toLowerCase();
|
|
30
30
|
groupProperties.forEach((p) => {
|
|
31
|
-
|
|
32
|
-
const lowerName = (_a = p.propertyName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
31
|
+
const lowerName = p.propertyName?.toLowerCase();
|
|
33
32
|
if (lowerName && lowerName !== selectedLowerName)
|
|
34
33
|
map[lowerName] = stringToPossibleDataType(p.dataType);
|
|
35
34
|
});
|
|
36
35
|
calculatedProperties.forEach((p) => {
|
|
37
|
-
|
|
38
|
-
const lowerName = (_a = p.propertyName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
36
|
+
const lowerName = p.propertyName?.toLowerCase();
|
|
39
37
|
if (lowerName)
|
|
40
38
|
map[lowerName] = "Number";
|
|
41
39
|
});
|
|
42
40
|
customCalculations.forEach((p) => {
|
|
43
|
-
|
|
44
|
-
const lowerName = (_a = p.propertyName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
41
|
+
const lowerName = p.propertyName?.toLowerCase();
|
|
45
42
|
if (lowerName && lowerName !== selectedLowerName)
|
|
46
43
|
map[lowerName] = stringToPossibleDataType(p.dataType);
|
|
47
44
|
});
|
|
48
45
|
return map;
|
|
49
46
|
};
|
|
50
47
|
export const CustomCalculationAction = ({ mappingId, groupId, customCalculation, onSaveSuccess, onClickCancel, }) => {
|
|
51
|
-
var _a, _b, _c;
|
|
52
48
|
const { getAccessToken, iModelId } = useGroupingMappingApiConfig();
|
|
53
49
|
const mappingClient = useMappingClient();
|
|
54
|
-
const [propertyName, setPropertyName] = useState(
|
|
55
|
-
const [formula, setFormula] = useState(
|
|
50
|
+
const [propertyName, setPropertyName] = useState(customCalculation?.propertyName ?? "");
|
|
51
|
+
const [formula, setFormula] = useState(customCalculation?.formula ?? "");
|
|
56
52
|
const { groupProperties, setGroupProperties, calculatedProperties, setCalculatedProperties, customCalculationProperties, setCustomCalculationProperties, } = usePropertiesContext();
|
|
57
|
-
const [quantityType, setQuantityType] = useState(
|
|
53
|
+
const [quantityType, setQuantityType] = useState(customCalculation?.quantityType ?? QuantityType.Undefined);
|
|
58
54
|
const [isLoading, setIsLoading] = useState(true);
|
|
59
55
|
const [formulaErrorMessage, setFormulaErrorMessage] = useState("");
|
|
60
56
|
const [validator, showValidationMessage] = useValidator();
|
|
@@ -86,7 +82,7 @@ export const CustomCalculationAction = ({ mappingId, groupId, customCalculation,
|
|
|
86
82
|
}
|
|
87
83
|
}, [calculatedProperties, customCalculationProperties, groupProperties, initialize]);
|
|
88
84
|
useEffect(() => {
|
|
89
|
-
const propertiesMap = convertToPropertyMap(groupProperties
|
|
85
|
+
const propertiesMap = convertToPropertyMap(groupProperties ?? [], calculatedProperties ?? [], customCalculationProperties ?? []);
|
|
90
86
|
setProperties(propertiesMap);
|
|
91
87
|
}, [calculatedProperties, customCalculationProperties, groupProperties]);
|
|
92
88
|
useEffect(() => {
|
|
@@ -140,7 +136,7 @@ export const CustomCalculationAction = ({ mappingId, groupId, customCalculation,
|
|
|
140
136
|
return (React.createElement(React.Fragment, null,
|
|
141
137
|
React.createElement("div", { className: 'gmw-custom-calculation-action-container' },
|
|
142
138
|
React.createElement(Fieldset, { legend: 'Custom Calculation Details', className: 'gmw-details-form' },
|
|
143
|
-
React.createElement(
|
|
139
|
+
React.createElement(Text, { variant: 'small', as: 'small', className: 'gmw-field-legend' }, "Asterisk * indicates mandatory fields."),
|
|
144
140
|
React.createElement(LabeledInput, { value: propertyName, required: true, name: 'name', label: 'Name', disabled: isLoading, onChange: (event) => {
|
|
145
141
|
setPropertyName(event.target.value);
|
|
146
142
|
validator.showMessageFor("name");
|