@itwin/grouping-mapping-widget 0.7.0 → 0.8.1
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/widget/components/BlockingOverlay.js +1 -2
- package/lib/cjs/widget/components/BlockingOverlay.js.map +1 -1
- package/lib/cjs/widget/components/BlockingOverlay.scss +8 -10
- package/lib/cjs/widget/components/GroupPropertyAction.d.ts +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.js +149 -302
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.scss +82 -8
- package/lib/cjs/widget/components/GroupPropertyUtils.d.ts +21 -0
- package/lib/cjs/widget/components/GroupPropertyUtils.js +287 -0
- package/lib/cjs/widget/components/GroupPropertyUtils.js.map +1 -0
- package/lib/cjs/widget/components/GroupingMapping.scss +4 -1
- package/lib/cjs/widget/components/HorizontalTile.d.ts +5 -3
- package/lib/cjs/widget/components/HorizontalTile.js +9 -6
- package/lib/cjs/widget/components/HorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/HorizontalTile.scss +46 -22
- package/lib/cjs/widget/components/SelectProject.js +2 -0
- package/lib/cjs/widget/components/SelectProject.js.map +1 -1
- package/lib/cjs/widget/components/SortableHorizontalTile.d.ts +8 -0
- package/lib/cjs/widget/components/SortableHorizontalTile.js +51 -0
- package/lib/cjs/widget/components/SortableHorizontalTile.js.map +1 -0
- package/lib/esm/widget/components/BlockingOverlay.js +1 -2
- package/lib/esm/widget/components/BlockingOverlay.js.map +1 -1
- package/lib/esm/widget/components/BlockingOverlay.scss +8 -10
- package/lib/esm/widget/components/GroupPropertyAction.d.ts +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.js +151 -304
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.scss +82 -8
- package/lib/esm/widget/components/GroupPropertyUtils.d.ts +21 -0
- package/lib/esm/widget/components/GroupPropertyUtils.js +280 -0
- package/lib/esm/widget/components/GroupPropertyUtils.js.map +1 -0
- package/lib/esm/widget/components/GroupingMapping.scss +4 -1
- package/lib/esm/widget/components/HorizontalTile.d.ts +5 -3
- package/lib/esm/widget/components/HorizontalTile.js +9 -6
- package/lib/esm/widget/components/HorizontalTile.js.map +1 -1
- package/lib/esm/widget/components/HorizontalTile.scss +46 -22
- package/lib/esm/widget/components/SelectProject.js +2 -0
- package/lib/esm/widget/components/SelectProject.js.map +1 -1
- package/lib/esm/widget/components/SortableHorizontalTile.d.ts +8 -0
- package/lib/esm/widget/components/SortableHorizontalTile.js +30 -0
- package/lib/esm/widget/components/SortableHorizontalTile.js.map +1 -0
- package/package.json +8 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/GroupPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAeA,oEAMoC;AACpC,wEAA4D;AAC5D,oDAA+D;AAC/D,oEAIoC;AAEpC,wDAS8B;AAC9B,+CAAyE;AACzE,gEAAwC;AACxC,sEAAwE;AACxE,mCAAoD;AACpD,sCAAoC;AAEpC,4DAAgE;AAChE,yEAAkE;AAClE,iFAAiF;AAYpE,QAAA,6BAA6B,GAAiC;IACzE,EAAE,KAAK,EAAE,8BAAY,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;IAC3C,EAAE,KAAK,EAAE,8BAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;IACnD,EAAE,KAAK,EAAE,8BAAY,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;IAC7C,EAAE,KAAK,EAAE,8BAAY,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;IAC3C,EAAE,KAAK,EAAE,8BAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;IACnD,EAAE,KAAK,EAAE,8BAAY,CAAC,IAA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C,CAAC;AAEF,kBAAe,mBAAmB,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 type { IModelConnection } from \"@itwin/core-frontend\";\nimport type {\n ContentDescriptorRequestOptions,\n Field,\n KeySet,\n NestedContentField,\n PropertiesField,\n Ruleset,\n RulesetVariable,\n StructFieldMemberDescription,\n} from \"@itwin/presentation-common\";\nimport {\n ContentSpecificationTypes,\n DefaultContentDisplayTypes,\n PropertyValueFormat,\n RelationshipMeaning,\n RuleTypes,\n} from \"@itwin/presentation-common\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport {\n SvgChevronDown,\n SvgChevronUp,\n SvgRemove,\n} from \"@itwin/itwinui-icons-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport {\n Alert,\n Fieldset,\n IconButton,\n LabeledInput,\n LabeledSelect,\n Select,\n Small,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport \"./GroupPropertyAction.scss\";\nimport type { ECProperty, GroupProperty, GroupPropertyCreate} from \"@itwin/insights-client\";\nimport { DataType, QuantityType } from \"@itwin/insights-client\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\ninterface GroupPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n groupPropertyId?: string;\n groupPropertyName?: string;\n keySet: KeySet;\n returnFn: (modified: boolean) => Promise<void>;\n}\n\nexport const quantityTypesSelectionOptions: SelectOption<QuantityType>[] = [\n { value: QuantityType.Area, label: \"Area\" },\n { value: QuantityType.Distance, label: \"Distance\" },\n { value: QuantityType.Force, label: \"Force\" },\n { value: QuantityType.Mass, label: \"Mass\" },\n { value: QuantityType.Monetary, label: \"Monetary\" },\n { value: QuantityType.Time, label: \"Time\" },\n { value: QuantityType.Volume, label: \"Volume\" },\n { value: QuantityType.Undefined, label: \"No Quantity Type\" },\n];\ninterface Property {\n name: string;\n label: string;\n type: string;\n}\n\ninterface NavigationProperty {\n navigationName: string;\n rootClassName: string;\n}\n\nconst extractPrimitive = (\n propertiesField: PropertiesField,\n classToPropertiesMapping: Map<string, Property[]>,\n navigation?: NavigationProperty\n) => {\n // There are rare cases which only happens in multiple selections where it returns more than one.\n // This also checks if this property comes from a navigation property\n const className =\n navigation?.rootClassName ??\n propertiesField.properties[0].property.classInfo.name;\n // Sometimes class names are not defined. Type error. Not guaranteed.\n if (!className) {\n return;\n }\n\n if (!classToPropertiesMapping.has(className)) {\n classToPropertiesMapping.set(className, []);\n }\n\n // Gets property name. Appends path if from navigation.\n const propertyName = navigation\n ? `${navigation.navigationName}.${propertiesField.properties[0].property.name}`\n : propertiesField.properties[0].property.name;\n\n const label = navigation\n ? `${propertiesField.label} (${navigation?.navigationName})`\n : propertiesField.label;\n\n // Ignore hardcoded BisCore navigation properties\n if (propertiesField.type.typeName === \"navigation\") {\n return;\n } else {\n classToPropertiesMapping.get(className)?.push({\n name: propertyName,\n label,\n type: propertiesField.properties[0].property.type,\n });\n }\n};\n\nconst extractStructProperties = (\n name: string,\n className: string,\n classToPropertiesMapping: Map<string, Property[]>,\n members: StructFieldMemberDescription[]\n) => {\n for (const member of members) {\n if (member.type.valueFormat === PropertyValueFormat.Primitive) {\n if (!classToPropertiesMapping.has(className)) {\n classToPropertiesMapping.set(className, []);\n }\n\n classToPropertiesMapping.get(className)?.push({\n name: `${name}.${member.name}`,\n label: member.label,\n type: member.type.typeName,\n });\n } else if (member.type.valueFormat === PropertyValueFormat.Struct) {\n extractStructProperties(\n `${name}.${member.name}`,\n className,\n classToPropertiesMapping,\n member.type.members\n );\n }\n }\n};\n\nconst extractProperties = (\n properties: Field[],\n classToPropertiesMapping: Map<string, Property[]>,\n navigation?: NavigationProperty\n) => {\n for (const property of properties) {\n switch (property.type.valueFormat) {\n case PropertyValueFormat.Primitive: {\n extractPrimitive(\n property as PropertiesField,\n classToPropertiesMapping,\n navigation\n );\n break;\n }\n // Get structs\n case PropertyValueFormat.Struct: {\n const nestedContentField = property as NestedContentField;\n // Only handling single path and not handling nested content fields within navigations\n if (\n nestedContentField.pathToPrimaryClass &&\n nestedContentField.pathToPrimaryClass.length > 1\n ) {\n break;\n }\n\n switch (nestedContentField.relationshipMeaning) {\n case RelationshipMeaning.SameInstance: {\n // Check for aspects. Ignore them if coming from navigation.\n if (\n !navigation &&\n (nestedContentField.pathToPrimaryClass[0].relationshipInfo\n .name === \"BisCore:ElementOwnsUniqueAspect\" ||\n nestedContentField.pathToPrimaryClass[0].relationshipInfo\n .name === \"BisCore:ElementOwnsMultiAspects\")\n ) {\n const className = nestedContentField.contentClassInfo.name;\n if (!classToPropertiesMapping.has(className)) {\n classToPropertiesMapping.set(className, []);\n }\n\n extractProperties(\n nestedContentField.nestedFields,\n classToPropertiesMapping,\n navigation\n );\n }\n\n break;\n }\n // Navigation properties\n case RelationshipMeaning.RelatedInstance: {\n if (\n // Deal with a TypeDefinition\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name ===\n \"BisCore:GeometricElement3dHasTypeDefinition\"\n ) {\n const className =\n nestedContentField.pathToPrimaryClass[0].targetClassInfo.name;\n extractProperties(\n nestedContentField.nestedFields,\n classToPropertiesMapping,\n {\n navigationName: \"TypeDefinition\",\n rootClassName: className,\n }\n );\n // Hardcoded BisCore navigation properties for the type definition.\n classToPropertiesMapping.get(className)?.push({\n name: \"TypeDefinition.Model.ModeledElement.UserLabel\",\n label: \"Model UserLabel (TypeDefinition)\",\n type: \"string\",\n });\n\n classToPropertiesMapping.get(className)?.push({\n name: \"TypeDefinition.Model.ModeledElement.CodeValue\",\n label: \"Model CodeValue (TypeDefinition)\",\n type: \"string\",\n });\n\n }\n break;\n }\n default: {\n // Some elements don't have a path to primary class or relationship meaning..\n // Most likely a simple struct property\n if (!nestedContentField.pathToPrimaryClass) {\n const columnName = (property as PropertiesField).properties[0]\n .property.name;\n const className = (property as PropertiesField).properties[0]\n .property.classInfo.name;\n extractStructProperties(\n navigation\n ? `${navigation.navigationName}.${columnName}`\n : columnName,\n navigation ? navigation.rootClassName : className,\n classToPropertiesMapping,\n property.type.members\n );\n\n }\n }\n }\n }\n }\n }\n};\n\nconst GroupPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n groupPropertyId,\n groupPropertyName,\n keySet,\n returnFn,\n}: GroupPropertyActionProps) => {\n const iModelConnection = useActiveIModelConnection() as IModelConnection;\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\"\");\n const [dataType, setDataType] = useState<DataType>(DataType.Undefined);\n const [quantityType, setQuantityType] = useState<QuantityType>(QuantityType.Undefined);\n const [classToPropertiesMapping, setClassToPropertiesMapping] =\n useState<Map<string, Property[]>>();\n const [ecProperties, setEcProperties] = useState<ECProperty[]>(\n []\n );\n const [validator, showValidationMessage] = useValidator();\n const [propertyAlert, setPropertyAlert] = useState<boolean>(false);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n\n useEffect(() => {\n const getContent = async () => {\n setIsLoading(true);\n const ruleSet: Ruleset = {\n id: \"element-properties\",\n rules: [\n {\n ruleType: RuleTypes.Content,\n specifications: [\n {\n specType: ContentSpecificationTypes.SelectedNodeInstances,\n },\n ],\n }],\n };\n const requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> = {\n imodel: iModelConnection,\n keys: keySet,\n rulesetOrId: ruleSet,\n displayType: DefaultContentDisplayTypes.PropertyPane,\n };\n const content = await Presentation.presentation.getContentDescriptor(\n requestOptions\n );\n\n // Only primitives and structs for now\n const properties =\n content?.fields.filter(\n (field) =>\n field.type.valueFormat === PropertyValueFormat.Primitive ||\n field.type.valueFormat === PropertyValueFormat.Struct\n ) ?? [];\n\n // Map properties to their classes\n const classToPropertiesMapping = new Map<string, Property[]>();\n\n extractProperties(properties, classToPropertiesMapping);\n\n const rootClassName = keySet.instanceKeys.keys().next().value;\n\n // Hardcoded BisCore navigation properties.\n classToPropertiesMapping.get(rootClassName)?.push({\n name: \"Model.ModeledElement.UserLabel\",\n label: \"Model UserLabel\",\n type: \"string\",\n });\n\n classToPropertiesMapping.get(rootClassName)?.push({\n name: \"Model.ModeledElement.CodeValue\",\n label: \"Model CodeValue\",\n type: \"string\",\n });\n\n classToPropertiesMapping.get(rootClassName)?.push({\n name: \"Category.CodeValue\",\n label: \"Category CodeValue\",\n type: \"string\",\n });\n\n classToPropertiesMapping.get(rootClassName)?.push({\n name: \"Category.UserLabel\",\n label: \"Category UserLabel\",\n type: \"string\",\n });\n\n setClassToPropertiesMapping(classToPropertiesMapping);\n\n let newEcProperties: ECProperty[];\n // Fetch already existing ec properties then add all classes from presentation\n if (groupPropertyId) {\n const accessToken = await getAccessToken();\n let response: GroupProperty | undefined;\n try {\n response = await mappingClient.getGroupProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n groupPropertyId\n );\n } catch (error: any) {\n handleError(error.status);\n }\n\n if (!response) {\n return;\n }\n newEcProperties = response.ecProperties;\n\n let keys = Array.from(classToPropertiesMapping.keys()).reverse();\n for (const ecProperty of newEcProperties) {\n keys = keys.filter(\n (key) =>\n `${ecProperty.ecSchemaName}:${ecProperty.ecClassName}` !== key\n );\n }\n\n newEcProperties.push(\n ...keys.map((key) => ({\n ecSchemaName: key.split(\":\")[0],\n ecClassName: key.split(\":\")[1],\n // Placeholders for properties\n ecPropertyName: \"\",\n ecPropertyType: DataType.Undefined,\n }))\n );\n\n setPropertyName(response.propertyName);\n setDataType(response.dataType);\n setQuantityType(response.quantityType);\n } else {\n newEcProperties = Array.from(classToPropertiesMapping)\n .map(([key]) => ({\n ecSchemaName: key.split(\":\")[0],\n ecClassName: key.split(\":\")[1],\n // Placeholders for properties\n ecPropertyName: \"\",\n ecPropertyType: DataType.Undefined,\n }))\n .reverse();\n }\n\n setEcProperties(newEcProperties);\n\n setIsLoading(false);\n };\n void getContent();\n }, [getAccessToken, mappingClient, groupId, groupPropertyId, iModelConnection, iModelId, keySet, mappingId]);\n\n const onSave = async () => {\n const filteredEcProperties = ecProperties.filter(\n (ecProperty) => ecProperty.ecPropertyName && ecProperty.ecPropertyType\n );\n if (!filteredEcProperties.length || !validator.allValid()) {\n showValidationMessage(true);\n if (!filteredEcProperties.length) {\n setPropertyAlert(true);\n }\n return;\n }\n try {\n setIsLoading(true);\n const accessToken = await getAccessToken();\n const groupProperty: GroupPropertyCreate = {\n propertyName,\n dataType,\n quantityType,\n ecProperties: filteredEcProperties,\n };\n groupPropertyId\n ? await mappingClient.updateGroupProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n groupPropertyId,\n groupProperty\n )\n : await mappingClient.createGroupProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n groupProperty\n );\n await returnFn(true);\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const onChange = useCallback((value: string, index: number) => {\n setPropertyAlert(false);\n const property = JSON.parse(value);\n setEcProperties((ecProperties) => {\n const updatedEcProperties = [...ecProperties];\n updatedEcProperties[index].ecPropertyName = property.name;\n\n // Unique types\n let type = DataType.Undefined;\n switch (property.type) {\n case \"long\":\n type = DataType.Integer;\n break;\n default:\n type = property.type;\n }\n\n updatedEcProperties[index].ecPropertyType = type;\n return updatedEcProperties;\n });\n }, []);\n\n const propertyOptions = useMemo(() => {\n return ecProperties.map(\n (ecProperty: ECProperty) =>\n classToPropertiesMapping\n ?.get(`${ecProperty.ecSchemaName}:${ecProperty.ecClassName}`)\n ?.map((property) => ({\n value: JSON.stringify({\n name: property.name,\n type: property.type,\n }),\n label: property.label,\n })) ?? []\n );\n }, [classToPropertiesMapping, ecProperties]);\n\n const getValue = useCallback(\n (ecProperty: ECProperty, index: number) => {\n const property = classToPropertiesMapping\n ?.get(`${ecProperty.ecSchemaName}:${ecProperty.ecClassName}`)\n ?.find(\n (property) => property.name === ecProperties[index].ecPropertyName\n );\n const result = JSON.stringify({\n name: property?.name,\n type: property?.type,\n });\n return result;\n },\n [classToPropertiesMapping, ecProperties]\n );\n\n return (\n <>\n <WidgetHeader\n title={groupPropertyName ?? \"Add Property\"}\n returnFn={async () => returnFn(false)}\n />\n <div className='gmw-group-property-action-container'>\n <Fieldset className='gmw-property-options' legend='Property Details'>\n <Small className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n id='propertyName'\n label='Property Name'\n value={propertyName}\n required\n disabled={isLoading}\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"propertyName\");\n }}\n message={validator.message(\n \"propertyName\",\n propertyName,\n NAME_REQUIREMENTS\n )}\n status={\n validator.message(\"propertyName\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"propertyName\");\n }}\n />\n <LabeledSelect<DataType>\n label={\"Data Type\"}\n id='dataType'\n disabled={isLoading}\n options={[\n { value: DataType.Boolean, label: \"Boolean\" },\n { value: DataType.Number, label: \"Number\" },\n { value: DataType.String, label: \"String\" },\n ]}\n required\n value={dataType}\n onChange={(value) => {\n validator.showMessageFor(\"dataType\");\n setDataType(value);\n }}\n message={validator.message(\"dataType\", propertyName, \"required\")}\n status={\n validator.message(\"dataType\", propertyName, \"required\")\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"dataType\");\n }}\n onShow={() => { }}\n onHide={() => { }}\n />\n <LabeledSelect<QuantityType>\n label='Quantity Type'\n disabled={isLoading}\n options={quantityTypesSelectionOptions}\n value={quantityType}\n onChange={setQuantityType}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n <Fieldset className='gmw-property-selection-container' legend='Properties'>\n {propertyAlert && (\n <Alert type={\"negative\"}>\n Please select at least one property.\n </Alert>\n )}\n {isLoading &&\n Array(3)\n .fill(null)\n .map((_, index) => (\n <Text key={index} variant='headline' isSkeleton>\n LOADING SKELETON\n </Text>\n ))}\n {ecProperties.map((ecProperty, index) => {\n return (\n <div\n className='gmw-property-select-item'\n key={`${ecProperty.ecSchemaName}${ecProperty.ecClassName}`}\n >\n <Text variant='leading'>{ecProperty.ecClassName}</Text>\n <Text isMuted variant='small'>\n {ecProperty.ecSchemaName}\n </Text>\n\n <div className='gmw-selection-and-reorder'>\n <Select<string>\n options={propertyOptions[index]}\n value={getValue(ecProperty, index)}\n onChange={(value) => { value && onChange(value, index); }}\n placeholder=\"<No Property Mapped>\"\n style={{ width: \"100%\" }}\n onShow={() => { }}\n onHide={() => { }}\n />\n <IconButton\n onClick={() => {\n const updatedEcPropertyList = [...ecProperties];\n updatedEcPropertyList[index] = {\n ...updatedEcPropertyList[index],\n ecPropertyName: \"\",\n ecPropertyType: DataType.Undefined,\n };\n setEcProperties(updatedEcPropertyList);\n }}\n disabled={\n !ecProperty.ecPropertyName && !ecProperty.ecPropertyType\n }\n >\n <SvgRemove />\n </IconButton>\n <IconButton\n onClick={() => {\n const tab = [...ecProperties];\n const item = tab.splice(index, 1);\n tab.splice(index - 1, 0, item[0]);\n setEcProperties(tab);\n }}\n disabled={index === 0}\n >\n <SvgChevronUp />\n </IconButton>\n <IconButton\n onClick={() => {\n const tab = [...ecProperties];\n const item = tab.splice(index, 1);\n tab.splice(index + 1, 0, item[0]);\n setEcProperties(tab);\n }}\n disabled={index === ecProperties.length - 1}\n >\n <SvgChevronDown />\n </IconButton>\n </div>\n </div>\n );\n })}\n </Fieldset>\n </div>\n {/* TODO: Disable when no properties are selected. Will do when I rework property selection. */}\n <ActionPanel onSave={onSave} onCancel={async () => returnFn(false)} isLoading={isLoading} />\n </>\n );\n};\n\nexport default GroupPropertyAction;\n"]}
|
|
1
|
+
{"version":3,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H,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,mBAAmB,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 { renderToStaticMarkup } from \"react-dom/server\";\nimport type { KeySet } from \"@itwin/presentation-common\";\nimport { PropertyValueFormat } from \"@itwin/presentation-common\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport {\n Alert,\n Button,\n Fieldset,\n IconButton,\n Label,\n LabeledInput,\n LabeledSelect,\n Modal,\n ModalButtonBar,\n Small,\n Surface,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport { HorizontalTile } from \"./HorizontalTile\";\nimport { DataType, QuantityType } from \"@itwin/insights-client\";\nimport type {\n GroupProperty,\n GroupPropertyCreate,\n} from \"@itwin/insights-client\";\nimport {\n SvgClose,\n SvgDragHandleVertical,\n SvgMoreVerticalSmall,\n SvgRemove,\n SvgSearch,\n} from \"@itwin/itwinui-icons-react\";\nimport type { DragEndEvent, DragStartEvent } from \"@dnd-kit/core\";\nimport {\n closestCenter,\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport {\n arrayMove,\n SortableContext,\n sortableKeyboardCoordinates,\n verticalListSortingStrategy,\n} from \"@dnd-kit/sortable\";\nimport SortableHorizontalTile from \"./SortableHorizontalTile\";\nimport Split from \"react-split\";\nimport \"./GroupPropertyAction.scss\";\nimport type { PropertyMetaData } from \"./GroupPropertyUtils\";\nimport {\n convertPresentationFields,\n convertToECProperties,\n fetchPresentationDescriptor,\n findProperties,\n} from \"./GroupPropertyUtils\";\n\ninterface GroupPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n groupPropertyId?: string;\n groupPropertyName?: string;\n keySet: KeySet;\n returnFn: (modified: boolean) => Promise<void>;\n}\n\nexport const quantityTypesSelectionOptions: SelectOption<QuantityType>[] = [\n { value: QuantityType.Area, label: \"Area\" },\n { value: QuantityType.Distance, label: \"Distance\" },\n { value: QuantityType.Force, label: \"Force\" },\n { value: QuantityType.Mass, label: \"Mass\" },\n { value: QuantityType.Monetary, label: \"Monetary\" },\n { value: QuantityType.Time, label: \"Time\" },\n { value: QuantityType.Volume, label: \"Volume\" },\n { value: QuantityType.Undefined, label: \"No Quantity Type\" },\n];\n\nconst GroupPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n groupPropertyId,\n groupPropertyName,\n keySet,\n returnFn,\n}: GroupPropertyActionProps) => {\n const iModelConnection = useActiveIModelConnection();\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\"\");\n const [dataType, setDataType] = useState<DataType>(DataType.Undefined);\n const [quantityType, setQuantityType] = useState<QuantityType>(QuantityType.Undefined);\n const [selectedProperties, setSelectedProperties] = useState<PropertyMetaData[]>([]);\n const [propertiesMetaData, setPropertiesMetaData] = useState<PropertyMetaData[]>([]);\n const [propertiesNotFoundAlert, setPropertiesNotFoundAlert] = useState<boolean>(false);\n const [validator, showValidationMessage] = useValidator();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [searchInput, setSearchInput] = useState<string>(\"\");\n const [activeSearchInput, setActiveSearchInput] = useState<string>(\"\");\n const [searched, setSearched] = useState<boolean>(false);\n const [activeDragProperty, setActiveDragProperty] = useState<PropertyMetaData | undefined>();\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n })\n );\n const [showModal, setShowModal] = useState<boolean>(false);\n\n const handleDragStart = useCallback((event: DragStartEvent) => {\n const { active } = event;\n const activeProperty = selectedProperties.find((p) => active.id === p.key);\n setActiveDragProperty(activeProperty);\n }, [selectedProperties]);\n\n const handleDragEnd = useCallback((event: DragEndEvent) => {\n const { active, over } = event;\n\n if (over && (active.id !== over.id)) {\n setSelectedProperties((items) => {\n const oldIndex = selectedProperties.findIndex((p) => active.id === p.key);\n const newIndex = selectedProperties.findIndex((p) => over.id === p.key);\n\n return arrayMove(items, oldIndex, newIndex);\n });\n }\n\n setActiveDragProperty(undefined);\n }, [selectedProperties]);\n\n const filteredProperties = useMemo(\n () =>\n propertiesMetaData.filter((p) =>\n [p.displayLabel, p.categoryLabel, p.actualECClassName]\n .map((l) => l.toLowerCase())\n .some((l) => l.includes(activeSearchInput.toLowerCase()))\n ),\n [activeSearchInput, propertiesMetaData]\n );\n\n useEffect(() => {\n const generateProperties = async () => {\n setIsLoading(true);\n\n if (!iModelConnection) return;\n\n const descriptor = await fetchPresentationDescriptor(iModelConnection, keySet);\n\n // Only allow primitives and structs\n const propertyFields =\n descriptor?.fields.filter(\n (field) =>\n field.type.valueFormat === PropertyValueFormat.Primitive ||\n field.type.valueFormat === PropertyValueFormat.Struct\n ) ?? [];\n\n const propertiesMetaData = convertPresentationFields(propertyFields);\n\n setPropertiesMetaData(propertiesMetaData);\n\n if (groupPropertyId) {\n const accessToken = await getAccessToken();\n let response: GroupProperty | undefined;\n try {\n response = await mappingClient.getGroupProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n groupPropertyId\n );\n\n setPropertyName(response.propertyName);\n setDataType(response.dataType);\n setQuantityType(response.quantityType);\n const properties = findProperties(response.ecProperties, propertiesMetaData);\n if (properties.length === 0) {\n setPropertiesNotFoundAlert(true);\n }\n\n setSelectedProperties(properties);\n } catch (error: any) {\n handleError(error.status);\n }\n }\n\n setIsLoading(false);\n };\n void generateProperties();\n }, [getAccessToken, mappingClient, groupId, groupPropertyId, iModelConnection, iModelId, keySet, mappingId]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n const accessToken = await getAccessToken();\n const groupProperty: GroupPropertyCreate = {\n propertyName,\n dataType,\n quantityType,\n ecProperties: selectedProperties.map((p) => convertToECProperties(p)).flat(),\n };\n groupPropertyId\n ? await mappingClient.updateGroupProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n groupPropertyId,\n groupProperty\n )\n : await mappingClient.createGroupProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n groupProperty\n );\n await returnFn(true);\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const startSearch = useCallback(() => {\n if (!searchInput) return;\n setActiveSearchInput(searchInput);\n setSearched(true);\n }, [searchInput]);\n\n const clearSearch = useCallback(() => {\n setSearchInput(\"\");\n setActiveSearchInput(\"\");\n setSearched(false);\n }, []);\n\n useEffect(() => {\n if (searchInput.length === 0) {\n setSearched(false);\n clearSearch();\n }\n }, [searchInput, setSearched, clearSearch]);\n\n return (\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n >\n <WidgetHeader\n title={groupPropertyName ?? \"Add Property\"}\n returnFn={async () => returnFn(false)}\n />\n <div className='gmw-group-property-action-container'>\n <Fieldset disabled={isLoading} className='gmw-property-options' legend='Property Details'>\n <Small className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n id='propertyName'\n label='Property Name'\n value={propertyName}\n required\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"propertyName\");\n }}\n message={validator.message(\n \"propertyName\",\n propertyName,\n NAME_REQUIREMENTS\n )}\n status={\n validator.message(\"propertyName\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"propertyName\");\n }}\n />\n <LabeledSelect<DataType>\n label={\"Data Type\"}\n id='dataType'\n options={[\n { value: DataType.Boolean, label: \"Boolean\" },\n { value: DataType.Number, label: \"Number\" },\n { value: DataType.String, label: \"String\" },\n ]}\n required\n value={dataType}\n onChange={(value) => {\n validator.showMessageFor(\"dataType\");\n setDataType(value);\n }}\n message={validator.message(\"dataType\", propertyName, \"required\")}\n status={\n validator.message(\"dataType\", propertyName, \"required\")\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"dataType\");\n }}\n onShow={() => { }}\n onHide={() => { }}\n />\n <LabeledSelect<QuantityType>\n label='Quantity Type'\n options={quantityTypesSelectionOptions}\n value={quantityType}\n onChange={setQuantityType}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n {propertiesNotFoundAlert &&\n <Alert type=\"warning\">\n Warning: Could not match saved properties from the current generated list. It does not confirm or deny validity. Overwriting will occur if a new selection is made and saved.\n </Alert>\n }\n <Fieldset className='gmw-property-view-container' legend=\"Mapped Properties\">\n <div className=\"gmw-property-view-button\">\n <Button\n onClick={async () => setShowModal(true)}\n disabled={isLoading}\n >\n Select Properties\n </Button>\n </div>\n <div className=\"gmw-properties-list\">\n {selectedProperties.length === 0 && !isLoading ?\n <div className=\"gmw-empty-selection\">\n <Text>No properties selected.</Text>\n <Text>Press the "Select Properties" button for options.</Text>\n </div> :\n selectedProperties.map((property) => (\n <HorizontalTile\n key={property.key}\n title={`${property.displayLabel} (${property.propertyType})`}\n titleTooltip={`${property.actualECClassName}`}\n subText={property.categoryLabel}\n actionGroup={null}\n />\n ))}\n </div>\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={async () => returnFn(false)}\n isLoading={isLoading}\n isSavingDisabled={\n selectedProperties.length === 0 || !propertyName || !dataType\n }\n />\n <Modal\n title=\"Properties Selection\"\n isOpen={showModal}\n onClose={() => {\n setShowModal(false);\n clearSearch();\n }}\n closeOnExternalClick={false}\n >\n <Split\n expandToMin={false}\n className=\"gmw-property-selection-container\"\n gutterAlign=\"center\"\n gutterSize={2}\n gutter={() => {\n // Expects HTMLElement\n const dragHangle = renderToStaticMarkup(<div className=\"gmw-gutter-drag-icon\"><SvgMoreVerticalSmall /></div>);\n const gutter = document.createElement(\"div\");\n gutter.className = `gmw-gutter`;\n gutter.innerHTML = dragHangle;\n return gutter;\n }}\n direction=\"horizontal\">\n <Surface className=\"gmw-available-properties\" elevation={1}>\n <div className=\"gmw-available-properties-header\">\n <Label as=\"span\">Available Properties</Label>\n <LabeledInput\n displayStyle=\"inline\"\n iconDisplayStyle=\"inline\"\n className=\"gmw-available-prop-search\"\n value={searchInput}\n size=\"small\"\n placeholder=\"Search....\"\n onChange={(event) => {\n const {\n target: { value },\n } = event;\n setSearchInput(value);\n }}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n startSearch();\n }\n }}\n svgIcon={\n searched ? (\n <IconButton onClick={clearSearch} styleType=\"borderless\">\n <SvgClose />\n </IconButton>\n ) : (\n <IconButton onClick={startSearch} styleType=\"borderless\">\n <SvgSearch />\n </IconButton>\n )\n }\n />\n </div>\n {filteredProperties.length === 0 ?\n <div className=\"gmw-empty-selection\">\n <Text>No properties available. </Text>\n </div> :\n <div className=\"gmw-properties-list\">\n {\n filteredProperties.map((property) => (\n <HorizontalTile\n key={property.key}\n title={`${property.displayLabel} (${property.propertyType})`}\n titleTooltip={`${property.actualECClassName}`}\n subText={property.categoryLabel}\n actionGroup={null}\n selected={selectedProperties.some((p) => property.key === p.key)}\n onClick={() =>\n setSelectedProperties((sp) =>\n sp.some((p) => property.key === p.key)\n ? sp.filter(\n (p) => property.key !== p.key\n )\n : [...sp, property]\n )\n }\n />\n ))}\n </div>}\n </Surface>\n <Surface className=\"gmw-selected-properties\" elevation={1}>\n <Label as=\"span\">Selected Properties</Label>\n {selectedProperties.length === 0 ?\n <div className=\"gmw-empty-selection\">\n <Text>No properties selected.</Text>\n <Text>Add some by clicking on the properties shown left.</Text>\n </div> :\n <div className=\"gmw-properties-list\" >\n <SortableContext\n items={selectedProperties.map((p) => p.key)}\n strategy={verticalListSortingStrategy}\n >\n {selectedProperties.map((property) =>\n <SortableHorizontalTile\n key={property.key}\n id={property.key}\n title={`${property.displayLabel} (${property.propertyType})`}\n titleTooltip={`${property.actualECClassName}`}\n subText={property.categoryLabel}\n actionGroup={\n <div>\n <IconButton\n styleType=\"borderless\"\n title=\"Remove\"\n onClick={() => {\n setSelectedProperties((sp) => sp.filter(\n (p) => property.key !== p.key\n ));\n }\n }>\n <SvgRemove />\n </IconButton>\n </div>\n }\n />)}\n </SortableContext>\n </div>}\n </Surface>\n </Split>\n <ModalButtonBar>\n <Button\n onClick={() => {\n setShowModal(false);\n clearSearch();\n }}\n styleType=\"high-visibility\"\n >\n Close\n </Button>\n </ModalButtonBar>\n </Modal>\n <DragOverlay zIndex={9999}>\n {activeDragProperty ?\n <HorizontalTile\n title={`${activeDragProperty.displayLabel} (${activeDragProperty.propertyType})`}\n titleTooltip={`${activeDragProperty.actualECClassName}`}\n subText={activeDragProperty.categoryLabel}\n actionGroup={\n <IconButton\n styleType=\"borderless\">\n <SvgRemove />\n </IconButton>}\n dragHandle={<div className=\"gmw-drag-icon\" ><SvgDragHandleVertical /></div>}\n /> : null}\n </DragOverlay>\n </DndContext>\n );\n};\n\nexport default GroupPropertyAction;\n\n"]}
|
|
@@ -2,31 +2,105 @@
|
|
|
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
|
|
5
|
+
@import "~@itwin/itwinui-css/scss/variables";
|
|
6
|
+
@import "~@itwin/itwinui-css/scss/icon/index";
|
|
6
7
|
|
|
7
8
|
.gmw-group-property-action-container {
|
|
8
9
|
display: flex;
|
|
9
10
|
flex-direction: column;
|
|
10
11
|
overflow-x: auto;
|
|
11
12
|
height: 100%;
|
|
13
|
+
gap: $iui-baseline;
|
|
12
14
|
|
|
13
15
|
.gmw-property-options {
|
|
14
16
|
display: inherit;
|
|
15
17
|
flex-direction: inherit;
|
|
16
18
|
gap: $iui-baseline;
|
|
17
|
-
margin-bottom: $iui-baseline * 4;
|
|
18
19
|
}
|
|
20
|
+
}
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
.gmw-properties-list {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: 7.5px;
|
|
26
|
+
flex: 1;
|
|
27
|
+
overflow-y: overlay;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.gmw-properties-list-surface {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
gap: 7.5px;
|
|
34
|
+
flex: 1;
|
|
35
|
+
overflow-y: overlay;
|
|
36
|
+
padding: $iui-baseline $iui-m;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.gmw-property-view-container {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
flex-grow: 1;
|
|
43
|
+
gap: $iui-baseline;
|
|
44
|
+
min-height: 0;
|
|
45
|
+
padding: $iui-baseline $iui-m;
|
|
46
|
+
min-width: 0;
|
|
47
|
+
.gmw-property-view-button {
|
|
48
|
+
display: flex;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.gmw-property-selection-container {
|
|
53
|
+
display: flex;
|
|
54
|
+
gap: $iui-s;
|
|
55
|
+
width: 45vw;
|
|
56
|
+
min-width: 100%;
|
|
57
|
+
height: 75vh;
|
|
58
|
+
|
|
59
|
+
.gmw-gutter {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
align-items: center;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.gmw-selected-properties {
|
|
21
67
|
display: flex;
|
|
22
68
|
flex-direction: column;
|
|
23
69
|
gap: $iui-baseline;
|
|
70
|
+
padding: $iui-baseline $iui-m;
|
|
71
|
+
}
|
|
24
72
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
73
|
+
.gmw-available-properties {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
gap: $iui-baseline;
|
|
77
|
+
padding: $iui-baseline $iui-m;
|
|
78
|
+
.gmw-available-properties-header {
|
|
79
|
+
display: flex;
|
|
80
|
+
justify-content: space-between;
|
|
81
|
+
flex-wrap: wrap;
|
|
82
|
+
gap: $iui-s;
|
|
83
|
+
.gmw-available-prop-search {
|
|
84
|
+
flex: 1 1 80px;
|
|
85
|
+
min-width: 80px;
|
|
86
|
+
max-width: 300px;
|
|
29
87
|
}
|
|
30
88
|
}
|
|
31
89
|
}
|
|
32
|
-
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.gmw-gutter-drag-icon {
|
|
93
|
+
@include iui-icons-large();
|
|
94
|
+
justify-content: center;
|
|
95
|
+
cursor: col-resize;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.gmw-empty-selection {
|
|
99
|
+
display: flex;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
align-items: center;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
gap: $iui-baseline;
|
|
104
|
+
padding: $iui-baseline $iui-m;
|
|
105
|
+
height: 100%;
|
|
106
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IModelConnection } from "@itwin/core-frontend";
|
|
2
|
+
import type { ECProperty } from "@itwin/insights-client";
|
|
3
|
+
import { DataType } from "@itwin/insights-client";
|
|
4
|
+
import type { Field, KeySet } from "@itwin/presentation-common";
|
|
5
|
+
export interface PropertyMetaData {
|
|
6
|
+
displayLabel: string;
|
|
7
|
+
sourceSchema: string;
|
|
8
|
+
sourceClassName: string;
|
|
9
|
+
categoryLabel: string;
|
|
10
|
+
propertyType: DataType;
|
|
11
|
+
actualECClassName: string;
|
|
12
|
+
parentPropertyClassName: string | undefined;
|
|
13
|
+
ecPropertyTraversal: string[];
|
|
14
|
+
primitiveNavigationClass: string;
|
|
15
|
+
key: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const convertPresentationFields: (propertyFields: Field[]) => PropertyMetaData[];
|
|
18
|
+
export declare const convertToECProperties: (property: PropertyMetaData) => ECProperty[];
|
|
19
|
+
export declare const findProperties: (ecProperties: ECProperty[], propertiesMetaData: PropertyMetaData[]) => PropertyMetaData[];
|
|
20
|
+
export declare const fetchPresentationDescriptor: (iModelConnection: IModelConnection, keySet: KeySet) => Promise<import("@itwin/presentation-common").Descriptor | undefined>;
|
|
21
|
+
//# sourceMappingURL=GroupPropertyUtils.d.ts.map
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchPresentationDescriptor = exports.findProperties = exports.convertToECProperties = exports.convertPresentationFields = void 0;
|
|
4
|
+
const insights_client_1 = require("@itwin/insights-client");
|
|
5
|
+
const presentation_common_1 = require("@itwin/presentation-common");
|
|
6
|
+
const presentation_frontend_1 = require("@itwin/presentation-frontend");
|
|
7
|
+
const fast_equals_1 = require("fast-equals");
|
|
8
|
+
const convertType = (type) => {
|
|
9
|
+
switch (type) {
|
|
10
|
+
case "int":
|
|
11
|
+
case "enum":
|
|
12
|
+
case "long":
|
|
13
|
+
return insights_client_1.DataType.Integer;
|
|
14
|
+
case "boolean":
|
|
15
|
+
return insights_client_1.DataType.Boolean;
|
|
16
|
+
case "double":
|
|
17
|
+
return insights_client_1.DataType.Double;
|
|
18
|
+
case "number":
|
|
19
|
+
return insights_client_1.DataType.Number;
|
|
20
|
+
default:
|
|
21
|
+
return insights_client_1.DataType.String;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const extractPrimitives = (propertyTraversal, propertyField) => propertyField.properties.map((property) => {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
const propertyName = property.property.name;
|
|
27
|
+
const displayLabel = propertyField.label;
|
|
28
|
+
// It belongs to this parent class
|
|
29
|
+
const parentPropertyClassName = (_a = propertyField.parent) === null || _a === void 0 ? void 0 : _a.contentClassInfo.name;
|
|
30
|
+
const primitiveNavigationClass = (_c = (_b = property.property.navigationPropertyInfo) === null || _b === void 0 ? void 0 : _b.classInfo.name) !== null && _c !== void 0 ? _c : "";
|
|
31
|
+
/* Presentation assigns primitive navigations properties as a long type due to how it stores the
|
|
32
|
+
ECInstanceId of the class in the meta.ECClassDef table on the C++ layer.
|
|
33
|
+
We are handling this special case.
|
|
34
|
+
*/
|
|
35
|
+
const propertyType = primitiveNavigationClass ? insights_client_1.DataType.String : convertType(property.property.type);
|
|
36
|
+
const actualECClassName = property.property.classInfo.name;
|
|
37
|
+
const newPropertyTraversal = [...propertyTraversal, propertyName];
|
|
38
|
+
return ({
|
|
39
|
+
displayLabel,
|
|
40
|
+
sourceSchema: "*",
|
|
41
|
+
sourceClassName: "*",
|
|
42
|
+
ecPropertyTraversal: newPropertyTraversal,
|
|
43
|
+
propertyType,
|
|
44
|
+
primitiveNavigationClass,
|
|
45
|
+
actualECClassName,
|
|
46
|
+
parentPropertyClassName,
|
|
47
|
+
key: `${actualECClassName}__${newPropertyTraversal.join("_")}`,
|
|
48
|
+
categoryLabel: propertyField.category.label,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
const extractPrimitiveStructProperties = (propertyTraversal, members, categoryLabel, actualECClassName, parentPropertyClassName) => members.flatMap((member) => {
|
|
52
|
+
if (member.type.valueFormat === presentation_common_1.PropertyValueFormat.Primitive) {
|
|
53
|
+
const propertyName = member.name;
|
|
54
|
+
const displayLabel = member.label;
|
|
55
|
+
const propertyType = convertType(member.type.typeName);
|
|
56
|
+
const newPropertyTraversal = [...propertyTraversal, propertyName];
|
|
57
|
+
return ({
|
|
58
|
+
displayLabel,
|
|
59
|
+
sourceSchema: "*",
|
|
60
|
+
sourceClassName: "*",
|
|
61
|
+
ecPropertyTraversal: newPropertyTraversal,
|
|
62
|
+
propertyType,
|
|
63
|
+
primitiveNavigationClass: "",
|
|
64
|
+
actualECClassName,
|
|
65
|
+
parentPropertyClassName,
|
|
66
|
+
key: `${actualECClassName}__${newPropertyTraversal.join("_")}`,
|
|
67
|
+
categoryLabel,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else if (member.type.valueFormat === presentation_common_1.PropertyValueFormat.Struct) {
|
|
71
|
+
return extractPrimitiveStructProperties(propertyTraversal, member.type.members, categoryLabel, actualECClassName, parentPropertyClassName);
|
|
72
|
+
}
|
|
73
|
+
return [];
|
|
74
|
+
});
|
|
75
|
+
const extractStruct = (property) => {
|
|
76
|
+
if (property.type.valueFormat !== presentation_common_1.PropertyValueFormat.Struct) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
const columnName = property.properties[0]
|
|
80
|
+
.property.name;
|
|
81
|
+
const actualECClassName = property.properties[0].property.classInfo.name;
|
|
82
|
+
return extractPrimitiveStructProperties([columnName], property.type.members, property.category.label, actualECClassName);
|
|
83
|
+
};
|
|
84
|
+
const extractNested = (propertyTraversal, propertyFields) => propertyFields.flatMap((property) => {
|
|
85
|
+
// Generate base ECProperty
|
|
86
|
+
switch (property.type.valueFormat) {
|
|
87
|
+
case presentation_common_1.PropertyValueFormat.Primitive: {
|
|
88
|
+
return extractPrimitives([...propertyTraversal], property);
|
|
89
|
+
}
|
|
90
|
+
// Get structs
|
|
91
|
+
case presentation_common_1.PropertyValueFormat.Struct: {
|
|
92
|
+
const nestedContentField = property;
|
|
93
|
+
// Only handling single path and not handling nested content fields within navigations
|
|
94
|
+
if (nestedContentField.pathToPrimaryClass &&
|
|
95
|
+
nestedContentField.pathToPrimaryClass.length > 1) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
switch (nestedContentField.relationshipMeaning) {
|
|
99
|
+
// Aspects are not looked at again. Extraction does not support aspects within navigations.
|
|
100
|
+
// Navigation properties
|
|
101
|
+
case presentation_common_1.RelationshipMeaning.RelatedInstance: {
|
|
102
|
+
if (
|
|
103
|
+
// Deal with a TypeDefinition
|
|
104
|
+
nestedContentField.pathToPrimaryClass[0].relationshipInfo.name ===
|
|
105
|
+
"BisCore:GeometricElement3dHasTypeDefinition") {
|
|
106
|
+
return extractNested([...propertyTraversal, "TypeDefinition"], nestedContentField.nestedFields);
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
default: {
|
|
111
|
+
// Some elements don't have a path to primary class or relationship meaning..
|
|
112
|
+
// Most likely a simple struct property
|
|
113
|
+
if (!nestedContentField.pathToPrimaryClass) {
|
|
114
|
+
return extractStruct(property);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return [];
|
|
121
|
+
});
|
|
122
|
+
const convertPresentationFields = (propertyFields) => propertyFields.flatMap((property) => {
|
|
123
|
+
// Generate base ECProperty
|
|
124
|
+
switch (property.type.valueFormat) {
|
|
125
|
+
case presentation_common_1.PropertyValueFormat.Primitive: {
|
|
126
|
+
const extractedPrimitives = extractPrimitives([], property);
|
|
127
|
+
for (const extractedPrimitive of extractedPrimitives) {
|
|
128
|
+
extractedPrimitive.sourceSchema = "*";
|
|
129
|
+
extractedPrimitive.sourceClassName = "*";
|
|
130
|
+
return extractedPrimitive;
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
// Get structs
|
|
135
|
+
case presentation_common_1.PropertyValueFormat.Struct: {
|
|
136
|
+
const nestedContentField = property;
|
|
137
|
+
// Only handling single path and not handling nested content fields within navigations
|
|
138
|
+
if (nestedContentField.pathToPrimaryClass &&
|
|
139
|
+
nestedContentField.pathToPrimaryClass.length > 1) {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
switch (nestedContentField.relationshipMeaning) {
|
|
143
|
+
case presentation_common_1.RelationshipMeaning.SameInstance: {
|
|
144
|
+
// Check for aspects.
|
|
145
|
+
if ((nestedContentField.pathToPrimaryClass[0].relationshipInfo
|
|
146
|
+
.name === "BisCore:ElementOwnsUniqueAspect" ||
|
|
147
|
+
nestedContentField.pathToPrimaryClass[0].relationshipInfo
|
|
148
|
+
.name === "BisCore:ElementOwnsMultiAspects")) {
|
|
149
|
+
const fullClassName = nestedContentField.contentClassInfo.name;
|
|
150
|
+
const schema = fullClassName.split(":")[0];
|
|
151
|
+
const className = fullClassName.split(":")[1];
|
|
152
|
+
const extractedNested = extractNested([], nestedContentField.nestedFields);
|
|
153
|
+
const aspectExtractedNested = extractedNested.map((ecProperty) => ({ ...ecProperty, schema, className }));
|
|
154
|
+
return aspectExtractedNested;
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
// Navigation properties
|
|
159
|
+
case presentation_common_1.RelationshipMeaning.RelatedInstance: {
|
|
160
|
+
if (
|
|
161
|
+
// Deal with a TypeDefinition
|
|
162
|
+
nestedContentField.pathToPrimaryClass[0].relationshipInfo.name ===
|
|
163
|
+
"BisCore:GeometricElement3dHasTypeDefinition") {
|
|
164
|
+
return extractNested(["TypeDefinition"], nestedContentField.nestedFields);
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
default: {
|
|
169
|
+
// Some elements don't have a path to primary class or relationship meaning..
|
|
170
|
+
// Most likely a simple struct property
|
|
171
|
+
if (!nestedContentField.pathToPrimaryClass) {
|
|
172
|
+
return extractStruct(property);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return [];
|
|
179
|
+
});
|
|
180
|
+
exports.convertPresentationFields = convertPresentationFields;
|
|
181
|
+
const convertToECProperties = (property) => {
|
|
182
|
+
const ecProperty = {
|
|
183
|
+
ecSchemaName: property.sourceSchema,
|
|
184
|
+
ecClassName: property.sourceClassName,
|
|
185
|
+
ecPropertyType: property.propertyType,
|
|
186
|
+
ecPropertyName: "",
|
|
187
|
+
};
|
|
188
|
+
switch (property.primitiveNavigationClass) {
|
|
189
|
+
// Hardcode Models navigation path and label behavior
|
|
190
|
+
case "BisCore:ModelContainsElements": {
|
|
191
|
+
return [
|
|
192
|
+
{
|
|
193
|
+
...ecProperty,
|
|
194
|
+
ecPropertyName: [
|
|
195
|
+
...property.ecPropertyTraversal,
|
|
196
|
+
"ModeledElement",
|
|
197
|
+
"UserLabel",
|
|
198
|
+
].join("."),
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
...ecProperty,
|
|
202
|
+
ecPropertyName: [
|
|
203
|
+
...property.ecPropertyTraversal,
|
|
204
|
+
"ModeledElement",
|
|
205
|
+
"CodeValue",
|
|
206
|
+
].join("."),
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
// Hardcode Category and Physical Material navigation path and label behavior
|
|
211
|
+
case "BisCore:GeometricElement3dIsInCategory":
|
|
212
|
+
case "BisCore:PhysicalElementIsOfPhysicalMaterial":
|
|
213
|
+
return [
|
|
214
|
+
{
|
|
215
|
+
...ecProperty,
|
|
216
|
+
ecPropertyName: [
|
|
217
|
+
...property.ecPropertyTraversal,
|
|
218
|
+
"UserLabel",
|
|
219
|
+
].join("."),
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
...ecProperty,
|
|
223
|
+
ecPropertyName: [
|
|
224
|
+
...property.ecPropertyTraversal,
|
|
225
|
+
"CodeValue",
|
|
226
|
+
].join("."),
|
|
227
|
+
},
|
|
228
|
+
];
|
|
229
|
+
default: {
|
|
230
|
+
return [
|
|
231
|
+
{
|
|
232
|
+
...ecProperty,
|
|
233
|
+
ecPropertyName: property.ecPropertyTraversal.join("."),
|
|
234
|
+
},
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
exports.convertToECProperties = convertToECProperties;
|
|
240
|
+
const findProperties = (ecProperties, propertiesMetaData) => {
|
|
241
|
+
let ecPropertiesCopy = [...ecProperties];
|
|
242
|
+
const propertiesMetaDataResult = new Array();
|
|
243
|
+
let notFound = false;
|
|
244
|
+
while (ecPropertiesCopy.length !== 0) {
|
|
245
|
+
for (let i = 0; i < propertiesMetaData.length; i++) {
|
|
246
|
+
const generatedProperty = exports.convertToECProperties(propertiesMetaData[i]);
|
|
247
|
+
const slicedEcProperties = ecPropertiesCopy.slice(0, generatedProperty.length);
|
|
248
|
+
if (fast_equals_1.deepEqual(generatedProperty, slicedEcProperties)) {
|
|
249
|
+
propertiesMetaDataResult.push(propertiesMetaData[i]);
|
|
250
|
+
ecPropertiesCopy = ecPropertiesCopy.slice(generatedProperty.length);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
if (i === propertiesMetaData.length - 1) {
|
|
254
|
+
notFound = true;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (notFound)
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return notFound ? [] : propertiesMetaDataResult;
|
|
261
|
+
};
|
|
262
|
+
exports.findProperties = findProperties;
|
|
263
|
+
const fetchPresentationDescriptor = async (iModelConnection, keySet) => {
|
|
264
|
+
const ruleSet = {
|
|
265
|
+
id: "gmw-element-properties",
|
|
266
|
+
rules: [
|
|
267
|
+
{
|
|
268
|
+
ruleType: presentation_common_1.RuleTypes.Content,
|
|
269
|
+
specifications: [
|
|
270
|
+
{
|
|
271
|
+
specType: presentation_common_1.ContentSpecificationTypes.SelectedNodeInstances,
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
};
|
|
277
|
+
const requestOptions = {
|
|
278
|
+
imodel: iModelConnection,
|
|
279
|
+
keys: keySet,
|
|
280
|
+
rulesetOrId: ruleSet,
|
|
281
|
+
displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
|
|
282
|
+
};
|
|
283
|
+
const descriptor = await presentation_frontend_1.Presentation.presentation.getContentDescriptor(requestOptions);
|
|
284
|
+
return descriptor;
|
|
285
|
+
};
|
|
286
|
+
exports.fetchPresentationDescriptor = fetchPresentationDescriptor;
|
|
287
|
+
//# sourceMappingURL=GroupPropertyUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupPropertyUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/GroupPropertyUtils.ts"],"names":[],"mappings":";;;AAMA,4DAAkD;AAWlD,oEAMoC;AACpC,wEAA4D;AAC5D,6CAAwC;AAexC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAY,EAAE;IAC7C,QAAQ,IAAI,EAAE;QACZ,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,0BAAQ,CAAC,OAAO,CAAC;QAC1B,KAAK,SAAS;YACZ,OAAO,0BAAQ,CAAC,OAAO,CAAC;QAC1B,KAAK,QAAQ;YACX,OAAO,0BAAQ,CAAC,MAAM,CAAC;QACzB,KAAK,QAAQ;YACX,OAAO,0BAAQ,CAAC,MAAM,CAAC;QACzB;YACE,OAAO,0BAAQ,CAAC,MAAM,CAAC;KAC1B;AACH,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CACxB,iBAA2B,EAC3B,aAA8B,EACV,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;;IACjE,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5C,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC;IACzC,kCAAkC;IAClC,MAAM,uBAAuB,GAAG,MAAA,aAAa,CAAC,MAAM,0CAAE,gBAAgB,CAAC,IAAI,CAAC;IAC5E,MAAM,wBAAwB,GAAG,MAAA,MAAA,QAAQ,CAAC,QAAQ,CAAC,sBAAsB,0CAAE,SAAS,CAAC,IAAI,mCAAI,EAAE,CAAC;IAChG;;;MAGE;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,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACvC,QAAQ,GAAG,IAAI,CAAC;aACjB;SACF;QACD,IAAI,QAAQ;YACV,MAAM;KACT;IACD,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAAC;AAClD,CAAC,CAAC;AArBW,QAAA,cAAc,kBAqBzB;AAEK,MAAM,2BAA2B,GAAG,KAAK,EAAE,gBAAkC,EAAE,MAAc,EAAE,EAAE;IACtG,MAAM,OAAO,GAAY;QACvB,EAAE,EAAE,wBAAwB;QAC5B,KAAK,EAAE;YACL;gBACE,QAAQ,EAAE,+BAAS,CAAC,OAAO;gBAC3B,cAAc,EAAE;oBACd;wBACE,QAAQ,EAAE,+CAAyB,CAAC,qBAAqB;qBAC1D;iBACF;aACF;SAAC;KACL,CAAC;IACF,MAAM,cAAc,GAA+E;QACjG,MAAM,EAAE,gBAAgB;QACxB,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,OAAO;QACpB,WAAW,EAAE,gDAA0B,CAAC,YAAY;KACrD,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,oCAAY,CAAC,YAAY,CAAC,oBAAoB,CACrE,cAAc,CACf,CAAC;IACF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAvBW,QAAA,2BAA2B,+BAuBtC","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 { IModelConnection } from \"@itwin/core-frontend\";\nimport type { ECProperty } from \"@itwin/insights-client\";\nimport { DataType } from \"@itwin/insights-client\";\nimport type {\n ContentDescriptorRequestOptions,\n Field,\n KeySet,\n NestedContentField,\n PropertiesField,\n Ruleset,\n RulesetVariable,\n StructFieldMemberDescription,\n} from \"@itwin/presentation-common\";\nimport {\n ContentSpecificationTypes,\n DefaultContentDisplayTypes,\n PropertyValueFormat,\n RelationshipMeaning,\n RuleTypes,\n} from \"@itwin/presentation-common\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { deepEqual } from \"fast-equals\";\n\nexport interface PropertyMetaData {\n displayLabel: string;\n sourceSchema: string;\n sourceClassName: string;\n categoryLabel: string;\n propertyType: DataType;\n actualECClassName: string;\n parentPropertyClassName: string | undefined;\n ecPropertyTraversal: string[];\n primitiveNavigationClass: string;\n key: string;\n}\n\nconst convertType = (type: string): DataType => {\n switch (type) {\n case \"int\":\n case \"enum\":\n case \"long\":\n return DataType.Integer;\n case \"boolean\":\n return DataType.Boolean;\n case \"double\":\n return DataType.Double;\n case \"number\":\n return DataType.Number;\n default:\n return DataType.String;\n }\n};\n\nconst extractPrimitives = (\n propertyTraversal: string[],\n propertyField: PropertiesField\n): PropertyMetaData[] => propertyField.properties.map((property) => {\n const propertyName = property.property.name;\n const displayLabel = propertyField.label;\n // It belongs to this parent class\n const parentPropertyClassName = propertyField.parent?.contentClassInfo.name;\n const primitiveNavigationClass = property.property.navigationPropertyInfo?.classInfo.name ?? \"\";\n /* Presentation assigns primitive navigations properties as a long type due to how it stores the\n ECInstanceId of the class in the meta.ECClassDef table on the C++ layer.\n We are handling this special case.\n */\n const propertyType = primitiveNavigationClass ? DataType.String : convertType(property.property.type);\n const actualECClassName = property.property.classInfo.name;\n const newPropertyTraversal = [...propertyTraversal, propertyName];\n\n return (\n {\n displayLabel,\n sourceSchema: \"*\",\n sourceClassName: \"*\",\n ecPropertyTraversal: newPropertyTraversal,\n propertyType,\n primitiveNavigationClass,\n actualECClassName,\n parentPropertyClassName,\n key: `${actualECClassName}__${newPropertyTraversal.join(\"_\")}`,\n categoryLabel: propertyField.category.label,\n }\n );\n});\n\nconst extractPrimitiveStructProperties = (\n propertyTraversal: string[],\n members: StructFieldMemberDescription[],\n categoryLabel: string,\n actualECClassName: string,\n parentPropertyClassName?: string,\n): PropertyMetaData[] => members.flatMap((member) => {\n if (member.type.valueFormat === PropertyValueFormat.Primitive) {\n const propertyName = member.name;\n const displayLabel = member.label;\n const propertyType = convertType(member.type.typeName);\n const newPropertyTraversal = [...propertyTraversal, propertyName];\n\n return ({\n displayLabel,\n sourceSchema: \"*\",\n sourceClassName: \"*\",\n ecPropertyTraversal: newPropertyTraversal,\n propertyType,\n primitiveNavigationClass: \"\",\n actualECClassName,\n parentPropertyClassName,\n key: `${actualECClassName}__${newPropertyTraversal.join(\"_\")}`,\n categoryLabel,\n });\n\n } else if (member.type.valueFormat === PropertyValueFormat.Struct) {\n return extractPrimitiveStructProperties(\n propertyTraversal,\n member.type.members,\n categoryLabel,\n actualECClassName,\n parentPropertyClassName\n );\n }\n\n return [];\n});\n\nconst extractStruct = (property: Field) => {\n if (property.type.valueFormat !== PropertyValueFormat.Struct) {\n return [];\n }\n\n const columnName = (property as PropertiesField).properties[0]\n .property.name;\n const actualECClassName = (property as PropertiesField).properties[0].property.classInfo.name;\n return extractPrimitiveStructProperties(\n [columnName],\n property.type.members,\n property.category.label,\n actualECClassName\n );\n};\n\nconst extractNested = (propertyTraversal: string[], propertyFields: Field[]): PropertyMetaData[] =>\n propertyFields.flatMap((property) => {\n // Generate base ECProperty\n switch (property.type.valueFormat) {\n case PropertyValueFormat.Primitive: {\n return extractPrimitives([...propertyTraversal], property as PropertiesField);\n }\n // Get structs\n case PropertyValueFormat.Struct: {\n const nestedContentField = property as NestedContentField;\n // Only handling single path and not handling nested content fields within navigations\n if (\n nestedContentField.pathToPrimaryClass &&\n nestedContentField.pathToPrimaryClass.length > 1\n ) {\n break;\n }\n\n switch (nestedContentField.relationshipMeaning) {\n // Aspects are not looked at again. Extraction does not support aspects within navigations.\n // Navigation properties\n case RelationshipMeaning.RelatedInstance: {\n if (\n // Deal with a TypeDefinition\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name ===\n \"BisCore:GeometricElement3dHasTypeDefinition\"\n ) {\n return extractNested([...propertyTraversal, \"TypeDefinition\"], nestedContentField.nestedFields);\n }\n break;\n }\n default: {\n // Some elements don't have a path to primary class or relationship meaning..\n // Most likely a simple struct property\n if (!nestedContentField.pathToPrimaryClass) {\n return extractStruct(property);\n }\n }\n }\n }\n }\n return [];\n });\n\nexport const convertPresentationFields = (propertyFields: Field[]): PropertyMetaData[] =>\n propertyFields.flatMap((property) => {\n // Generate base ECProperty\n switch (property.type.valueFormat) {\n case PropertyValueFormat.Primitive: {\n const extractedPrimitives = extractPrimitives([], property as PropertiesField);\n for (const extractedPrimitive of extractedPrimitives) {\n extractedPrimitive.sourceSchema = \"*\";\n extractedPrimitive.sourceClassName = \"*\";\n return extractedPrimitive;\n }\n break;\n }\n // Get structs\n case PropertyValueFormat.Struct: {\n const nestedContentField = property as NestedContentField;\n // Only handling single path and not handling nested content fields within navigations\n if (\n nestedContentField.pathToPrimaryClass &&\n nestedContentField.pathToPrimaryClass.length > 1\n ) {\n break;\n }\n switch (nestedContentField.relationshipMeaning) {\n case RelationshipMeaning.SameInstance: {\n // Check for aspects.\n if (\n (nestedContentField.pathToPrimaryClass[0].relationshipInfo\n .name === \"BisCore:ElementOwnsUniqueAspect\" ||\n nestedContentField.pathToPrimaryClass[0].relationshipInfo\n .name === \"BisCore:ElementOwnsMultiAspects\")\n ) {\n const fullClassName = nestedContentField.contentClassInfo.name;\n const schema = fullClassName.split(\":\")[0];\n const className = fullClassName.split(\":\")[1];\n const extractedNested = extractNested([], nestedContentField.nestedFields);\n const aspectExtractedNested = extractedNested.map((ecProperty) => ({ ...ecProperty, schema, className }));\n return aspectExtractedNested;\n }\n break;\n }\n // Navigation properties\n case RelationshipMeaning.RelatedInstance: {\n if (\n // Deal with a TypeDefinition\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name ===\n \"BisCore:GeometricElement3dHasTypeDefinition\"\n ) {\n return extractNested([\"TypeDefinition\"], nestedContentField.nestedFields);\n }\n break;\n }\n default: {\n // Some elements don't have a path to primary class or relationship meaning..\n // Most likely a simple struct property\n if (!nestedContentField.pathToPrimaryClass) {\n return extractStruct(property);\n }\n }\n }\n }\n }\n return [];\n });\n\nexport const convertToECProperties = (property: PropertyMetaData): ECProperty[] => {\n const ecProperty: ECProperty = {\n ecSchemaName: property.sourceSchema,\n ecClassName: property.sourceClassName,\n ecPropertyType: property.propertyType,\n ecPropertyName: \"\",\n };\n switch (property.primitiveNavigationClass) {\n // Hardcode Models navigation path and label behavior\n case \"BisCore:ModelContainsElements\": {\n return [\n {\n ...ecProperty,\n ecPropertyName: [\n ...property.ecPropertyTraversal,\n \"ModeledElement\",\n \"UserLabel\",\n ].join(\".\"),\n },\n {\n ...ecProperty,\n ecPropertyName: [\n ...property.ecPropertyTraversal,\n \"ModeledElement\",\n \"CodeValue\",\n ].join(\".\"),\n },\n ];\n }\n // Hardcode Category and Physical Material navigation path and label behavior\n case \"BisCore:GeometricElement3dIsInCategory\":\n case \"BisCore:PhysicalElementIsOfPhysicalMaterial\":\n return [\n {\n ...ecProperty,\n ecPropertyName: [\n ...property.ecPropertyTraversal,\n \"UserLabel\",\n ].join(\".\"),\n },\n {\n ...ecProperty,\n ecPropertyName: [\n ...property.ecPropertyTraversal,\n \"CodeValue\",\n ].join(\".\"),\n },\n ];\n default: {\n return [\n {\n ...ecProperty,\n ecPropertyName: property.ecPropertyTraversal.join(\".\"),\n },\n ];\n }\n }\n};\n\nexport const findProperties = (ecProperties: ECProperty[], propertiesMetaData: PropertyMetaData[]) => {\n let ecPropertiesCopy = [...ecProperties];\n const propertiesMetaDataResult: PropertyMetaData[] = new Array<PropertyMetaData>();\n let notFound = false;\n while (ecPropertiesCopy.length !== 0) {\n for (let i = 0; i < propertiesMetaData.length; i++) {\n const generatedProperty = convertToECProperties(propertiesMetaData[i]);\n const slicedEcProperties = ecPropertiesCopy.slice(0, generatedProperty.length);\n if (deepEqual(generatedProperty, slicedEcProperties)) {\n propertiesMetaDataResult.push(propertiesMetaData[i]);\n ecPropertiesCopy = ecPropertiesCopy.slice(generatedProperty.length);\n break;\n }\n if (i === propertiesMetaData.length - 1) {\n notFound = true;\n }\n }\n if (notFound)\n break;\n }\n return notFound ? [] : propertiesMetaDataResult;\n};\n\nexport const fetchPresentationDescriptor = async (iModelConnection: IModelConnection, keySet: KeySet) => {\n const ruleSet: Ruleset = {\n id: \"gmw-element-properties\",\n rules: [\n {\n ruleType: RuleTypes.Content,\n specifications: [\n {\n specType: ContentSpecificationTypes.SelectedNodeInstances,\n },\n ],\n }],\n };\n const requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> = {\n imodel: iModelConnection,\n keys: keySet,\n rulesetOrId: ruleSet,\n displayType: DefaultContentDisplayTypes.PropertyPane,\n };\n const descriptor = await Presentation.presentation.getContentDescriptor(\n requestOptions\n );\n return descriptor;\n};\n"]}
|