iTwin / viewer-components-react

Components built on iTwin.js for usability in an iTwin.js based Viewer.
MIT License
24 stars 33 forks source link

Tree Widget: External sources tree #352

Closed grigasp closed 1 year ago

grigasp commented 1 year ago

Add a new "External Sources" tree component to the @itwin/tree-widget-react package.

Proposed ruleset

Click me ```json { "id": "ExternalSources", "requiredSchemas": [ { "name": "BisCore", "minVersion": "1.0.13" } ], "rules": [ { "ruleType": "RootNodes", "specifications": [ { "specType": "InstanceNodesOfSpecificClasses", "classes": [ { "schemaName": "BisCore", "classNames": [ "ExternalSource" ] } ], "arePolymorphic": false, "relatedInstances": [ { "relationshipPath": [ { "relationship": { "schemaName": "BisCore", "className": "SynchronizationConfigSpecifiesRootSources" }, "direction": "Backward" } ], "isRequired": true, "alias": "configRoot" }, { "relationshipPath": [ { "relationship": { "schemaName": "BisCore", "className": "ExternalSourceIsInRepository" }, "direction": "Forward" } ], "isRequired": true, "alias": "repo" } ], "instanceFilter": "configRoot.ECInstanceId <> NULL", "groupByClass": false, "groupByLabel": false } ] }, { "ruleType": "ChildNodes", "condition": "ParentNode.IsOfClass(\"ExternalSourceGroup\", \"BisCore\")", "specifications": [ { "specType": "RelatedInstanceNodes", "hideIfNoChildren": false, "relationshipPaths": [ [ { "relationship": { "schemaName": "BisCore", "className": "ExternalSourceGroupGroupsSources" }, "direction": "Forward" } ] ], "groupByClass": false, "groupByLabel": false } ] }, { "ruleType": "ChildNodes", "condition": "ParentNode.IsOfClass(\"ExternalSource\", \"BisCore\")", "specifications": [ { "specType": "RelatedInstanceNodes", "hideIfNoChildren": false, "relationshipPaths": [ [ { "relationship": { "schemaName": "BisCore", "className": "ExternalSourceOwnsAttachments" }, "direction": "Forward" }, { "relationship": { "schemaName": "BisCore", "className": "ExternalSourceAttachmentAttachesSource" }, "direction": "Forward" } ] ], "groupByClass": false, "groupByLabel": false }, { "specType": "CustomNode", "type": "T_ExternalSource_Elements", "label": "Elements", "imageId": "icon-sitemap", "hideIfNoChildren": true, "nestedRules": [ { "ruleType": "ChildNodes", "specifications": [ { "specType": "RelatedInstanceNodes", "relationshipPaths": [ [ { "relationship": { "schemaName": "BisCore", "className": "ElementIsFromSource" }, "direction": "Backward", "targetClass": { "schemaName": "BisCore", "className": "ExternalSourceAspect" } }, { "relationship": { "schemaName": "BisCore", "className": "ElementOwnsMultiAspects" }, "direction": "Backward", "targetClass": { "schemaName": "BisCore", "className": "GeometricElement" } } ] ], "groupByClass": true, "groupByLabel": false } ] } ] } ] }, { "ruleType": "InstanceLabelOverride", "class": { "schemaName": "BisCore", "className": "RepositoryLink" }, "values": [ { "specType": "Property", "propertyName": "UserLabel" } ] }, { "ruleType": "InstanceLabelOverride", "class": { "schemaName": "BisCore", "className": "ExternalSource" }, "values": [ { "specType": "Composite", "separator": " - ", "parts": [ { "spec": { "specType": "RelatedInstanceLabel", "pathToRelatedInstance": { "relationship": { "schemaName": "BisCore", "className": "ExternalSourceIsInRepository" }, "direction": "Forward" } } }, { "spec": { "specType": "Property", "propertyName": "UserLabel" } } ] } ] }, { "ruleType": "ImageIdOverride", "condition": "this.IsOfClass(\"ExternalSource\", \"BisCore\")", "imageIdExpression": "IIF(this.ConnectorName = \"IFCBridge\", \"icon-file-types-word\", IIF(this.ConnectorName = \"iModelBridgeForMstn\", \"icon-file-types-microstation\", \"icon-file-types-unknown\"))" }, { "ruleType": "ImageIdOverride", "condition": "ThisNode.IsClassGroupingNode", "imageIdExpression": "\"icon-ec-class\"" } ] } ```

Live preview

Example 1

Image

link to preview

Example 2

image

link to preview

TBD

grigasp commented 1 year ago

Another iModel that can be used for testing the hierarchy: https://connect-imodelweb.bentley.com/imodeljs/?projectId=6de2930c-c4b9-4f9c-a12f-462d6e6a5e06&iModelId=f3902fde-1417-4271-894e-9eb3a1233170&ChangeSetId=579df8cd24b9e0da96efc93c2587d860756d4c04