@itwin/grouping-mapping-widget 0.2.2 → 0.2.3
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/ActionPanel.js +5 -3
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.js +4 -2
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.scss +6 -0
- package/lib/cjs/widget/components/GroupAction.js +85 -12
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.scss +23 -0
- package/lib/cjs/widget/components/GroupPropertyAction.js +51 -20
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupQueryBuilderContext.d.ts +2 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContext.js +2 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContext.js.map +1 -1
- package/lib/cjs/widget/components/QueryBuilder.d.ts +1 -1
- package/lib/cjs/widget/components/QueryBuilder.js +10 -4
- package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js +7 -3
- package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGrid.scss +3 -3
- package/lib/cjs/widget/components/property-grid/PropertyRender.d.ts +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyRender.js +5 -8
- package/lib/cjs/widget/components/property-grid/PropertyRender.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.d.ts +2 -0
- package/lib/cjs/widget/components/property-grid/PropertyView.js +14 -11
- package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.scss +19 -4
- package/lib/cjs/widget/components/utils.d.ts +1 -0
- package/lib/cjs/widget/components/utils.js +6 -1
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/components/utils.scss +5 -0
- package/lib/esm/widget/components/ActionPanel.js +6 -4
- package/lib/esm/widget/components/ActionPanel.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.js +6 -4
- package/lib/esm/widget/components/DeleteModal.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.scss +6 -0
- package/lib/esm/widget/components/GroupAction.js +87 -14
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.scss +23 -0
- package/lib/esm/widget/components/GroupPropertyAction.js +51 -20
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupQueryBuilderContext.d.ts +2 -0
- package/lib/esm/widget/components/GroupQueryBuilderContext.js +2 -0
- package/lib/esm/widget/components/GroupQueryBuilderContext.js.map +1 -1
- package/lib/esm/widget/components/QueryBuilder.d.ts +1 -1
- package/lib/esm/widget/components/QueryBuilder.js +10 -4
- package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js +7 -3
- package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGrid.scss +3 -3
- package/lib/esm/widget/components/property-grid/PropertyRender.d.ts +1 -1
- package/lib/esm/widget/components/property-grid/PropertyRender.js +5 -8
- package/lib/esm/widget/components/property-grid/PropertyRender.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.d.ts +2 -0
- package/lib/esm/widget/components/property-grid/PropertyView.js +14 -11
- package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.scss +19 -4
- package/lib/esm/widget/components/utils.d.ts +1 -0
- package/lib/esm/widget/components/utils.js +5 -1
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/components/utils.scss +5 -0
- package/package.json +3 -3
|
@@ -33,12 +33,15 @@ const GroupQueryBuilderContext_1 = require("../GroupQueryBuilderContext");
|
|
|
33
33
|
const react_1 = require("react");
|
|
34
34
|
const PropertyGridColumns_1 = require("@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns");
|
|
35
35
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
36
|
+
const CommonPropertyRenderer_1 = require("@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer");
|
|
36
37
|
/**
|
|
37
38
|
* A React component that renders property as label/value pair
|
|
38
39
|
* @public
|
|
39
40
|
*/
|
|
40
41
|
const PropertyView = (props) => {
|
|
42
|
+
var _a;
|
|
41
43
|
const context = React.useContext(GroupQueryBuilderContext_1.GroupQueryBuilderContext);
|
|
44
|
+
const [isCheckboxLoading, setIsCheckboxLoading] = React.useState(false);
|
|
42
45
|
const _validatePropertySelection = () => {
|
|
43
46
|
if (context.currentPropertyList.includes(props.propertyRecord)) {
|
|
44
47
|
return true;
|
|
@@ -80,8 +83,12 @@ const PropertyView = (props) => {
|
|
|
80
83
|
// TODO: roof selected item/category value is an object but format is primitive(needs further exploration)
|
|
81
84
|
if (!context.currentPropertyList.includes(prop) &&
|
|
82
85
|
prop.value.valueFormat === appui_abstract_1.PropertyValueFormat.Primitive) {
|
|
86
|
+
if (!(await context.queryBuilder.addProperty(prop))) {
|
|
87
|
+
setIsCheckboxLoading(false);
|
|
88
|
+
setIsPropertySelected(false);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
83
91
|
context.setCurrentPropertyList(context.currentPropertyList.concat(prop));
|
|
84
|
-
await context.queryBuilder.addProperty(prop);
|
|
85
92
|
context.setQuery(context.queryBuilder.buildQueryString());
|
|
86
93
|
}
|
|
87
94
|
}, [context]);
|
|
@@ -131,6 +138,7 @@ const PropertyView = (props) => {
|
|
|
131
138
|
React.useEffect(() => {
|
|
132
139
|
if (props === null || props === void 0 ? void 0 : props.propertyRecord) {
|
|
133
140
|
if (isPropertySelected) {
|
|
141
|
+
setIsCheckboxLoading(true);
|
|
134
142
|
_addNestedProperties(props.propertyRecord);
|
|
135
143
|
}
|
|
136
144
|
else {
|
|
@@ -144,15 +152,9 @@ const PropertyView = (props) => {
|
|
|
144
152
|
props.propertyRecord,
|
|
145
153
|
]);
|
|
146
154
|
React.useEffect(() => {
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
setIsPropertySelected(false);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}, [context.currentPropertyList, props.propertyRecord]);
|
|
155
|
+
if (!context.isRendering)
|
|
156
|
+
setIsCheckboxLoading(false);
|
|
157
|
+
}, [context.isRendering]);
|
|
156
158
|
const _onPropertySelectionChanged = () => {
|
|
157
159
|
setIsPropertySelected(!isPropertySelected);
|
|
158
160
|
};
|
|
@@ -201,10 +203,11 @@ const PropertyView = (props) => {
|
|
|
201
203
|
!!props.onColumnRatioChanged;
|
|
202
204
|
const needActionButtons = !!props.actionButtonRenderers;
|
|
203
205
|
const columnsStyleProvider = new PropertyGridColumns_1.PropertyGridColumnStyleProvider(props.columnInfo);
|
|
206
|
+
const offset = CommonPropertyRenderer_1.CommonPropertyRenderer.getLabelOffset(props.indentation, props.orientation, props.width, props.columnRatio, (_a = props.columnInfo) === null || _a === void 0 ? void 0 : _a.minLabelWidth);
|
|
204
207
|
return (React.createElement("div", { style: columnsStyleProvider.getStyle(props.orientation, needActionButtons, ratio, needElementSeparator), className: getClassName(props), onClick: _onClick, onContextMenu: _onContextMenu, onMouseEnter: _onMouseEnter, onMouseLeave: _onMouseLeave, role: 'presentation' },
|
|
205
208
|
React.createElement("div", { className: 'components-property-record-label' },
|
|
206
209
|
props.propertyRecord.value.valueFormat ===
|
|
207
|
-
appui_abstract_1.PropertyValueFormat.Primitive && (React.createElement(itwinui_react_1.Checkbox, { className: 'components-property-selection-checkbox', checked: isPropertySelected, onChange: _onPropertySelectionChanged })),
|
|
210
|
+
appui_abstract_1.PropertyValueFormat.Primitive && (React.createElement(itwinui_react_1.Checkbox, { style: { marginLeft: offset }, className: 'components-property-selection-checkbox', checked: isPropertySelected, onChange: _onPropertySelectionChanged, disabled: context.isLoading || context.isRendering || (props.propertyRecord.value.value === undefined), isLoading: isCheckboxLoading })),
|
|
208
211
|
props.labelElement),
|
|
209
212
|
needElementSeparator ? (React.createElement(core_react_1.ElementSeparator, { movableArea: props.width, onRatioChanged: props.onColumnRatioChanged, ratio: ratio, orientation: props.orientation, isResizeHandleHovered: props.isResizeHandleHovered, onResizeHandleHoverChanged: props.onResizeHandleHoverChanged, isResizeHandleBeingDragged: props.isResizeHandleBeingDragged, onResizeHandleDragChanged: props.onResizeHandleDragChanged })) : undefined,
|
|
210
213
|
props.propertyRecord.value.valueFormat ===
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyView.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,6CAA+B;AAE/B,0DAA4D;AAC5D,kDAAkE;AAClE,8DAA2D;AAE3D,+BAA6B;AAE7B,0EAAuE;AACvE,iCAAoC;AACpC,mIAA4I;AAC5I,wDAAgD;AAchD;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,mDAAwB,CAAC,CAAC;IAE3D,MAAM,0BAA0B,GAAG,GAAG,EAAE;QACtC,IAAI,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;QACD,0CAA0C;QAC1C,IAAI,CAAC,kCAAkC,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YAC7D,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,kCA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EAC9B,iBAAiB,EAAE,SAAS,EAC5B,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,GAClD,CACH,CAAC,CAAC,CAAC,SAAS,CACT,CACP,CAAC;AACJ,CAAC,CAAC;AAxRW,QAAA,YAAY,gBAwRvB","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 * as React from \"react\";\nimport type { PropertyRecord} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ElementSeparator, Orientation } from \"@itwin/core-react\";\nimport { ActionButtonList } from \"@itwin/components-react\";\n\nimport \"./PropertyView.scss\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { GroupQueryBuilderContext } from \"../GroupQueryBuilderContext\";\nimport { useCallback } from \"react\";\nimport { PropertyGridColumnStyleProvider } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\n\n/** Properties of [[PropertyView]] React component\n * @public\n */\nexport interface PropertyViewProps extends SharedRendererProps {\n /** Property label as a React element */\n labelElement: React.ReactNode;\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n}\n\n/**\n * A React component that renders property as label/value pair\n * @public\n */\nexport const PropertyView = (props: PropertyViewProps) => {\n const context = React.useContext(GroupQueryBuilderContext);\n\n const _validatePropertySelection = () => {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n return true;\n }\n // Check if all subproperties are selected\n if (!_validateNestedPropertiesSelection(props.propertyRecord)) {\n return false;\n }\n return true;\n };\n\n const _validateNestedPropertiesSelection = (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n if (\n !_validateNestedPropertiesSelection(\n prop.value.members[subPropName]\n )\n ) {\n return false;\n }\n }\n }\n }\n return true;\n };\n\n const [isHovered, setIsHovered] = React.useState<boolean>(false);\n const [isPropertySelected, setIsPropertySelected] = React.useState<boolean>(\n _validatePropertySelection()\n );\n\n const _addSelectedProperty = useCallback(\n async (prop: PropertyRecord) => {\n // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)\n if (\n !context.currentPropertyList.includes(prop) &&\n prop.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n context.setCurrentPropertyList(\n context.currentPropertyList.concat(prop)\n );\n await context.queryBuilder.addProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _addNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _addSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _addSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _addNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_addSelectedProperty]\n );\n\n const _removeSelectedProperty = useCallback(\n async (prop: PropertyRecord): Promise<void> => {\n if (context.currentPropertyList.includes(prop)) {\n context.setCurrentPropertyList(\n context.currentPropertyList.filter((x: PropertyRecord) => x !== prop)\n );\n await context.queryBuilder.removeProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _removeNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _removeSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _removeSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _removeNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_removeSelectedProperty]\n );\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (isPropertySelected) {\n _addNestedProperties(props.propertyRecord);\n } else {\n _removeNestedProperties(props.propertyRecord);\n }\n }\n }, [\n _addNestedProperties,\n _removeNestedProperties,\n isPropertySelected,\n props.propertyRecord,\n ]);\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n setIsPropertySelected(true);\n } else {\n setIsPropertySelected(false);\n }\n }\n }, [context.currentPropertyList, props.propertyRecord]);\n\n const _onPropertySelectionChanged = () => {\n setIsPropertySelected(!isPropertySelected);\n };\n\n const _onClick = () => {\n if (props.onClick) {\n props.onClick(props.propertyRecord, props.uniqueKey);\n }\n };\n\n const _onMouseEnter = () => {\n if (props.isHoverable) {\n setIsHovered(true);\n }\n };\n\n const _onMouseLeave = () => {\n if (props.isHoverable) {\n setIsHovered(false);\n }\n };\n\n const _onContextMenu = (e: React.MouseEvent) => {\n if (props.onContextMenu) {\n props.onContextMenu(props.propertyRecord, e);\n }\n if (props.onRightClick) {\n props.onRightClick(props.propertyRecord, props.uniqueKey);\n }\n e.preventDefault();\n return false;\n };\n\n const getClassName = (viewProps: PropertyViewProps) => {\n let propertyRecordClassName =\n viewProps.orientation === Orientation.Horizontal\n ? \"components-property-record--horizontal\"\n : \"components-property-record--vertical\";\n if (viewProps.isSelected) {\n propertyRecordClassName += \" components--selected\";\n }\n if (viewProps.onClick) {\n propertyRecordClassName += \" components--clickable\";\n }\n if (viewProps.isHoverable) {\n propertyRecordClassName += \" components--hoverable\";\n }\n return propertyRecordClassName;\n };\n\n const ratio = props.columnRatio ? props.columnRatio : 0.25;\n const needElementSeparator =\n props.orientation === Orientation.Horizontal &&\n !!props.onColumnRatioChanged;\n const needActionButtons = !!props.actionButtonRenderers;\n const columnsStyleProvider = new PropertyGridColumnStyleProvider(\n props.columnInfo\n );\n\n return (\n <div\n style={columnsStyleProvider.getStyle(\n props.orientation,\n needActionButtons,\n ratio,\n needElementSeparator\n )}\n className={getClassName(props)}\n onClick={_onClick}\n onContextMenu={_onContextMenu}\n onMouseEnter={_onMouseEnter}\n onMouseLeave={_onMouseLeave}\n role='presentation'\n >\n <div className='components-property-record-label'>\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive && (\n <Checkbox\n className='components-property-selection-checkbox'\n checked={isPropertySelected}\n onChange={_onPropertySelectionChanged}\n />\n )}\n {props.labelElement}\n </div>\n {needElementSeparator ? (\n <ElementSeparator\n movableArea={props.width}\n onRatioChanged={props.onColumnRatioChanged}\n ratio={ratio}\n orientation={props.orientation}\n isResizeHandleHovered={props.isResizeHandleHovered}\n onResizeHandleHoverChanged={props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={props.onResizeHandleDragChanged}\n />\n ) : undefined}\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive ? (\n <div className='components-property-record-value'>\n <span>\n {props.valueElementRenderer\n ? props.valueElementRenderer()\n : props.valueElement}\n </span>\n </div>\n ) : undefined}\n {props.actionButtonRenderers ? (\n <ActionButtonList\n orientation={props.orientation}\n property={props.propertyRecord}\n isPropertyHovered={isHovered}\n actionButtonRenderers={props.actionButtonRenderers}\n />\n ) : undefined}\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyView.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FA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qSvB","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 * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ElementSeparator, Orientation } from \"@itwin/core-react\";\nimport { ActionButtonList } from \"@itwin/components-react\";\n\nimport \"./PropertyView.scss\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { GroupQueryBuilderContext } from \"../GroupQueryBuilderContext\";\nimport { useCallback } from \"react\";\nimport { PropertyGridColumnStyleProvider } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties of [[PropertyView]] React component\n * @public\n */\nexport interface PropertyViewProps extends SharedRendererProps {\n /** Property label as a React element */\n labelElement: React.ReactNode;\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n}\n\n/**\n * A React component that renders property as label/value pair\n * @public\n */\nexport const PropertyView = (props: PropertyViewProps) => {\n const context = React.useContext(GroupQueryBuilderContext);\n const [isCheckboxLoading, setIsCheckboxLoading] = React.useState(false);\n\n const _validatePropertySelection = () => {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n return true;\n }\n // Check if all subproperties are selected\n if (!_validateNestedPropertiesSelection(props.propertyRecord)) {\n return false;\n }\n return true;\n };\n\n const _validateNestedPropertiesSelection = (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n if (\n !_validateNestedPropertiesSelection(\n prop.value.members[subPropName]\n )\n ) {\n return false;\n }\n }\n }\n }\n return true;\n };\n\n const [isHovered, setIsHovered] = React.useState<boolean>(false);\n const [isPropertySelected, setIsPropertySelected] = React.useState<boolean>(\n _validatePropertySelection()\n );\n\n const _addSelectedProperty = useCallback(\n async (prop: PropertyRecord) => {\n // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)\n if (\n !context.currentPropertyList.includes(prop) &&\n prop.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n\n if (!(await context.queryBuilder.addProperty(prop))) {\n setIsCheckboxLoading(false);\n setIsPropertySelected(false);\n return;\n }\n context.setCurrentPropertyList(\n context.currentPropertyList.concat(prop)\n );\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _addNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _addSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _addSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _addNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_addSelectedProperty]\n );\n\n const _removeSelectedProperty = useCallback(\n async (prop: PropertyRecord): Promise<void> => {\n if (context.currentPropertyList.includes(prop)) {\n context.setCurrentPropertyList(\n context.currentPropertyList.filter((x: PropertyRecord) => x !== prop)\n );\n await context.queryBuilder.removeProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _removeNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _removeSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _removeSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _removeNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_removeSelectedProperty]\n );\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (isPropertySelected) {\n setIsCheckboxLoading(true);\n _addNestedProperties(props.propertyRecord);\n } else {\n _removeNestedProperties(props.propertyRecord);\n }\n }\n }, [\n _addNestedProperties,\n _removeNestedProperties,\n isPropertySelected,\n props.propertyRecord,\n ]);\n\n React.useEffect(() => {\n if (!context.isRendering)\n setIsCheckboxLoading(false);\n }, [context.isRendering]);\n\n const _onPropertySelectionChanged = () => {\n setIsPropertySelected(!isPropertySelected);\n };\n\n const _onClick = () => {\n if (props.onClick) {\n props.onClick(props.propertyRecord, props.uniqueKey);\n }\n };\n\n const _onMouseEnter = () => {\n if (props.isHoverable) {\n setIsHovered(true);\n }\n };\n\n const _onMouseLeave = () => {\n if (props.isHoverable) {\n setIsHovered(false);\n }\n };\n\n const _onContextMenu = (e: React.MouseEvent) => {\n if (props.onContextMenu) {\n props.onContextMenu(props.propertyRecord, e);\n }\n if (props.onRightClick) {\n props.onRightClick(props.propertyRecord, props.uniqueKey);\n }\n e.preventDefault();\n return false;\n };\n\n const getClassName = (viewProps: PropertyViewProps) => {\n let propertyRecordClassName =\n viewProps.orientation === Orientation.Horizontal\n ? \"components-property-record--horizontal\"\n : \"components-property-record--vertical\";\n if (viewProps.isSelected) {\n propertyRecordClassName += \" components--selected\";\n }\n if (viewProps.onClick) {\n propertyRecordClassName += \" components--clickable\";\n }\n if (viewProps.isHoverable) {\n propertyRecordClassName += \" components--hoverable\";\n }\n return propertyRecordClassName;\n };\n\n const ratio = props.columnRatio ? props.columnRatio : 0.25;\n const needElementSeparator =\n props.orientation === Orientation.Horizontal &&\n !!props.onColumnRatioChanged;\n const needActionButtons = !!props.actionButtonRenderers;\n const columnsStyleProvider = new PropertyGridColumnStyleProvider(\n props.columnInfo\n );\n\n const offset = CommonPropertyRenderer.getLabelOffset(\n props.indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n return (\n <div\n style={columnsStyleProvider.getStyle(\n props.orientation,\n needActionButtons,\n ratio,\n needElementSeparator\n )}\n className={getClassName(props)}\n onClick={_onClick}\n onContextMenu={_onContextMenu}\n onMouseEnter={_onMouseEnter}\n onMouseLeave={_onMouseLeave}\n role='presentation'\n >\n <div className='components-property-record-label'>\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive && (\n <Checkbox\n style={{ marginLeft: offset }}\n className='components-property-selection-checkbox'\n checked={isPropertySelected}\n onChange={_onPropertySelectionChanged}\n disabled={context.isLoading || context.isRendering || (props.propertyRecord.value.value === undefined)}\n isLoading={isCheckboxLoading}\n />\n )}\n {props.labelElement}\n </div>\n {needElementSeparator ? (\n <ElementSeparator\n movableArea={props.width}\n onRatioChanged={props.onColumnRatioChanged}\n ratio={ratio}\n orientation={props.orientation}\n isResizeHandleHovered={props.isResizeHandleHovered}\n onResizeHandleHoverChanged={props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={props.onResizeHandleDragChanged}\n />\n ) : undefined}\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive ? (\n <div className='components-property-record-value'>\n <span>\n {props.valueElementRenderer\n ? props.valueElementRenderer()\n : props.valueElement}\n </span>\n </div>\n ) : undefined}\n {props.actionButtonRenderers ? (\n <ActionButtonList\n orientation={props.orientation}\n property={props.propertyRecord}\n isPropertyHovered={isHovered}\n actionButtonRenderers={props.actionButtonRenderers}\n />\n ) : undefined}\n </div>\n );\n};\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
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
|
|
6
|
-
@import
|
|
7
|
-
@import
|
|
5
|
+
@import '~@itwin/core-react/lib/cjs/core-react/style/themecolors';
|
|
6
|
+
@import '~@itwin/itwinui-css/scss/style/typography';
|
|
7
|
+
@import '~@itwin/itwinui-css/scss/variables';
|
|
8
8
|
|
|
9
9
|
$text-font-size: $iui-font-size;
|
|
10
10
|
$text-font-color: $buic-text-color;
|
|
@@ -52,8 +52,23 @@ $text-font-color: $buic-text-color;
|
|
|
52
52
|
|
|
53
53
|
.components-property-record-label {
|
|
54
54
|
@include record-cell;
|
|
55
|
+
position: relative;
|
|
55
56
|
.components-property-selection-checkbox {
|
|
56
|
-
|
|
57
|
+
flex-shrink: 0;
|
|
58
|
+
position: absolute;
|
|
59
|
+
z-index: 1;
|
|
60
|
+
}
|
|
61
|
+
// Radial does not respect checkbox positioning, have to force it.
|
|
62
|
+
> .iui-progress-indicator-radial {
|
|
63
|
+
position: absolute;
|
|
64
|
+
}
|
|
65
|
+
.components-property-selection-loading {
|
|
66
|
+
display: flex;
|
|
67
|
+
width: $iui-m;
|
|
68
|
+
height: $iui-m;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
flex-shrink: 0;
|
|
57
72
|
}
|
|
58
73
|
}
|
|
59
74
|
|
|
@@ -12,4 +12,5 @@ export declare const WidgetHeader: ({ title, disabled, returnFn, }: WidgetHeader
|
|
|
12
12
|
export declare const handleInputChange: <T>(e: React.ChangeEvent<HTMLInputElement>, values: T, setValues: React.Dispatch<React.SetStateAction<T>>) => void;
|
|
13
13
|
export declare const fetchIdsFromQuery: (query: string, iModelConnection: IModelConnection) => Promise<string[]>;
|
|
14
14
|
export declare const handleError: (errorStatus: number) => void;
|
|
15
|
+
export declare const LoadingSpinner: () => JSX.Element;
|
|
15
16
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.handleError = exports.fetchIdsFromQuery = exports.handleInputChange = exports.WidgetHeader = exports.onSelectionChanged = void 0;
|
|
6
|
+
exports.LoadingSpinner = exports.handleError = exports.fetchIdsFromQuery = exports.handleInputChange = exports.WidgetHeader = exports.onSelectionChanged = void 0;
|
|
7
7
|
/*---------------------------------------------------------------------------------------------
|
|
8
8
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
9
9
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -115,4 +115,9 @@ const handleError = (errorStatus) => {
|
|
|
115
115
|
itwinui_react_1.toaster.negative(errorMessage);
|
|
116
116
|
};
|
|
117
117
|
exports.handleError = handleError;
|
|
118
|
+
const LoadingSpinner = () => {
|
|
119
|
+
return (react_1.default.createElement("div", { className: "gm-loading-spinner" },
|
|
120
|
+
react_1.default.createElement(itwinui_react_1.ProgressRadial, { size: "small", indeterminate: true })));
|
|
121
|
+
};
|
|
122
|
+
exports.LoadingSpinner = LoadingSpinner;
|
|
118
123
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,oEAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,oEAA4D;AAC5D,wDAAqE;AACrE,wBAAsB;AACtB,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,GAAG,GAAG,EAAE;IACjC,OAAO,CACL,uCAAK,SAAS,EAAC,oBAAoB;QACjC,8BAAC,8BAAc,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,SAAG,CACzC,CACP,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB","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 { SvgChevronLeft } from \"@itwin/itwinui-icons-react\";\nimport { ProgressRadial, Text, toaster } from \"@itwin/itwinui-react\";\nimport \"./utils.scss\";\nimport React from \"react\";\nimport type {\n ISelectionProvider,\n SelectionChangeEventArgs,\n} from \"@itwin/presentation-frontend\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\n\nexport const onSelectionChanged = (\n evt: SelectionChangeEventArgs,\n selectionProvider: ISelectionProvider,\n) => {\n /* eslint-disable no-console */\n const selection = selectionProvider.getSelection(evt.imodel, evt.level);\n if (selection.isEmpty) {\n console.log(\"========== Selection cleared ==========\");\n } else {\n console.log(\"========== Selection change ===========\");\n if (selection.instanceKeys.size !== 0) {\n // log all selected ECInstance ids grouped by ECClass name\n console.log(\"ECInstances:\");\n selection.instanceKeys.forEach((ids, ecclass) => {\n console.log(`${ecclass}: [${[...ids].join(\",\")}]`);\n });\n }\n if (selection.nodeKeys.size !== 0) {\n // log all selected node keys\n console.log(\"Nodes:\");\n selection.nodeKeys.forEach((key) => console.log(JSON.stringify(key)));\n }\n console.log(\"=======================================\");\n }\n /* eslint-enable no-console */\n};\n\nexport interface WidgetHeaderProps {\n title: string;\n disabled?: boolean;\n returnFn?: () => Promise<void>;\n}\n\nexport const WidgetHeader = ({\n title,\n disabled = false,\n returnFn,\n}: WidgetHeaderProps) => {\n return (\n <div className='widget-header-container'>\n {returnFn && (\n <div\n className={disabled ? \"chevron-disabled\" : \"chevron\"}\n onClick={disabled ? undefined : returnFn}\n >\n <SvgChevronLeft />\n </div>\n )}\n <Text className='title' variant='title'>\n {title}\n </Text>\n </div>\n );\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: React.Dispatch<React.SetStateAction<T>>,\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const fetchIdsFromQuery = async (\n query: string,\n iModelConnection: IModelConnection,\n) => {\n if (query === \"\") {\n return [];\n }\n const ids: string[] = [];\n const rowIterator = iModelConnection.query(query, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n });\n while (true) {\n const { done, value } = await rowIterator.next();\n if (done) {\n break;\n }\n if (Object.keys(value).includes(\"id\")) {\n ids.push(value.id);\n } else if (Object.keys(value).includes(\"element.id\")) {\n ids.push(value[\"element.id\"]);\n } else if (Object.keys(value).includes(\"eCInstanceId\")) {\n ids.push(value.eCInstanceId);\n }\n }\n return ids;\n};\n\nexport const handleError = (errorStatus: number) => {\n let errorMessage = \"Error! \";\n switch (errorStatus) {\n case 401:\n errorMessage += `You are unauthorized to do this operation.`;\n break;\n case 403:\n errorMessage += `You don't have permission to access the requested resource.`;\n break;\n case 404:\n errorMessage += `The requested resource was not found.`;\n break;\n case 409:\n errorMessage += `This property name is already being used.`;\n break;\n case 422:\n errorMessage += `Unable to process the request.`;\n break;\n case 429:\n errorMessage += `Too many requests.`;\n break;\n case 500:\n errorMessage += `Internal server error.`;\n break;\n case 502:\n errorMessage += `Bad gateway.`;\n break;\n case 503:\n errorMessage += `Service unavailable.`;\n break;\n default:\n errorMessage += `Something went wrong!`;\n }\n toaster.negative(errorMessage);\n\n};\n\nexport const LoadingSpinner = () => {\n return (\n <div className=\"gm-loading-spinner\">\n <ProgressRadial size=\"small\" indeterminate />\n </div>\n );\n};\n"]}
|
|
@@ -2,15 +2,17 @@
|
|
|
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 { Button
|
|
5
|
+
import { Button } from "@itwin/itwinui-react";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import "./ActionPanel.scss";
|
|
8
|
+
import { LoadingSpinner } from "./utils";
|
|
8
9
|
const ActionPanel = ({ onSave, onCancel, disabled = false, isLoading = false, }) => {
|
|
9
10
|
return (React.createElement("div", { id: 'action', className: 'action-panel-container' },
|
|
10
11
|
React.createElement("div", { className: 'action-panel' },
|
|
11
|
-
isLoading
|
|
12
|
-
React.createElement(
|
|
13
|
-
React.createElement(Button, {
|
|
12
|
+
isLoading &&
|
|
13
|
+
React.createElement(LoadingSpinner, null),
|
|
14
|
+
React.createElement(Button, { disabled: disabled || isLoading, styleType: 'high-visibility', id: 'save-app', onClick: onSave }, "Save"),
|
|
15
|
+
React.createElement(Button, { styleType: 'default', type: 'button', id: 'cancel', onClick: onCancel, disabled: disabled || isLoading }, "Cancel"))));
|
|
14
16
|
};
|
|
15
17
|
export default ActionPanel;
|
|
16
18
|
//# sourceMappingURL=ActionPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionPanel.js","sourceRoot":"","sources":["../../../../src/widget/components/ActionPanel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"ActionPanel.js","sourceRoot":"","sources":["../../../../src/widget/components/ActionPanel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AASzC,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,SAAS,GAAG,KAAK,GACA,EAAe,EAAE;IAClC,OAAO,CACL,6BAAK,EAAE,EAAC,QAAQ,EAAC,SAAS,EAAC,wBAAwB;QACjD,6BAAK,SAAS,EAAC,cAAc;YAC1B,SAAS;gBACR,oBAAC,cAAc,OAAG;YAEpB,oBAAC,MAAM,IACL,QAAQ,EAAE,QAAQ,IAAI,SAAS,EAC/B,SAAS,EAAC,iBAAiB,EAC3B,EAAE,EAAC,UAAU,EACb,OAAO,EAAE,MAAM,WAGR;YACT,oBAAC,MAAM,IACL,SAAS,EAAC,SAAS,EACnB,IAAI,EAAC,QAAQ,EACb,EAAE,EAAC,QAAQ,EACX,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAQ,IAAI,SAAS,aAGxB,CACL,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,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 { Button } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport \"./ActionPanel.scss\";\nimport { LoadingSpinner } from \"./utils\";\n\nexport interface ActionPanelProps {\n onSave: () => void;\n onCancel: () => void;\n disabled?: boolean;\n isLoading?: boolean;\n}\n\nconst ActionPanel = ({\n onSave,\n onCancel,\n disabled = false,\n isLoading = false,\n}: ActionPanelProps): JSX.Element => {\n return (\n <div id='action' className='action-panel-container'>\n <div className='action-panel'>\n {isLoading &&\n <LoadingSpinner />\n }\n <Button\n disabled={disabled || isLoading}\n styleType='high-visibility'\n id='save-app'\n onClick={onSave}\n >\n Save\n </Button>\n <Button\n styleType='default'\n type='button'\n id='cancel'\n onClick={onCancel}\n disabled={disabled || isLoading}\n >\n Cancel\n </Button>\n </div>\n </div>\n );\n};\n\nexport default ActionPanel;\n"]}
|
|
@@ -2,10 +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 { Button,
|
|
5
|
+
import { Button, Leading, MiddleTextTruncation, Modal, ModalButtonBar, } from "@itwin/itwinui-react";
|
|
6
6
|
import React, { useState } from "react";
|
|
7
7
|
import "./DeleteModal.scss";
|
|
8
|
-
import { handleError } from "./utils";
|
|
8
|
+
import { handleError, LoadingSpinner } from "./utils";
|
|
9
9
|
export const DeleteModal = ({ entityName, show, setShow, onDelete, refresh, }) => {
|
|
10
10
|
const [isLoading, setIsLoading] = useState(false);
|
|
11
11
|
const deleteCallback = async () => {
|
|
@@ -30,8 +30,10 @@ export const DeleteModal = ({ entityName, show, setShow, onDelete, refresh, }) =
|
|
|
30
30
|
React.createElement(Leading, null, "Are you sure you want to delete"),
|
|
31
31
|
React.createElement("strong", null, React.createElement(MiddleTextTruncation, { text: `${entityName}?` }))),
|
|
32
32
|
React.createElement(ModalButtonBar, null,
|
|
33
|
-
isLoading
|
|
34
|
-
React.createElement(
|
|
33
|
+
isLoading &&
|
|
34
|
+
React.createElement("div", { className: "loading-delete" },
|
|
35
|
+
React.createElement(LoadingSpinner, null)),
|
|
36
|
+
React.createElement(Button, { styleType: 'high-visibility', onClick: deleteCallback, disabled: isLoading }, "Delete"),
|
|
35
37
|
React.createElement(Button, { styleType: 'default', onClick: () => {
|
|
36
38
|
setShow(false);
|
|
37
39
|
}, disabled: isLoading }, "Cancel")))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteModal.js","sourceRoot":"","sources":["../../../../src/widget/components/DeleteModal.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,
|
|
1
|
+
{"version":3,"file":"DeleteModal.js","sourceRoot":"","sources":["../../../../src/widget/components/DeleteModal.tsx"],"names":[],"mappings":"A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BAAC,cAAc,OAAG,CACd;gBACR,oBAAC,MAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,aAEvE;gBACT,oBAAC,MAAM,IACL,SAAS,EAAC,SAAS,EACnB,OAAO,EAAE,GAAG,EAAE;wBACZ,OAAO,CAAC,KAAK,CAAC,CAAC;oBACjB,CAAC,EACD,QAAQ,EAAE,SAAS,aAGZ,CACM,CACX,CACP,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,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 Leading,\n MiddleTextTruncation,\n Modal,\n ModalButtonBar,\n} from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport \"./DeleteModal.scss\";\nimport { handleError, LoadingSpinner } from \"./utils\";\n\nexport interface DeleteModalProps {\n entityName: string;\n show: boolean;\n setShow: React.Dispatch<React.SetStateAction<boolean>>;\n onDelete: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\nexport const DeleteModal = ({\n entityName,\n show,\n setShow,\n onDelete,\n refresh,\n}: DeleteModalProps) => {\n const [isLoading, setIsLoading] = useState<boolean>(false);\n\n const deleteCallback = async () => {\n try {\n setIsLoading(true);\n await onDelete();\n setShow(false);\n await refresh();\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n };\n\n return (\n <>\n <Modal\n title='Confirm'\n modalRootId='grouping-mapping-widget'\n isOpen={show}\n isDismissible={!isLoading}\n onClose={() => {\n setShow(false);\n }}\n >\n <div className=\"delete-modal-body-text\">\n <Leading>\n Are you sure you want to delete\n </Leading>\n <strong>\n {<MiddleTextTruncation text={`${entityName}?`} />}\n </strong>\n </div>\n <ModalButtonBar>\n {isLoading &&\n <div className=\"loading-delete\">\n <LoadingSpinner />\n </div>}\n <Button styleType='high-visibility' onClick={deleteCallback} disabled={isLoading}>\n Delete\n </Button>\n <Button\n styleType='default'\n onClick={() => {\n setShow(false);\n }}\n disabled={isLoading}\n >\n Cancel\n </Button>\n </ModalButtonBar>\n </Modal>\n </>\n );\n};\n\nexport default DeleteModal;\n"]}
|
|
@@ -2,6 +2,8 @@
|
|
|
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
|
.delete-modal-body-text {
|
|
6
8
|
display: flex;
|
|
7
9
|
gap: 4px;
|
|
@@ -10,3 +12,7 @@
|
|
|
10
12
|
min-width: 0px;
|
|
11
13
|
}
|
|
12
14
|
}
|
|
15
|
+
|
|
16
|
+
.loading-delete {
|
|
17
|
+
margin-right: $iui-s;
|
|
18
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Presentation, } from "@itwin/presentation-frontend";
|
|
2
2
|
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
3
|
-
import { Fieldset, LabeledInput, Small, toaster } from "@itwin/itwinui-react";
|
|
3
|
+
import { Button, Fieldset, LabeledInput, LabeledTextarea, RadioTile, RadioTileGroup, Small, Text, toaster } from "@itwin/itwinui-react";
|
|
4
4
|
import React, { useCallback, useEffect, useState } from "react";
|
|
5
5
|
import { reportingClientApi } from "../../api/reportingClient";
|
|
6
|
-
import { fetchIdsFromQuery, handleError, handleInputChange, WidgetHeader } from "./utils";
|
|
6
|
+
import { fetchIdsFromQuery, handleError, handleInputChange, LoadingSpinner, WidgetHeader } from "./utils";
|
|
7
7
|
import "./GroupAction.scss";
|
|
8
8
|
import ActionPanel from "./ActionPanel";
|
|
9
9
|
import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
|
|
@@ -11,6 +11,7 @@ import { GroupQueryBuilderContainer } from "./GroupQueryBuilderContainer";
|
|
|
11
11
|
import { GroupQueryBuilderContext } from "./GroupQueryBuilderContext";
|
|
12
12
|
import { QueryBuilder } from "./QueryBuilder";
|
|
13
13
|
import { clearEmphasizedElements, visualizeElementsById, zoomToElements, } from "./viewerUtils";
|
|
14
|
+
import { SvgCursor, SvgSearch } from "@itwin/itwinui-icons-react";
|
|
14
15
|
const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
|
|
15
16
|
var _a, _b, _c;
|
|
16
17
|
const iModelConnection = useActiveIModelConnection();
|
|
@@ -22,12 +23,21 @@ const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
|
|
|
22
23
|
const [simpleQuery, setSimpleQuery] = useState("");
|
|
23
24
|
const [validator, showValidationMessage] = useValidator();
|
|
24
25
|
const [isLoading, setIsLoading] = useState(false);
|
|
26
|
+
const [isRendering, setIsRendering] = useState(false);
|
|
25
27
|
const [currentPropertyList, setCurrentPropertyList] = React.useState([]);
|
|
26
28
|
const [queryBuilder, setQueryBuilder] = React.useState(new QueryBuilder(undefined));
|
|
29
|
+
const [groupByType, setGroupByType] = React.useState("Selection");
|
|
30
|
+
const [searchInput, setSearchInput] = React.useState("");
|
|
31
|
+
const changeGroupByType = (event) => {
|
|
32
|
+
const { target: { value }, } = event;
|
|
33
|
+
setGroupByType(value);
|
|
34
|
+
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
35
|
+
setQuery("");
|
|
36
|
+
};
|
|
27
37
|
useEffect(() => {
|
|
28
38
|
const removeListener = Presentation.selection.selectionChange.addListener(async (evt, selectionProvider) => {
|
|
29
39
|
const selection = selectionProvider.getSelection(evt.imodel, evt.level);
|
|
30
|
-
const query = `SELECT ECInstanceId FROM ${selection.instanceKeys.keys().next().value}
|
|
40
|
+
const query = selection.instanceKeys.size > 0 ? `SELECT ECInstanceId FROM ${selection.instanceKeys.keys().next().value}` : "";
|
|
31
41
|
setSimpleQuery(query);
|
|
32
42
|
});
|
|
33
43
|
return () => {
|
|
@@ -41,6 +51,7 @@ const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
|
|
|
41
51
|
if (!query || query === "") {
|
|
42
52
|
return;
|
|
43
53
|
}
|
|
54
|
+
setIsRendering(true);
|
|
44
55
|
const ids = await fetchIdsFromQuery(query !== null && query !== void 0 ? query : "", iModelConnection);
|
|
45
56
|
const resolvedHiliteIds = await visualizeElementsById(ids, "red", iModelConnection);
|
|
46
57
|
await zoomToElements(resolvedHiliteIds);
|
|
@@ -48,12 +59,57 @@ const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
|
|
|
48
59
|
catch {
|
|
49
60
|
toaster.negative("Sorry, we have failed to generate a valid query. 😔");
|
|
50
61
|
}
|
|
62
|
+
finally {
|
|
63
|
+
setIsRendering(false);
|
|
64
|
+
}
|
|
51
65
|
};
|
|
52
66
|
void reemphasize();
|
|
53
67
|
}, [iModelConnection, query]);
|
|
54
68
|
useEffect(() => {
|
|
55
69
|
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
56
70
|
}, [iModelConnection]);
|
|
71
|
+
const isWrappedInQuotes = (text) => {
|
|
72
|
+
return text.startsWith(`"`) && text.endsWith(`"`);
|
|
73
|
+
};
|
|
74
|
+
// Temporary until ECViews become available for use.
|
|
75
|
+
const generateSearchQuery = (searchQuery) => {
|
|
76
|
+
const generatedSearchQuery = searchQuery.length > 0 ? `SELECT
|
|
77
|
+
be.ecinstanceid
|
|
78
|
+
FROM
|
|
79
|
+
generic.physicalobject be
|
|
80
|
+
JOIN
|
|
81
|
+
biscore.geometricelement3disincategory ce
|
|
82
|
+
ON be.ecinstanceid = ce.sourceecinstanceid
|
|
83
|
+
JOIN
|
|
84
|
+
bis.ELEMENT de
|
|
85
|
+
ON ce.targetecinstanceid = de.ecinstanceid
|
|
86
|
+
WHERE
|
|
87
|
+
(${searchQuery.map((token, index) => `${index === 0 ? "" : isWrappedInQuotes(token) ? "AND" : "OR"}
|
|
88
|
+
de.codevalue LIKE '%${isWrappedInQuotes(token) ? token.slice(1, -1) : token}%'`).join(" ")}
|
|
89
|
+
)
|
|
90
|
+
UNION
|
|
91
|
+
SELECT
|
|
92
|
+
de.ecinstanceid
|
|
93
|
+
FROM
|
|
94
|
+
biscore.geometricelement3d AS de
|
|
95
|
+
JOIN
|
|
96
|
+
ecdbmeta.ecclassdef AS be
|
|
97
|
+
ON de.ecclassid = be.ecinstanceid
|
|
98
|
+
WHERE
|
|
99
|
+
(${searchQuery.map((token, index) => `${index === 0 ? "" : isWrappedInQuotes(token) ? "AND" : "OR"}
|
|
100
|
+
be.name LIKE '%${isWrappedInQuotes(token) ? token.slice(1, -1) : token}%'`).join(" ")}
|
|
101
|
+
)
|
|
102
|
+
UNION
|
|
103
|
+
SELECT
|
|
104
|
+
be.ecinstanceid
|
|
105
|
+
FROM
|
|
106
|
+
generic.physicalobject be
|
|
107
|
+
WHERE
|
|
108
|
+
(${searchQuery.map((token, index) => `${index === 0 ? "" : isWrappedInQuotes(token) ? "AND" : "OR"}
|
|
109
|
+
be.userlabel LIKE '%${isWrappedInQuotes(token) ? token.slice(1, -1) : token}%'`).join(" ")}
|
|
110
|
+
)` : "";
|
|
111
|
+
setQuery(generatedSearchQuery.trim());
|
|
112
|
+
};
|
|
57
113
|
const save = useCallback(async () => {
|
|
58
114
|
var _a;
|
|
59
115
|
if (!validator.allValid()) {
|
|
@@ -118,22 +174,39 @@ const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
|
|
|
118
174
|
handleInputChange(event, details, setDetails);
|
|
119
175
|
validator.showMessageFor("description");
|
|
120
176
|
} })),
|
|
121
|
-
React.createElement(Fieldset, { legend: 'Group By', className: '
|
|
122
|
-
React.createElement(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
177
|
+
React.createElement(Fieldset, { legend: 'Group By', className: 'query-builder-container' },
|
|
178
|
+
React.createElement(RadioTileGroup, { className: "radio-group-tile", required: true },
|
|
179
|
+
React.createElement(RadioTile, { name: "groupby", icon: React.createElement(SvgCursor, null), onChange: changeGroupByType, defaultChecked: true, value: "Selection", label: "Selection", disabled: isLoading || isRendering }),
|
|
180
|
+
React.createElement(RadioTile, { icon: React.createElement(SvgSearch, null), name: "groupby", onChange: changeGroupByType, value: "Query Keywords", label: "Query Keywords", disabled: isLoading || isRendering })),
|
|
181
|
+
groupByType === "Selection" ?
|
|
182
|
+
React.createElement(GroupQueryBuilderContext.Provider, { value: {
|
|
183
|
+
currentPropertyList,
|
|
184
|
+
setCurrentPropertyList,
|
|
185
|
+
query,
|
|
186
|
+
setQuery,
|
|
187
|
+
queryBuilder,
|
|
188
|
+
setQueryBuilder,
|
|
189
|
+
isLoading,
|
|
190
|
+
isRendering,
|
|
191
|
+
} },
|
|
192
|
+
React.createElement(GroupQueryBuilderContainer, null)) :
|
|
193
|
+
React.createElement("div", { className: "search-form" },
|
|
194
|
+
React.createElement(Text, null, "Generate a query by keywords. Keywords wrapped in double quotes will be considered a required criteria."),
|
|
195
|
+
React.createElement(LabeledTextarea, { label: "Query Keywords", required: true, value: searchInput, onChange: (event) => setSearchInput(event.target.value), disabled: isLoading || isRendering, placeholder: `ex: wall curtain "panel" facade` }),
|
|
196
|
+
React.createElement("div", { className: "search-actions" },
|
|
197
|
+
isRendering &&
|
|
198
|
+
React.createElement(LoadingSpinner, null),
|
|
199
|
+
React.createElement(Button, { disabled: isLoading || isRendering, onClick: () => generateSearchQuery(searchInput ? searchInput.split(" ") : []) }, "Apply"),
|
|
200
|
+
React.createElement(Button, { disabled: isLoading || isRendering, onClick: () => {
|
|
201
|
+
setQuery("");
|
|
202
|
+
setSearchInput("");
|
|
203
|
+
} }, "Clear"))))),
|
|
131
204
|
React.createElement(ActionPanel, { onSave: async () => {
|
|
132
205
|
await save();
|
|
133
206
|
}, onCancel: async () => {
|
|
134
207
|
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
135
208
|
await goBack();
|
|
136
|
-
}, disabled: !(details.groupName && details.description && (query || simpleQuery)), isLoading: isLoading })));
|
|
209
|
+
}, disabled: !(details.groupName && details.description && (query || simpleQuery) && !isRendering && !isLoading), isLoading: isLoading })));
|
|
137
210
|
};
|
|
138
211
|
export default GroupAction;
|
|
139
212
|
//# sourceMappingURL=GroupAction.js.map
|