@itwin/grouping-mapping-widget 0.3.2 → 0.3.5
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/formula/FormulaFunctionProvider.d.ts +18 -0
- package/lib/cjs/formula/FormulaFunctionProvider.js +136 -0
- package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -0
- package/lib/cjs/formula/FormulaOperatorsProvider.d.ts +34 -0
- package/lib/cjs/formula/FormulaOperatorsProvider.js +185 -0
- package/lib/cjs/formula/FormulaOperatorsProvider.js.map +1 -0
- package/lib/cjs/formula/FormulaSplitter.d.ts +2 -0
- package/lib/cjs/formula/FormulaSplitter.js +140 -0
- package/lib/cjs/formula/FormulaSplitter.js.map +1 -0
- package/lib/cjs/formula/FormulaTokensValidator.d.ts +5 -0
- package/lib/cjs/formula/FormulaTokensValidator.js +137 -0
- package/lib/cjs/formula/FormulaTokensValidator.js.map +1 -0
- package/lib/cjs/formula/FormulaValidator.d.ts +3 -0
- package/lib/cjs/formula/FormulaValidator.js +35 -0
- package/lib/cjs/formula/FormulaValidator.js.map +1 -0
- package/lib/cjs/formula/IResult.d.ts +5 -0
- package/lib/cjs/formula/IResult.js +3 -0
- package/lib/cjs/formula/IResult.js.map +1 -0
- package/lib/cjs/formula/InfixToPostfixConverter.d.ts +18 -0
- package/lib/cjs/formula/InfixToPostfixConverter.js +299 -0
- package/lib/cjs/formula/InfixToPostfixConverter.js.map +1 -0
- package/lib/cjs/formula/InputStream.d.ts +12 -0
- package/lib/cjs/formula/InputStream.js +36 -0
- package/lib/cjs/formula/InputStream.js.map +1 -0
- package/lib/cjs/formula/ParenthesisValidator.d.ts +7 -0
- package/lib/cjs/formula/ParenthesisValidator.js +34 -0
- package/lib/cjs/formula/ParenthesisValidator.js.map +1 -0
- package/lib/cjs/formula/Queue.d.ts +11 -0
- package/lib/cjs/formula/Queue.js +42 -0
- package/lib/cjs/formula/Queue.js.map +1 -0
- package/lib/cjs/formula/Stack.d.ts +14 -0
- package/lib/cjs/formula/Stack.js +71 -0
- package/lib/cjs/formula/Stack.js.map +1 -0
- package/lib/cjs/formula/StringBuilder.d.ts +9 -0
- package/lib/cjs/formula/StringBuilder.js +26 -0
- package/lib/cjs/formula/StringBuilder.js.map +1 -0
- package/lib/cjs/formula/Types.d.ts +8 -0
- package/lib/cjs/formula/Types.js +3 -0
- package/lib/cjs/formula/Types.js.map +1 -0
- package/lib/cjs/formula/Utils.d.ts +7 -0
- package/lib/cjs/formula/Utils.js +39 -0
- package/lib/cjs/formula/Utils.js.map +1 -0
- package/lib/cjs/widget/components/BlockingOverlay.d.ts +7 -0
- package/lib/cjs/widget/components/BlockingOverlay.js +21 -0
- package/lib/cjs/widget/components/BlockingOverlay.js.map +1 -0
- package/lib/cjs/widget/components/BlockingOverlay.scss +26 -0
- package/lib/cjs/widget/components/CalculatedPropertyAction.d.ts +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyAction.js +4 -5
- package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +5 -2
- package/lib/cjs/widget/components/CalculatedPropertyTable.js +5 -29
- package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/ConfirmMappingsImport.js +1 -2
- package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/widget/components/ConfirmMappingsImport.scss +4 -2
- package/lib/cjs/widget/components/CustomCalculationAction.d.ts +4 -2
- package/lib/cjs/widget/components/CustomCalculationAction.js +10 -6
- package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationTable.d.ts +5 -2
- package/lib/cjs/widget/components/CustomCalculationTable.js +5 -29
- package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.js +3 -12
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.d.ts +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.js +5 -6
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyTable.d.ts +5 -2
- package/lib/cjs/widget/components/GroupPropertyTable.js +5 -29
- package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.js +2 -3
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/Mapping.js +26 -5
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/MappingAction.js +10 -13
- package/lib/cjs/widget/components/MappingAction.js.map +1 -1
- package/lib/cjs/widget/components/MappingImportWizardModal.js +2 -2
- package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -1
- package/lib/cjs/widget/components/MappingImportWizardModal.scss +6 -2
- package/lib/cjs/widget/components/PropertyMenu.js +77 -21
- package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
- package/lib/cjs/widget/components/SelectIModel.scss +2 -1
- package/lib/cjs/widget/components/SelectMapping.scss +2 -1
- package/lib/cjs/widget/components/SelectMappings.js +1 -2
- package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
- package/lib/cjs/widget/components/SelectProject.js +9 -9
- package/lib/cjs/widget/components/SelectProject.js.map +1 -1
- package/lib/cjs/widget/components/SelectProject.scss +3 -8
- package/lib/cjs/widget/components/utils.d.ts +2 -0
- package/lib/cjs/widget/components/utils.js +13 -1
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/hooks/useFetchData.d.ts +9 -0
- package/lib/cjs/widget/hooks/useFetchData.js +41 -0
- package/lib/cjs/widget/hooks/useFetchData.js.map +1 -0
- package/lib/cjs/widget/hooks/useFormulaValidation.d.ts +6 -0
- package/lib/cjs/widget/hooks/useFormulaValidation.js +29 -0
- package/lib/cjs/widget/hooks/useFormulaValidation.js.map +1 -0
- package/lib/cjs/widget/utils.d.ts +1 -0
- package/lib/cjs/widget/utils.js +9 -0
- package/lib/cjs/widget/utils.js.map +1 -1
- package/lib/esm/formula/FormulaFunctionProvider.d.ts +18 -0
- package/lib/esm/formula/FormulaFunctionProvider.js +130 -0
- package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -0
- package/lib/esm/formula/FormulaOperatorsProvider.d.ts +34 -0
- package/lib/esm/formula/FormulaOperatorsProvider.js +174 -0
- package/lib/esm/formula/FormulaOperatorsProvider.js.map +1 -0
- package/lib/esm/formula/FormulaSplitter.d.ts +2 -0
- package/lib/esm/formula/FormulaSplitter.js +136 -0
- package/lib/esm/formula/FormulaSplitter.js.map +1 -0
- package/lib/esm/formula/FormulaTokensValidator.d.ts +5 -0
- package/lib/esm/formula/FormulaTokensValidator.js +133 -0
- package/lib/esm/formula/FormulaTokensValidator.js.map +1 -0
- package/lib/esm/formula/FormulaValidator.d.ts +3 -0
- package/lib/esm/formula/FormulaValidator.js +31 -0
- package/lib/esm/formula/FormulaValidator.js.map +1 -0
- package/lib/esm/formula/IResult.d.ts +5 -0
- package/lib/esm/formula/IResult.js +2 -0
- package/lib/esm/formula/IResult.js.map +1 -0
- package/lib/esm/formula/InfixToPostfixConverter.d.ts +18 -0
- package/lib/esm/formula/InfixToPostfixConverter.js +295 -0
- package/lib/esm/formula/InfixToPostfixConverter.js.map +1 -0
- package/lib/esm/formula/InputStream.d.ts +12 -0
- package/lib/esm/formula/InputStream.js +32 -0
- package/lib/esm/formula/InputStream.js.map +1 -0
- package/lib/esm/formula/ParenthesisValidator.d.ts +7 -0
- package/lib/esm/formula/ParenthesisValidator.js +30 -0
- package/lib/esm/formula/ParenthesisValidator.js.map +1 -0
- package/lib/esm/formula/Queue.d.ts +11 -0
- package/lib/esm/formula/Queue.js +38 -0
- package/lib/esm/formula/Queue.js.map +1 -0
- package/lib/esm/formula/Stack.d.ts +14 -0
- package/lib/esm/formula/Stack.js +67 -0
- package/lib/esm/formula/Stack.js.map +1 -0
- package/lib/esm/formula/StringBuilder.d.ts +9 -0
- package/lib/esm/formula/StringBuilder.js +22 -0
- package/lib/esm/formula/StringBuilder.js.map +1 -0
- package/lib/esm/formula/Types.d.ts +8 -0
- package/lib/esm/formula/Types.js +2 -0
- package/lib/esm/formula/Types.js.map +1 -0
- package/lib/esm/formula/Utils.d.ts +7 -0
- package/lib/esm/formula/Utils.js +30 -0
- package/lib/esm/formula/Utils.js.map +1 -0
- package/lib/esm/widget/components/BlockingOverlay.d.ts +7 -0
- package/lib/esm/widget/components/BlockingOverlay.js +14 -0
- package/lib/esm/widget/components/BlockingOverlay.js.map +1 -0
- package/lib/esm/widget/components/BlockingOverlay.scss +26 -0
- package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +1 -1
- package/lib/esm/widget/components/CalculatedPropertyAction.js +5 -6
- package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +5 -2
- package/lib/esm/widget/components/CalculatedPropertyTable.js +6 -30
- package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/ConfirmMappingsImport.js +2 -3
- package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/esm/widget/components/ConfirmMappingsImport.scss +4 -2
- package/lib/esm/widget/components/CustomCalculationAction.d.ts +4 -2
- package/lib/esm/widget/components/CustomCalculationAction.js +11 -7
- package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationTable.d.ts +5 -2
- package/lib/esm/widget/components/CustomCalculationTable.js +6 -30
- package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.js +4 -13
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.d.ts +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.js +6 -7
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyTable.d.ts +5 -2
- package/lib/esm/widget/components/GroupPropertyTable.js +6 -30
- package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/Grouping.js +3 -4
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/Mapping.js +28 -7
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/MappingAction.js +12 -15
- package/lib/esm/widget/components/MappingAction.js.map +1 -1
- package/lib/esm/widget/components/MappingImportWizardModal.js +2 -2
- package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -1
- package/lib/esm/widget/components/MappingImportWizardModal.scss +6 -2
- package/lib/esm/widget/components/PropertyMenu.js +79 -23
- package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
- package/lib/esm/widget/components/SelectIModel.scss +2 -1
- package/lib/esm/widget/components/SelectMapping.scss +2 -1
- package/lib/esm/widget/components/SelectMappings.js +2 -3
- package/lib/esm/widget/components/SelectMappings.js.map +1 -1
- package/lib/esm/widget/components/SelectProject.js +9 -9
- package/lib/esm/widget/components/SelectProject.js.map +1 -1
- package/lib/esm/widget/components/SelectProject.scss +3 -8
- package/lib/esm/widget/components/utils.d.ts +2 -0
- package/lib/esm/widget/components/utils.js +11 -0
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/hooks/useFetchData.d.ts +9 -0
- package/lib/esm/widget/hooks/useFetchData.js +35 -0
- package/lib/esm/widget/hooks/useFetchData.js.map +1 -0
- package/lib/esm/widget/hooks/useFormulaValidation.d.ts +6 -0
- package/lib/esm/widget/hooks/useFormulaValidation.js +25 -0
- package/lib/esm/widget/hooks/useFormulaValidation.js.map +1 -0
- package/lib/esm/widget/utils.d.ts +1 -0
- package/lib/esm/widget/utils.js +7 -1
- package/lib/esm/widget/utils.js.map +1 -1
- package/package.json +3 -3
|
@@ -38,6 +38,8 @@ const CustomCalculationTable_1 = __importDefault(require("./CustomCalculationTab
|
|
|
38
38
|
const CustomCalculationAction_1 = __importDefault(require("./CustomCalculationAction"));
|
|
39
39
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
40
40
|
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
41
|
+
const useFetchData_1 = require("../hooks/useFetchData");
|
|
42
|
+
const GroupingMapping_1 = require("./GroupingMapping");
|
|
41
43
|
var PropertyMenuView;
|
|
42
44
|
(function (PropertyMenuView) {
|
|
43
45
|
PropertyMenuView["DEFAULT"] = "default";
|
|
@@ -48,8 +50,44 @@ var PropertyMenuView;
|
|
|
48
50
|
PropertyMenuView["ADD_CUSTOM_CALCULATION"] = "add_custom_calculation";
|
|
49
51
|
PropertyMenuView["MODIFY_CUSTOM_CALCULATION"] = "modify_custom_calculation";
|
|
50
52
|
})(PropertyMenuView = exports.PropertyMenuView || (exports.PropertyMenuView = {}));
|
|
53
|
+
const stringToPossibleDataType = (str) => {
|
|
54
|
+
if (!str)
|
|
55
|
+
return "undefined";
|
|
56
|
+
switch (str.toLowerCase()) {
|
|
57
|
+
case "double":
|
|
58
|
+
case "number": return "number";
|
|
59
|
+
case "string": return "string";
|
|
60
|
+
case "boolean": return "boolean";
|
|
61
|
+
default: return "undefined";
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const convertToPropertyMap = (groupProperties, calculatedProperties, customCalculations, selectedPropertyName) => {
|
|
65
|
+
const map = {};
|
|
66
|
+
const selectedLowerName = selectedPropertyName === null || selectedPropertyName === void 0 ? void 0 : selectedPropertyName.toLowerCase();
|
|
67
|
+
groupProperties.forEach((p) => {
|
|
68
|
+
var _a;
|
|
69
|
+
const lowerName = (_a = p.propertyName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
70
|
+
if (lowerName && lowerName !== selectedLowerName)
|
|
71
|
+
map[lowerName] = stringToPossibleDataType(p.dataType);
|
|
72
|
+
});
|
|
73
|
+
calculatedProperties.forEach((p) => {
|
|
74
|
+
var _a;
|
|
75
|
+
const lowerName = (_a = p.propertyName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
76
|
+
if (lowerName)
|
|
77
|
+
map[lowerName] = "number";
|
|
78
|
+
});
|
|
79
|
+
customCalculations.forEach((p) => {
|
|
80
|
+
var _a;
|
|
81
|
+
const lowerName = (_a = p.propertyName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
82
|
+
if (lowerName && lowerName !== selectedLowerName)
|
|
83
|
+
map[lowerName] = stringToPossibleDataType(p.dataType);
|
|
84
|
+
});
|
|
85
|
+
return map;
|
|
86
|
+
};
|
|
51
87
|
const PropertyMenu = ({ iModelId, mappingId, group, goBack, hideGroupProps = false, hideCalculatedProps = false, hideCustomCalculationProps = false, }) => {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f
|
|
88
|
+
var _a, _b, _c, _d, _e, _f;
|
|
89
|
+
const groupId = (_a = group.id) !== null && _a !== void 0 ? _a : "";
|
|
90
|
+
const apiContext = react_1.useContext(GroupingMapping_1.ApiContext);
|
|
53
91
|
const iModelConnection = appui_react_1.useActiveIModelConnection();
|
|
54
92
|
const [propertyMenuView, setPropertyMenuView] = react_1.useState(PropertyMenuView.DEFAULT);
|
|
55
93
|
const [selectedGroupProperty, setSelectedGroupProperty] = react_1.useState(undefined);
|
|
@@ -59,6 +97,21 @@ const PropertyMenu = ({ iModelId, mappingId, group, goBack, hideGroupProps = fal
|
|
|
59
97
|
const [resolvedHiliteIds, setResolvedHiliteIds] = react_1.useState([]);
|
|
60
98
|
const [keySet, setKeySet] = react_1.useState();
|
|
61
99
|
const [isLoading, setIsLoading] = react_1.useState(true);
|
|
100
|
+
const fetchGroupProperties = react_1.useMemo(() => {
|
|
101
|
+
const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
|
|
102
|
+
return async () => reportingClientApi.getGroupProperties(apiContext.accessToken, iModelId, mappingId, groupId);
|
|
103
|
+
}, [apiContext, iModelId, mappingId, groupId]);
|
|
104
|
+
const { isLoading: isLoadingGroupProperties, data: groupProperties, refreshData: refreshGroupProperties } = useFetchData_1.useCombinedFetchRefresh(fetchGroupProperties);
|
|
105
|
+
const fetchCalculatedProperties = react_1.useMemo(() => {
|
|
106
|
+
const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
|
|
107
|
+
return async () => reportingClientApi.getCalculatedProperties(apiContext.accessToken, iModelId, mappingId, groupId);
|
|
108
|
+
}, [apiContext, iModelId, mappingId, groupId]);
|
|
109
|
+
const { isLoading: isLoadingCalculatedProperties, data: calculatedProperties, refreshData: refreshCalculatedProperties } = useFetchData_1.useCombinedFetchRefresh(fetchCalculatedProperties);
|
|
110
|
+
const fetchCustomCalculations = react_1.useMemo(() => {
|
|
111
|
+
const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
|
|
112
|
+
return async () => reportingClientApi.getCustomCalculations(apiContext.accessToken, iModelId, mappingId, groupId);
|
|
113
|
+
}, [apiContext, iModelId, mappingId, groupId]);
|
|
114
|
+
const { isLoading: isLoadingCustomCalculations, data: customCalculations, refreshData: refreshCustomCalculations } = useFetchData_1.useCombinedFetchRefresh(fetchCustomCalculations);
|
|
62
115
|
react_1.useEffect(() => {
|
|
63
116
|
const initialize = async () => {
|
|
64
117
|
var _a;
|
|
@@ -96,11 +149,20 @@ const PropertyMenu = ({ iModelId, mappingId, group, goBack, hideGroupProps = fal
|
|
|
96
149
|
setSelectedCustomCalculation(value.row.original);
|
|
97
150
|
setPropertyMenuView(PropertyMenuView.MODIFY_CUSTOM_CALCULATION);
|
|
98
151
|
}, []);
|
|
99
|
-
const
|
|
152
|
+
const groupPropertyReturn = react_1.useCallback(async (modified) => {
|
|
153
|
+
setPropertyMenuView(PropertyMenuView.DEFAULT);
|
|
154
|
+
modified && await refreshGroupProperties();
|
|
155
|
+
}, [refreshGroupProperties]);
|
|
156
|
+
const calculatedPropertyReturn = react_1.useCallback(async (modified) => {
|
|
100
157
|
viewerUtils_1.visualizeElements(resolvedHiliteIds, "red");
|
|
101
158
|
await viewerUtils_1.zoomToElements(resolvedHiliteIds);
|
|
102
159
|
setPropertyMenuView(PropertyMenuView.DEFAULT);
|
|
103
|
-
|
|
160
|
+
modified && await refreshCalculatedProperties();
|
|
161
|
+
}, [resolvedHiliteIds, refreshCalculatedProperties]);
|
|
162
|
+
const customCalculationReturn = react_1.useCallback(async (modified) => {
|
|
163
|
+
setPropertyMenuView(PropertyMenuView.DEFAULT);
|
|
164
|
+
modified && await refreshCustomCalculations();
|
|
165
|
+
}, [refreshCustomCalculations]);
|
|
104
166
|
if (isLoading) {
|
|
105
167
|
return (react_1.default.createElement("div", { className: 'loading-overlay' },
|
|
106
168
|
react_1.default.createElement(itwinui_react_1.Text, null, "Loading Group"),
|
|
@@ -109,42 +171,36 @@ const PropertyMenu = ({ iModelId, mappingId, group, goBack, hideGroupProps = fal
|
|
|
109
171
|
}
|
|
110
172
|
switch (propertyMenuView) {
|
|
111
173
|
case PropertyMenuView.ADD_GROUP_PROPERTY:
|
|
112
|
-
return (react_1.default.createElement(GroupPropertyAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId:
|
|
113
|
-
setPropertyMenuView(PropertyMenuView.DEFAULT);
|
|
114
|
-
} }));
|
|
174
|
+
return (react_1.default.createElement(GroupPropertyAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, keySet: keySet !== null && keySet !== void 0 ? keySet : new presentation_common_1.KeySet(), returnFn: groupPropertyReturn }));
|
|
115
175
|
case PropertyMenuView.MODIFY_GROUP_PROPERTY:
|
|
116
|
-
return (react_1.default.createElement(GroupPropertyAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId:
|
|
117
|
-
setPropertyMenuView(PropertyMenuView.DEFAULT);
|
|
118
|
-
} }));
|
|
176
|
+
return (react_1.default.createElement(GroupPropertyAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, keySet: keySet !== null && keySet !== void 0 ? keySet : new presentation_common_1.KeySet(), groupPropertyId: (_b = selectedGroupProperty === null || selectedGroupProperty === void 0 ? void 0 : selectedGroupProperty.id) !== null && _b !== void 0 ? _b : "", groupPropertyName: (_c = selectedGroupProperty === null || selectedGroupProperty === void 0 ? void 0 : selectedGroupProperty.propertyName) !== null && _c !== void 0 ? _c : "", returnFn: groupPropertyReturn }));
|
|
119
177
|
case PropertyMenuView.ADD_CALCULATED_PROPERTY:
|
|
120
|
-
return (react_1.default.createElement(CalculatedPropertyAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId:
|
|
178
|
+
return (react_1.default.createElement(CalculatedPropertyAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, ids: resolvedHiliteIds, returnFn: calculatedPropertyReturn }));
|
|
121
179
|
case PropertyMenuView.MODIFY_CALCULATED_PROPERTY:
|
|
122
|
-
return (react_1.default.createElement(CalculatedPropertyAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId:
|
|
180
|
+
return (react_1.default.createElement(CalculatedPropertyAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, property: selectedCalculatedProperty, ids: resolvedHiliteIds, returnFn: calculatedPropertyReturn }));
|
|
123
181
|
case PropertyMenuView.ADD_CUSTOM_CALCULATION:
|
|
124
|
-
return (react_1.default.createElement(CustomCalculationAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: (
|
|
125
|
-
setPropertyMenuView(PropertyMenuView.DEFAULT);
|
|
126
|
-
} }));
|
|
182
|
+
return (react_1.default.createElement(CustomCalculationAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, properties: convertToPropertyMap(groupProperties, calculatedProperties, customCalculations), returnFn: customCalculationReturn }));
|
|
127
183
|
case PropertyMenuView.MODIFY_CUSTOM_CALCULATION:
|
|
128
|
-
return (react_1.default.createElement(CustomCalculationAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: (
|
|
184
|
+
return (react_1.default.createElement(CustomCalculationAction_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, properties: convertToPropertyMap(groupProperties, calculatedProperties, customCalculations, selectedCustomCalculation === null || selectedCustomCalculation === void 0 ? void 0 : selectedCustomCalculation.propertyName), customCalculation: selectedCustomCalculation, returnFn: customCalculationReturn }));
|
|
129
185
|
default:
|
|
130
186
|
return (react_1.default.createElement(itwinui_react_1.InformationPanelWrapper, { className: 'property-menu-wrapper' },
|
|
131
187
|
react_1.default.createElement("div", { className: 'property-header' },
|
|
132
|
-
react_1.default.createElement(utils_1.WidgetHeader, { title: `${(
|
|
188
|
+
react_1.default.createElement(utils_1.WidgetHeader, { title: `${(_d = group.groupName) !== null && _d !== void 0 ? _d : ""}`, returnFn: goBack }),
|
|
133
189
|
react_1.default.createElement(itwinui_react_1.IconButton, { styleType: 'borderless', onClick: () => setIsInformationPanelOpen(true) },
|
|
134
190
|
react_1.default.createElement(itwinui_icons_react_1.SvgProperties, null))),
|
|
135
191
|
react_1.default.createElement("div", { className: 'property-menu-container' },
|
|
136
192
|
!hideGroupProps && (react_1.default.createElement("div", { className: 'property-table' },
|
|
137
|
-
react_1.default.createElement(GroupPropertyTable_1.default, { iModelId: iModelId, mappingId: mappingId, groupId:
|
|
193
|
+
react_1.default.createElement(GroupPropertyTable_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, onGroupPropertyModify: onGroupPropertyModify, setSelectedGroupProperty: setSelectedGroupProperty, setGroupModifyView: setPropertyMenuView, isLoadingGroupProperties: isLoadingGroupProperties, groupProperties: groupProperties, refreshGroupProperties: refreshGroupProperties, selectedGroupProperty: selectedGroupProperty }))),
|
|
138
194
|
!hideCalculatedProps && (react_1.default.createElement("div", { className: 'property-table' },
|
|
139
|
-
react_1.default.createElement(CalculatedPropertyTable_1.default, { iModelId: iModelId, mappingId: mappingId, groupId:
|
|
195
|
+
react_1.default.createElement(CalculatedPropertyTable_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, onCalculatedPropertyModify: onCalculatedPropertyModify, setSelectedCalculatedProperty: setSelectedCalculatedProperty, setGroupModifyView: setPropertyMenuView, isLoadingCalculatedProperties: isLoadingCalculatedProperties, calculatedProperties: calculatedProperties, refreshCalculatedProperties: refreshCalculatedProperties, selectedCalculatedProperty: selectedCalculatedProperty }))),
|
|
140
196
|
!hideCustomCalculationProps && (react_1.default.createElement("div", { className: 'property-table' },
|
|
141
|
-
react_1.default.createElement(CustomCalculationTable_1.default, { iModelId: iModelId, mappingId: mappingId, groupId:
|
|
197
|
+
react_1.default.createElement(CustomCalculationTable_1.default, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, onCustomCalculationModify: onCustomCalculationModify, setSelectedCustomCalculation: setSelectedCustomCalculation, setGroupModifyView: setPropertyMenuView, isLoadingCustomCalculations: isLoadingCustomCalculations, customCalculations: customCalculations, refreshCustomCalculations: refreshCustomCalculations, selectedCustomCalculation: selectedCustomCalculation })))),
|
|
142
198
|
react_1.default.createElement(itwinui_react_1.InformationPanel, { className: 'information-panel', isOpen: isInformationPanelOpen },
|
|
143
199
|
react_1.default.createElement(itwinui_react_1.InformationPanelHeader, { onClose: () => setIsInformationPanelOpen(false) },
|
|
144
|
-
react_1.default.createElement(itwinui_react_1.Text, { variant: 'subheading' }, `${(
|
|
200
|
+
react_1.default.createElement(itwinui_react_1.Text, { variant: 'subheading' }, `${(_e = group.groupName) !== null && _e !== void 0 ? _e : ""} Information`)),
|
|
145
201
|
react_1.default.createElement(itwinui_react_1.InformationPanelBody, null,
|
|
146
202
|
react_1.default.createElement("div", { className: 'information-body' },
|
|
147
|
-
react_1.default.createElement(itwinui_react_1.LabeledTextarea, { label: 'Query', rows: 15, readOnly: true, defaultValue: (
|
|
203
|
+
react_1.default.createElement(itwinui_react_1.LabeledTextarea, { label: 'Query', rows: 15, readOnly: true, defaultValue: (_f = group.query) !== null && _f !== void 0 ? _f : "" }))))));
|
|
148
204
|
}
|
|
149
205
|
};
|
|
150
206
|
exports.PropertyMenu = PropertyMenu;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyMenu.js","sourceRoot":"","sources":["../../../../src/widget/components/PropertyMenu.tsx"],"names":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,KAAK,mCAAI,EAAE,GAC/B,CACE,CACe,CACN,CACK,CAC3B,CAAC;KACL;AACH,CAAC,CAAC;AArPW,QAAA,YAAY,gBAqPvB","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 { Presentation } from \"@itwin/presentation-frontend\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React, { useCallback, useEffect, useState } from \"react\";\n\nimport { fetchIdsFromQuery, WidgetHeader } from \"./utils\";\nimport {\n clearEmphasizedElements,\n manufactureKeys,\n visualizeElements,\n visualizeElementsByKeys,\n zoomToElements,\n} from \"./viewerUtils\";\nimport type { GroupType } from \"./Grouping\";\nimport \"./PropertyMenu.scss\";\nimport GroupPropertyAction from \"./GroupPropertyAction\";\nimport CalculatedPropertyAction from \"./CalculatedPropertyAction\";\nimport type { GroupPropertyType } from \"./GroupPropertyTable\";\nimport GroupPropertyTable from \"./GroupPropertyTable\";\nimport type {\n CalculatedPropertyType,\n} from \"./CalculatedPropertyTable\";\nimport CalculatedPropertyTable from \"./CalculatedPropertyTable\";\nimport {\n IconButton,\n InformationPanel,\n InformationPanelBody,\n InformationPanelHeader,\n InformationPanelWrapper,\n LabeledTextarea,\n ProgressRadial,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport type { CellProps } from \"react-table\";\nimport type {\n CustomCalculationType,\n} from \"./CustomCalculationTable\";\nimport CustomCalculationTable from \"./CustomCalculationTable\";\nimport CustomCalculationAction from \"./CustomCalculationAction\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { SvgProperties } from \"@itwin/itwinui-icons-react\";\n\ninterface PropertyModifyProps {\n iModelId: string;\n mappingId: string;\n group: GroupType;\n goBack: () => Promise<void>;\n hideGroupProps?: boolean;\n hideCalculatedProps?: boolean;\n hideCustomCalculationProps?: boolean;\n}\n\nexport enum PropertyMenuView {\n DEFAULT = \"default\",\n ADD_GROUP_PROPERTY = \"add_group_property\",\n MODIFY_GROUP_PROPERTY = \"modify_group_property\",\n ADD_CALCULATED_PROPERTY = \"add_calculated_property\",\n MODIFY_CALCULATED_PROPERTY = \"modify_calculated_property\",\n ADD_CUSTOM_CALCULATION = \"add_custom_calculation\",\n MODIFY_CUSTOM_CALCULATION = \"modify_custom_calculation\",\n}\n\nexport const PropertyMenu = ({\n iModelId,\n mappingId,\n group,\n goBack,\n hideGroupProps = false,\n hideCalculatedProps = false,\n hideCustomCalculationProps = false,\n}: PropertyModifyProps) => {\n const iModelConnection = useActiveIModelConnection() as IModelConnection;\n const [propertyMenuView, setPropertyMenuView] = useState<PropertyMenuView>(\n PropertyMenuView.DEFAULT,\n );\n const [selectedGroupProperty, setSelectedGroupProperty] = useState<\n GroupPropertyType | undefined\n >(undefined);\n const [selectedCalculatedProperty, setSelectedCalculatedProperty] = useState<\n CalculatedPropertyType | undefined\n >(undefined);\n const [selectedCustomCalculation, setSelectedCustomCalculation] = useState<\n CustomCalculationType | undefined\n >(undefined);\n const [isInformationPanelOpen, setIsInformationPanelOpen] =\n useState<boolean>(false);\n const [resolvedHiliteIds, setResolvedHiliteIds] = useState<string[]>([]);\n const [keySet, setKeySet] = useState<KeySet>();\n const [isLoading, setIsLoading] = useState<boolean>(true);\n\n useEffect(() => {\n const initialize = async () => {\n try {\n const ids = await fetchIdsFromQuery(group.query ?? \"\", iModelConnection);\n if (ids.length === 0) {\n toaster.warning(\"The query is valid but produced no results.\");\n await goBack();\n }\n const keys = await manufactureKeys(ids, iModelConnection);\n setKeySet(keys);\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n clearEmphasizedElements();\n const resolvedIds = await visualizeElementsByKeys(keys, \"red\");\n await zoomToElements(resolvedIds);\n setResolvedHiliteIds(resolvedIds);\n setIsLoading(false);\n } catch {\n toaster.negative(`Could not load ${group.groupName}.`);\n await goBack();\n }\n };\n void initialize();\n }, [iModelConnection, group.query, goBack, group.groupName]);\n\n const onGroupPropertyModify = useCallback(\n (value: CellProps<GroupPropertyType>) => {\n setSelectedGroupProperty(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_GROUP_PROPERTY);\n },\n [],\n );\n\n const onCalculatedPropertyModify = useCallback(\n (value: CellProps<CalculatedPropertyType>) => {\n setSelectedCalculatedProperty(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_CALCULATED_PROPERTY);\n },\n [],\n );\n\n const onCustomCalculationModify = useCallback(\n (value: CellProps<CustomCalculationType>) => {\n setSelectedCustomCalculation(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_CUSTOM_CALCULATION);\n },\n [],\n );\n\n const calculatedPropertyReturn = useCallback(async () => {\n visualizeElements(resolvedHiliteIds, \"red\");\n await zoomToElements(resolvedHiliteIds);\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }, [resolvedHiliteIds]);\n\n if (isLoading) {\n return (\n <div className='loading-overlay'>\n <Text>Loading Group</Text>\n <ProgressRadial indeterminate />\n <Text>Please wait...</Text>\n </div>\n );\n }\n\n switch (propertyMenuView) {\n case PropertyMenuView.ADD_GROUP_PROPERTY:\n return (\n <GroupPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n keySet={keySet ?? new KeySet()}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.MODIFY_GROUP_PROPERTY:\n return (\n <GroupPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n keySet={keySet ?? new KeySet()}\n groupPropertyId={selectedGroupProperty?.id ?? \"\"}\n groupPropertyName={selectedGroupProperty?.propertyName ?? \"\"}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.ADD_CALCULATED_PROPERTY:\n return (\n <CalculatedPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n ids={resolvedHiliteIds}\n returnFn={calculatedPropertyReturn}\n />\n );\n case PropertyMenuView.MODIFY_CALCULATED_PROPERTY:\n return (\n <CalculatedPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n property={selectedCalculatedProperty}\n ids={resolvedHiliteIds}\n returnFn={calculatedPropertyReturn}\n />\n );\n case PropertyMenuView.ADD_CUSTOM_CALCULATION:\n return (\n <CustomCalculationAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.MODIFY_CUSTOM_CALCULATION:\n return (\n <CustomCalculationAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n customCalculation={selectedCustomCalculation}\n returnFn={calculatedPropertyReturn}\n />\n );\n default:\n return (\n <InformationPanelWrapper className='property-menu-wrapper'>\n <div className='property-header'>\n <WidgetHeader\n title={`${group.groupName ?? \"\"}`}\n returnFn={goBack}\n />\n <IconButton\n styleType='borderless'\n onClick={() => setIsInformationPanelOpen(true)}\n >\n <SvgProperties />\n </IconButton>\n </div>\n <div className='property-menu-container'>\n {!hideGroupProps && (\n <div className='property-table'>\n <GroupPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onGroupPropertyModify={onGroupPropertyModify}\n setSelectedGroupProperty={setSelectedGroupProperty}\n setGroupModifyView={setPropertyMenuView}\n selectedGroupProperty={selectedGroupProperty}\n />\n </div>\n )}\n\n {!hideCalculatedProps && (\n <div className='property-table'>\n <CalculatedPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onCalculatedPropertyModify={onCalculatedPropertyModify}\n setSelectedCalculatedProperty={setSelectedCalculatedProperty}\n setGroupModifyView={setPropertyMenuView}\n selectedCalculatedProperty={selectedCalculatedProperty}\n />\n </div>\n )}\n {!hideCustomCalculationProps && (\n <div className='property-table'>\n <CustomCalculationTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onCustomCalculationModify={onCustomCalculationModify}\n setSelectedCustomCalculation={setSelectedCustomCalculation}\n setGroupModifyView={setPropertyMenuView}\n selectedCustomCalculation={selectedCustomCalculation}\n />\n </div>\n )}\n </div>\n <InformationPanel\n className='information-panel'\n isOpen={isInformationPanelOpen}\n >\n <InformationPanelHeader\n onClose={() => setIsInformationPanelOpen(false)}\n >\n <Text variant='subheading'>{`${group.groupName ?? \"\"\n } Information`}</Text>\n </InformationPanelHeader>\n <InformationPanelBody>\n <div className='information-body'>\n <LabeledTextarea\n label='Query'\n rows={15}\n readOnly\n defaultValue={group.query ?? \"\"}\n />\n </div>\n </InformationPanelBody>\n </InformationPanel>\n </InformationPanelWrapper>\n );\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyMenu.js","sourceRoot":"","sources":["../../../../src/widget/components/PropertyMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wEAA4D;AAC5D,oDAA+D;AAC/D,+CAAqF;AAErF,mCAA8E;AAC9E,+CAMuB;AAEvB,+BAA6B;AAC7B,gFAAwD;AACxD,0FAAkE;AAElE,8EAAsD;AAItD,wFAAgE;AAChE,wDAU8B;AAK9B,sFAA8D;AAC9D,wFAAgE;AAChE,oEAAoD;AACpD,oEAA2D;AAE3D,wDAAgE;AAChE,uDAA+C;AAY/C,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,6DAAyC,CAAA;IACzC,mEAA+C,CAAA;IAC/C,uEAAmD,CAAA;IACnD,6EAAyD,CAAA;IACzD,qEAAiD,CAAA;IACjD,2EAAuD,CAAA;AACzD,CAAC,EARW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAQ3B;AAED,MAA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BAAyB,EAAE,yBAAyB,GACpD,CACE,CACP,CACG;gBACN,8BAAC,gCAAgB,IACf,SAAS,EAAC,mBAAmB,EAC7B,MAAM,EAAE,sBAAsB;oBAE9B,8BAAC,sCAAsB,IACrB,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,KAAK,CAAC;wBAE/C,8BAAC,oBAAI,IAAC,OAAO,EAAC,YAAY,IAAE,GAAG,MAAA,KAAK,CAAC,SAAS,mCAAI,EAClD,cAAc,CAAQ,CACC;oBACzB,8BAAC,oCAAoB;wBACnB,uCAAK,SAAS,EAAC,kBAAkB;4BAC/B,8BAAC,+BAAe,IACd,KAAK,EAAC,OAAO,EACb,IAAI,EAAE,EAAE,EACR,QAAQ,QACR,YAAY,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,EAAE,GAC/B,CACE,CACe,CACN,CACK,CAC3B,CAAC;KACL;AACH,CAAC,CAAC;AAvSW,QAAA,YAAY,gBAuSvB","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 { Presentation } from \"@itwin/presentation-frontend\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React, { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\n\nimport { fetchIdsFromQuery, getReportingClient, WidgetHeader } from \"./utils\";\nimport {\n clearEmphasizedElements,\n manufactureKeys,\n visualizeElements,\n visualizeElementsByKeys,\n zoomToElements,\n} from \"./viewerUtils\";\nimport type { GroupType } from \"./Grouping\";\nimport \"./PropertyMenu.scss\";\nimport GroupPropertyAction from \"./GroupPropertyAction\";\nimport CalculatedPropertyAction from \"./CalculatedPropertyAction\";\nimport type { GroupPropertyType } from \"./GroupPropertyTable\";\nimport GroupPropertyTable from \"./GroupPropertyTable\";\nimport type {\n CalculatedPropertyType,\n} from \"./CalculatedPropertyTable\";\nimport CalculatedPropertyTable from \"./CalculatedPropertyTable\";\nimport {\n IconButton,\n InformationPanel,\n InformationPanelBody,\n InformationPanelHeader,\n InformationPanelWrapper,\n LabeledTextarea,\n ProgressRadial,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport type { CellProps } from \"react-table\";\nimport type {\n CustomCalculationType,\n} from \"./CustomCalculationTable\";\nimport CustomCalculationTable from \"./CustomCalculationTable\";\nimport CustomCalculationAction from \"./CustomCalculationAction\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { SvgProperties } from \"@itwin/itwinui-icons-react\";\nimport type { PossibleDataType, PropertyMap } from \"../../formula/Types\";\nimport { useCombinedFetchRefresh } from \"../hooks/useFetchData\";\nimport { ApiContext } from \"./GroupingMapping\";\n\ninterface PropertyModifyProps {\n iModelId: string;\n mappingId: string;\n group: GroupType;\n goBack: () => Promise<void>;\n hideGroupProps?: boolean;\n hideCalculatedProps?: boolean;\n hideCustomCalculationProps?: boolean;\n}\n\nexport enum PropertyMenuView {\n DEFAULT = \"default\",\n ADD_GROUP_PROPERTY = \"add_group_property\",\n MODIFY_GROUP_PROPERTY = \"modify_group_property\",\n ADD_CALCULATED_PROPERTY = \"add_calculated_property\",\n MODIFY_CALCULATED_PROPERTY = \"modify_calculated_property\",\n ADD_CUSTOM_CALCULATION = \"add_custom_calculation\",\n MODIFY_CUSTOM_CALCULATION = \"modify_custom_calculation\",\n}\n\nconst stringToPossibleDataType = (str?: string): PossibleDataType => {\n if (!str)\n return \"undefined\";\n\n switch (str.toLowerCase()) {\n case \"double\":\n case \"number\": return \"number\";\n case \"string\": return \"string\";\n case \"boolean\": return \"boolean\";\n default: return \"undefined\";\n }\n};\n\nconst convertToPropertyMap = (\n groupProperties: GroupPropertyType[],\n calculatedProperties: CalculatedPropertyType[],\n customCalculations: CustomCalculationType[],\n selectedPropertyName?: string\n): PropertyMap => {\n const map: PropertyMap = {};\n const selectedLowerName = selectedPropertyName?.toLowerCase();\n\n groupProperties.forEach((p) => {\n const lowerName = p.propertyName?.toLowerCase();\n if (lowerName && lowerName !== selectedLowerName)\n map[lowerName] = stringToPossibleDataType(p.dataType);\n });\n\n calculatedProperties.forEach((p) => {\n const lowerName = p.propertyName?.toLowerCase();\n if (lowerName)\n map[lowerName] = \"number\";\n });\n\n customCalculations.forEach((p) => {\n const lowerName = p.propertyName?.toLowerCase();\n if (lowerName && lowerName !== selectedLowerName)\n map[lowerName] = stringToPossibleDataType(p.dataType);\n });\n\n return map;\n};\n\nexport const PropertyMenu = ({\n iModelId,\n mappingId,\n group,\n goBack,\n hideGroupProps = false,\n hideCalculatedProps = false,\n hideCustomCalculationProps = false,\n}: PropertyModifyProps) => {\n const groupId = group.id ?? \"\";\n\n const apiContext = useContext(ApiContext);\n\n const iModelConnection = useActiveIModelConnection() as IModelConnection;\n const [propertyMenuView, setPropertyMenuView] = useState<PropertyMenuView>(\n PropertyMenuView.DEFAULT,\n );\n const [selectedGroupProperty, setSelectedGroupProperty] = useState<\n GroupPropertyType | undefined\n >(undefined);\n const [selectedCalculatedProperty, setSelectedCalculatedProperty] = useState<\n CalculatedPropertyType | undefined\n >(undefined);\n const [selectedCustomCalculation, setSelectedCustomCalculation] = useState<\n CustomCalculationType | undefined\n >(undefined);\n const [isInformationPanelOpen, setIsInformationPanelOpen] =\n useState<boolean>(false);\n const [resolvedHiliteIds, setResolvedHiliteIds] = useState<string[]>([]);\n const [keySet, setKeySet] = useState<KeySet>();\n const [isLoading, setIsLoading] = useState<boolean>(true);\n\n const fetchGroupProperties = useMemo(\n () => {\n const reportingClientApi = getReportingClient(apiContext.prefix);\n return async () => reportingClientApi.getGroupProperties(apiContext.accessToken, iModelId, mappingId, groupId);\n },\n [apiContext, iModelId, mappingId, groupId],\n );\n const { isLoading: isLoadingGroupProperties, data: groupProperties, refreshData: refreshGroupProperties } =\n useCombinedFetchRefresh<GroupPropertyType>(fetchGroupProperties);\n\n const fetchCalculatedProperties = useMemo(\n () => {\n const reportingClientApi = getReportingClient(apiContext.prefix);\n return async () => reportingClientApi.getCalculatedProperties(apiContext.accessToken, iModelId, mappingId, groupId);\n },\n [apiContext, iModelId, mappingId, groupId],\n );\n const { isLoading: isLoadingCalculatedProperties, data: calculatedProperties, refreshData: refreshCalculatedProperties } =\n useCombinedFetchRefresh<CalculatedPropertyType>(fetchCalculatedProperties);\n\n const fetchCustomCalculations = useMemo(\n () => {\n const reportingClientApi = getReportingClient(apiContext.prefix);\n return async () => reportingClientApi.getCustomCalculations(apiContext.accessToken, iModelId, mappingId, groupId);\n },\n [apiContext, iModelId, mappingId, groupId],\n );\n const { isLoading: isLoadingCustomCalculations, data: customCalculations, refreshData: refreshCustomCalculations } =\n useCombinedFetchRefresh<CustomCalculationType>(fetchCustomCalculations);\n\n useEffect(() => {\n const initialize = async () => {\n try {\n const ids = await fetchIdsFromQuery(group.query ?? \"\", iModelConnection);\n if (ids.length === 0) {\n toaster.warning(\"The query is valid but produced no results.\");\n await goBack();\n }\n const keys = await manufactureKeys(ids, iModelConnection);\n setKeySet(keys);\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n clearEmphasizedElements();\n const resolvedIds = await visualizeElementsByKeys(keys, \"red\");\n await zoomToElements(resolvedIds);\n setResolvedHiliteIds(resolvedIds);\n setIsLoading(false);\n } catch {\n toaster.negative(`Could not load ${group.groupName}.`);\n await goBack();\n }\n };\n void initialize();\n }, [iModelConnection, group.query, goBack, group.groupName]);\n\n const onGroupPropertyModify = useCallback(\n (value: CellProps<GroupPropertyType>) => {\n setSelectedGroupProperty(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_GROUP_PROPERTY);\n },\n [],\n );\n\n const onCalculatedPropertyModify = useCallback(\n (value: CellProps<CalculatedPropertyType>) => {\n setSelectedCalculatedProperty(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_CALCULATED_PROPERTY);\n },\n [],\n );\n\n const onCustomCalculationModify = useCallback(\n (value: CellProps<CustomCalculationType>) => {\n setSelectedCustomCalculation(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_CUSTOM_CALCULATION);\n },\n [],\n );\n\n const groupPropertyReturn = useCallback(async (modified: boolean) => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n modified && await refreshGroupProperties();\n }, [refreshGroupProperties]);\n\n const calculatedPropertyReturn = useCallback(async (modified: boolean) => {\n visualizeElements(resolvedHiliteIds, \"red\");\n await zoomToElements(resolvedHiliteIds);\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n modified && await refreshCalculatedProperties();\n }, [resolvedHiliteIds, refreshCalculatedProperties]);\n\n const customCalculationReturn = useCallback(async (modified: boolean) => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n modified && await refreshCustomCalculations();\n }, [refreshCustomCalculations]);\n\n if (isLoading) {\n return (\n <div className='loading-overlay'>\n <Text>Loading Group</Text>\n <ProgressRadial indeterminate />\n <Text>Please wait...</Text>\n </div>\n );\n }\n\n switch (propertyMenuView) {\n case PropertyMenuView.ADD_GROUP_PROPERTY:\n return (\n <GroupPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n keySet={keySet ?? new KeySet()}\n returnFn={groupPropertyReturn}\n />\n );\n case PropertyMenuView.MODIFY_GROUP_PROPERTY:\n return (\n <GroupPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n keySet={keySet ?? new KeySet()}\n groupPropertyId={selectedGroupProperty?.id ?? \"\"}\n groupPropertyName={selectedGroupProperty?.propertyName ?? \"\"}\n returnFn={groupPropertyReturn}\n />\n );\n case PropertyMenuView.ADD_CALCULATED_PROPERTY:\n return (\n <CalculatedPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n ids={resolvedHiliteIds}\n returnFn={calculatedPropertyReturn}\n />\n );\n case PropertyMenuView.MODIFY_CALCULATED_PROPERTY:\n return (\n <CalculatedPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n property={selectedCalculatedProperty}\n ids={resolvedHiliteIds}\n returnFn={calculatedPropertyReturn}\n />\n );\n case PropertyMenuView.ADD_CUSTOM_CALCULATION:\n return (\n <CustomCalculationAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n properties={convertToPropertyMap(groupProperties, calculatedProperties, customCalculations)}\n returnFn={customCalculationReturn}\n />\n );\n case PropertyMenuView.MODIFY_CUSTOM_CALCULATION:\n return (\n <CustomCalculationAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n properties={convertToPropertyMap(groupProperties, calculatedProperties, customCalculations, selectedCustomCalculation?.propertyName)}\n customCalculation={selectedCustomCalculation}\n returnFn={customCalculationReturn}\n />\n );\n default:\n return (\n <InformationPanelWrapper className='property-menu-wrapper'>\n <div className='property-header'>\n <WidgetHeader\n title={`${group.groupName ?? \"\"}`}\n returnFn={goBack}\n />\n <IconButton\n styleType='borderless'\n onClick={() => setIsInformationPanelOpen(true)}\n >\n <SvgProperties />\n </IconButton>\n </div>\n <div className='property-menu-container'>\n {!hideGroupProps && (\n <div className='property-table'>\n <GroupPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n onGroupPropertyModify={onGroupPropertyModify}\n setSelectedGroupProperty={setSelectedGroupProperty}\n setGroupModifyView={setPropertyMenuView}\n isLoadingGroupProperties={isLoadingGroupProperties}\n groupProperties={groupProperties}\n refreshGroupProperties={refreshGroupProperties}\n selectedGroupProperty={selectedGroupProperty}\n />\n </div>\n )}\n\n {!hideCalculatedProps && (\n <div className='property-table'>\n <CalculatedPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n onCalculatedPropertyModify={onCalculatedPropertyModify}\n setSelectedCalculatedProperty={setSelectedCalculatedProperty}\n setGroupModifyView={setPropertyMenuView}\n isLoadingCalculatedProperties={isLoadingCalculatedProperties}\n calculatedProperties={calculatedProperties}\n refreshCalculatedProperties={refreshCalculatedProperties}\n selectedCalculatedProperty={selectedCalculatedProperty}\n />\n </div>\n )}\n {!hideCustomCalculationProps && (\n <div className='property-table'>\n <CustomCalculationTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n onCustomCalculationModify={onCustomCalculationModify}\n setSelectedCustomCalculation={setSelectedCustomCalculation}\n setGroupModifyView={setPropertyMenuView}\n isLoadingCustomCalculations={isLoadingCustomCalculations}\n customCalculations={customCalculations}\n refreshCustomCalculations={refreshCustomCalculations}\n selectedCustomCalculation={selectedCustomCalculation}\n />\n </div>\n )}\n </div>\n <InformationPanel\n className='information-panel'\n isOpen={isInformationPanelOpen}\n >\n <InformationPanelHeader\n onClose={() => setIsInformationPanelOpen(false)}\n >\n <Text variant='subheading'>{`${group.groupName ?? \"\"\n } Information`}</Text>\n </InformationPanelHeader>\n <InformationPanelBody>\n <div className='information-body'>\n <LabeledTextarea\n label='Query'\n rows={15}\n readOnly\n defaultValue={group.query ?? \"\"}\n />\n </div>\n </InformationPanelBody>\n </InformationPanel>\n </InformationPanelWrapper>\n );\n }\n};\n"]}
|
|
@@ -21,14 +21,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
23
23
|
const react_1 = __importStar(require("react"));
|
|
24
|
-
const insights_client_1 = require("@itwin/insights-client");
|
|
25
24
|
const GroupingMapping_1 = require("./GroupingMapping");
|
|
26
25
|
require("./SelectMapping.scss");
|
|
27
26
|
const utils_1 = require("./utils");
|
|
28
27
|
const fetchMappings = async (setMappings, iModelId, setIsLoading, apiContext) => {
|
|
29
28
|
try {
|
|
30
29
|
setIsLoading(true);
|
|
31
|
-
const reportingClientApi =
|
|
30
|
+
const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
|
|
32
31
|
const mappings = await reportingClientApi.getMappings(apiContext.accessToken, iModelId);
|
|
33
32
|
setMappings(mappings);
|
|
34
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMappings.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectMappings.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA,wDAK8B;AAC9B,+CAAqF;
|
|
1
|
+
{"version":3,"file":"SelectMappings.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectMappings.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA,wDAK8B;AAC9B,+CAAqF;AAGrF,uDAA+C;AAE/C,gCAA8B;AAC9B,mCAA0D;AAE1D,MAAM,aAAa,GAAG,KAAK,EACzB,WAA4D,EAC5D,QAAgB,EAChB,YAA2D,EAC3D,UAAe,EACf,EAAE;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,kBAAkB,GAAG,0BAAkB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACxF,WAAW,CAAC,QAAQ,CAAC,CAAC;KACvB;IAAC,OAAO,KAAU,EAAE;QACnB,mBAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC3B;YAAS;QACR,YAAY,CAAC,KAAK,CAAC,CAAC;KACrB;AACH,CAAC,CAAC;AASF,MAAM,cAAc,GAAG,CAAC,EACtB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,GACc,EAAE,EAAE;IACxB,MAAM,UAAU,GAAG,kBAAU,CAAC,4BAAU,CAAC,CAAC;IAC1C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,gBAAQ,CAAU,IAAI,CAAC,CAAC;IAC1D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,gBAAQ,CAAgB,EAAE,CAAC,CAAC;IAC5E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG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D,CAAC,EACD,iBAAiB,EAAE,SAAS,GAC5B;QACF,uCAAK,SAAS,EAAC,qBAAqB;YAClC,8BAAC,sBAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,8BAAC,sBAAM,IACL,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,GAAG,EAAE;oBACZ,QAAQ,CAAC,gBAAgB,CAAC,CAAC;gBAC7B,CAAC,EACD,QAAQ,EAAE,SAAS,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,WAG7C;YACT,8BAAC,sBAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type {\n TablePaginatorRendererProps,\n} from \"@itwin/itwinui-react\";\nimport {\n Button,\n Table,\n tableFilters,\n TablePaginator,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport type { Api } from \"./GroupingMapping\";\nimport { ApiContext } from \"./GroupingMapping\";\nimport type { MappingType } from \"./Mapping\";\nimport \"./SelectMapping.scss\";\nimport { getReportingClient, handleError } from \"./utils\";\n\nconst fetchMappings = async (\n setMappings: React.Dispatch<React.SetStateAction<Mapping[]>>,\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n apiContext: Api\n) => {\n try {\n setIsLoading(true);\n const reportingClientApi = getReportingClient(apiContext.prefix);\n const mappings = await reportingClientApi.getMappings(apiContext.accessToken, iModelId);\n setMappings(mappings);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\ninterface SelectMappingsProps {\n iModelId: string;\n onSelect: (selectedMappings: MappingType[]) => void;\n onCancel: () => void;\n backFn: () => void;\n}\n\nconst SelectMappings = ({\n iModelId,\n onSelect,\n onCancel,\n backFn,\n}: SelectMappingsProps) => {\n const apiContext = useContext(ApiContext);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [selectedMappings, setSelectedMappings] = useState<MappingType[]>([]);\n const [mappings, setMappings] = useState<Mapping[]>([]);\n\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading, apiContext);\n }, [apiContext, iModelId, setIsLoading]);\n\n const mappingsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"mappingName\",\n Header: \"Mapping Name\",\n accessor: \"mappingName\",\n Filter: tableFilters.TextFilter(),\n },\n {\n id: \"description\",\n Header: \"Description\",\n accessor: \"description\",\n Filter: tableFilters.TextFilter(),\n },\n ],\n },\n ],\n []\n );\n\n const pageSizeList = useMemo(() => [10, 25, 50], []);\n const paginator = useCallback(\n (props: TablePaginatorRendererProps) => (\n <TablePaginator {...props} pageSizeList={pageSizeList} />\n ),\n [pageSizeList]\n );\n\n return (\n <div className='select-mapping-container'>\n <Table<MappingType>\n data={mappings}\n columns={mappingsColumns}\n className='select-mapping-table'\n emptyTableContent='No Mappings available.'\n isSortable\n isSelectable\n isLoading={isLoading}\n onSelect={(selectData: MappingType[] | undefined) => {\n selectData && setSelectedMappings(selectData);\n }}\n paginatorRenderer={paginator}\n />\n <div className='import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button\n styleType='high-visibility'\n onClick={() => {\n onSelect(selectedMappings);\n }}\n disabled={isLoading || selectedMappings.length === 0}\n >\n Next\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectMappings;\n"]}
|
|
@@ -53,15 +53,15 @@ const SelectProject = ({ onSelect, onCancel }) => {
|
|
|
53
53
|
setActiveSearchInput("");
|
|
54
54
|
}
|
|
55
55
|
}, svgIcon: react_1.default.createElement(itwinui_react_1.IconButton, { onClick: () => startSearch(), styleType: 'borderless' },
|
|
56
|
-
react_1.default.createElement(itwinui_icons_react_1.SvgSearch, null)) }),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgSearch, null)) })),
|
|
57
|
+
react_1.default.createElement("div", { className: 'project-grid' },
|
|
58
|
+
react_1.default.createElement(imodel_browser_react_1.ProjectGrid, { onThumbnailClick: onSelect, accessToken: apiContext.accessToken, apiOverrides: apiOverrides, filterOptions: activeSearchInput, requestType: projectType === 0
|
|
59
|
+
? "favorites"
|
|
60
|
+
: projectType === 1
|
|
61
|
+
? "recents"
|
|
62
|
+
: "" })),
|
|
63
|
+
react_1.default.createElement("div", { className: 'select-project-action-panel' },
|
|
64
|
+
react_1.default.createElement(itwinui_react_1.Button, { onClick: onCancel }, "Cancel"))));
|
|
65
65
|
};
|
|
66
66
|
exports.default = SelectProject;
|
|
67
67
|
//# sourceMappingURL=SelectProject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectProject.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectProject.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,sEAEqC;AACrC,oEAKoC;AACpC,wDAM8B;AAC9B,+CAA0E;AAC1E,uDAA+C;AAC/C,gCAA8B;AAE9B,MAAM,aAAa,GAAG;IACpB,8BAAC,mBAAG,IACF,GAAG,EAAC,UAAU,EACd,KAAK,EAAC,mBAAmB,EACzB,SAAS,EAAE,8BAAC,mCAAa,OAAG,GAC5B;IACF,8BAAC,mBAAG,IAAC,GAAG,EAAC,SAAS,EAAC,KAAK,EAAC,iBAAiB,EAAC,SAAS,EAAE,8BAAC,iCAAW,OAAG,GAAI;IACzE,8BAAC,mBAAG,IAAC,GAAG,EAAC,KAAK,EAAC,KAAK,EAAC,aAAa,EAAC,SAAS,EAAE,8BAAC,6BAA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AAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,SAAS,EAAC,YAAY;oBAC9D,8BAAC,+BAAS,OAAG,CACF,GAEf,CACa;QACjB,uCAAK,SAAS,EAAC,cAAc;YAC3B,8BAAC,kCAAW,IACV,gBAAgB,EAAE,QAAQ,EAC1B,WAAW,EAAE,UAAU,CAAC,WAAW,EACnC,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,iBAAiB,EAChC,WAAW,EACT,WAAW,KAAK,CAAC;oBACf,CAAC,CAAC,WAAW;oBACb,CAAC,CAAC,WAAW,KAAK,CAAC;wBACjB,CAAC,CAAC,SAAS;wBACX,CAAC,CAAC,EAAE,GAEV,CACE;QACN,uCAAK,SAAS,EAAC,6BAA6B;YAC1C,8BAAC,sBAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,aAAa,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 {\n ApiOverrides,\n ProjectFull,\n} from \"@itwin/imodel-browser-react\";\nimport {\n ProjectGrid,\n} from \"@itwin/imodel-browser-react\";\nimport {\n SvgCalendar,\n SvgList,\n SvgSearch,\n SvgStarHollow,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n HorizontalTabs,\n IconButton,\n LabeledInput,\n Tab,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useContext, useMemo, useState } from \"react\";\nimport { ApiContext } from \"./GroupingMapping\";\nimport \"./SelectProject.scss\";\n\nconst tabsWithIcons = [\n <Tab\n key='favorite'\n label='Favorite projects'\n startIcon={<SvgStarHollow />}\n />,\n <Tab key='recents' label='Recent projects' startIcon={<SvgCalendar />} />,\n <Tab key='all' label='My projects' startIcon={<SvgList />} />,\n];\ninterface SelectProjectProps {\n onSelect: (project: ProjectFull) => void;\n onCancel: () => void;\n}\nconst SelectProject = ({ onSelect, onCancel }: SelectProjectProps) => {\n const apiContext = useContext(ApiContext);\n const [projectType, setProjectType] = useState<number>(0);\n const [searchInput, setSearchInput] = useState<string>(\"\");\n const [activeSearchInput, setActiveSearchInput] = useState<string>(\"\");\n\n const startSearch = useCallback(() => {\n setActiveSearchInput(searchInput);\n }, [searchInput]);\n\n const apiOverrides = useMemo<ApiOverrides<ProjectFull[]>>(\n () => ({ serverEnvironmentPrefix: apiContext.prefix }),\n [apiContext.prefix],\n );\n\n return (\n <div className='select-project-grid-container'>\n <HorizontalTabs\n labels={tabsWithIcons}\n onTabSelected={setProjectType}\n activeIndex={projectType}\n type={\"borderless\"}\n contentClassName='grid-holding-tab'\n >\n <LabeledInput\n displayStyle='inline'\n iconDisplayStyle='inline'\n className='search-input'\n label='Search'\n value={searchInput}\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 if (event.key === \"Escape\") {\n setSearchInput(\"\");\n setActiveSearchInput(\"\");\n }\n }}\n svgIcon={\n <IconButton onClick={() => startSearch()} styleType='borderless'>\n <SvgSearch />\n </IconButton>\n }\n />\n </HorizontalTabs>\n <div className='project-grid'>\n <ProjectGrid\n onThumbnailClick={onSelect}\n accessToken={apiContext.accessToken}\n apiOverrides={apiOverrides}\n filterOptions={activeSearchInput}\n requestType={\n projectType === 0\n ? \"favorites\"\n : projectType === 1\n ? \"recents\"\n : \"\"\n }\n />\n </div>\n <div className='select-project-action-panel'>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectProject;\n"]}
|
|
@@ -7,12 +7,8 @@
|
|
|
7
7
|
.select-project-grid-container {
|
|
8
8
|
display: flex;
|
|
9
9
|
flex-direction: column;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
height: 66vh;
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
}
|
|
10
|
+
flex-grow: 1;
|
|
11
|
+
min-height: 0;
|
|
16
12
|
|
|
17
13
|
.search-input {
|
|
18
14
|
margin-left: auto;
|
|
@@ -26,10 +22,9 @@
|
|
|
26
22
|
.grid-holding-tab {
|
|
27
23
|
display: flex;
|
|
28
24
|
flex-direction: column;
|
|
29
|
-
overflow: hidden;
|
|
30
25
|
gap: $iui-baseline;
|
|
31
|
-
flex-grow: 1;
|
|
32
26
|
}
|
|
27
|
+
|
|
33
28
|
.select-project-action-panel {
|
|
34
29
|
display: flex;
|
|
35
30
|
justify-content: center;
|
|
@@ -2,6 +2,7 @@ import "./utils.scss";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { ISelectionProvider, SelectionChangeEventArgs } from "@itwin/presentation-frontend";
|
|
4
4
|
import type { IModelConnection } from "@itwin/core-frontend";
|
|
5
|
+
import { ReportingClient } from "@itwin/insights-client";
|
|
5
6
|
export declare const onSelectionChanged: (evt: SelectionChangeEventArgs, selectionProvider: ISelectionProvider) => void;
|
|
6
7
|
export interface WidgetHeaderProps {
|
|
7
8
|
title: string;
|
|
@@ -13,4 +14,5 @@ export declare const handleInputChange: <T>(e: React.ChangeEvent<HTMLInputElemen
|
|
|
13
14
|
export declare const fetchIdsFromQuery: (query: string, iModelConnection: IModelConnection) => Promise<string[]>;
|
|
14
15
|
export declare const handleError: (errorStatus: number) => void;
|
|
15
16
|
export declare const LoadingSpinner: () => JSX.Element;
|
|
17
|
+
export declare const getReportingClient: (prefix?: "" | "qa" | "dev" | undefined) => ReportingClient;
|
|
16
18
|
//# 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.LoadingSpinner = exports.handleError = exports.fetchIdsFromQuery = exports.handleInputChange = exports.WidgetHeader = exports.onSelectionChanged = void 0;
|
|
6
|
+
exports.getReportingClient = 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.
|
|
@@ -13,6 +13,7 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
13
13
|
require("./utils.scss");
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
15
|
const core_common_1 = require("@itwin/core-common");
|
|
16
|
+
const insights_client_1 = require("@itwin/insights-client");
|
|
16
17
|
const onSelectionChanged = (evt, selectionProvider) => {
|
|
17
18
|
/* eslint-disable no-console */
|
|
18
19
|
const selection = selectionProvider.getSelection(evt.imodel, evt.level);
|
|
@@ -120,4 +121,15 @@ const LoadingSpinner = () => {
|
|
|
120
121
|
react_1.default.createElement(itwinui_react_1.ProgressRadial, { size: "small", indeterminate: true })));
|
|
121
122
|
};
|
|
122
123
|
exports.LoadingSpinner = LoadingSpinner;
|
|
124
|
+
const prefixUrl = (baseUrl, prefix) => {
|
|
125
|
+
if (prefix && baseUrl) {
|
|
126
|
+
return baseUrl.replace("api.bentley.com", `${prefix}-api.bentley.com`);
|
|
127
|
+
}
|
|
128
|
+
return baseUrl;
|
|
129
|
+
};
|
|
130
|
+
const getReportingClient = (prefix) => {
|
|
131
|
+
const url = prefixUrl(insights_client_1.REPORTING_BASE_PATH, prefix);
|
|
132
|
+
return new insights_client_1.ReportingClient(url);
|
|
133
|
+
};
|
|
134
|
+
exports.getReportingClient = getReportingClient;
|
|
123
135
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":";;;;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K,GAAG;YACN,YAAY,IAAI,cAAc,CAAC;YAC/B,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,sBAAsB,CAAC;YACvC,MAAM;QACR;YACE,YAAY,IAAI,uBAAuB,CAAC;KAC3C;IACD,uBAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAEjC,CAAC,CAAC;AAnCW,QAAA,WAAW,eAmCtB;AAEK,MAAM,cAAc,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;AAEF,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,MAAe,EAAE,EAAE;IACtD,IAAI,MAAM,IAAI,OAAO,EAAE;QACrB,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,MAAM,kBAAkB,CAAC,CAAC;KACxE;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEK,MAAM,kBAAkB,GAAG,CAAC,MAA0B,EAAE,EAAE;IAC/D,MAAM,GAAG,GAAG,SAAS,CAAC,qCAAmB,EAAE,MAAM,CAAC,CAAC;IACnD,OAAO,IAAI,iCAAe,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B","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\";\nimport { REPORTING_BASE_PATH, ReportingClient } from \"@itwin/insights-client\";\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\nconst prefixUrl = (baseUrl?: string, prefix?: string) => {\n if (prefix && baseUrl) {\n return baseUrl.replace(\"api.bentley.com\", `${prefix}-api.bentley.com`);\n }\n return baseUrl;\n};\n\nexport const getReportingClient = (prefix?: \"\" | \"qa\" | \"dev\") => {\n const url = prefixUrl(REPORTING_BASE_PATH, prefix);\n return new ReportingClient(url);\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export declare const useFetchData: <T>(fetchFunc: () => Promise<T[] | undefined>, setIsLoading: React.Dispatch<React.SetStateAction<boolean>>) => [T[], React.Dispatch<React.SetStateAction<T[]>>];
|
|
3
|
+
export declare const useRefreshData: <T>(setData: React.Dispatch<React.SetStateAction<T[]>>, fetchFunc: () => Promise<T[] | undefined>, setIsLoading: React.Dispatch<React.SetStateAction<boolean>>) => () => Promise<void>;
|
|
4
|
+
export declare const useCombinedFetchRefresh: <T>(fetchFunc: () => Promise<T[] | undefined>) => {
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
data: T[];
|
|
7
|
+
refreshData: () => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useFetchData.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCombinedFetchRefresh = exports.useRefreshData = exports.useFetchData = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const utils_1 = require("../components/utils");
|
|
6
|
+
const fetchData = async (setData, fetchFunc, setIsLoading) => {
|
|
7
|
+
try {
|
|
8
|
+
setIsLoading(true);
|
|
9
|
+
const data = await fetchFunc();
|
|
10
|
+
setData(data !== null && data !== void 0 ? data : []);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
utils_1.handleError(error.status);
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
setIsLoading(false);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const useFetchData = (fetchFunc, setIsLoading) => {
|
|
20
|
+
const [data, setData] = react_1.useState([]);
|
|
21
|
+
react_1.useEffect(() => {
|
|
22
|
+
void fetchData(setData, fetchFunc, setIsLoading);
|
|
23
|
+
}, [fetchFunc, setIsLoading]);
|
|
24
|
+
return [data, setData];
|
|
25
|
+
};
|
|
26
|
+
exports.useFetchData = useFetchData;
|
|
27
|
+
const useRefreshData = (setData, fetchFunc, setIsLoading) => {
|
|
28
|
+
return react_1.useCallback(async () => {
|
|
29
|
+
setData([]);
|
|
30
|
+
await fetchData(setData, fetchFunc, setIsLoading);
|
|
31
|
+
}, [setData, fetchFunc, setIsLoading]);
|
|
32
|
+
};
|
|
33
|
+
exports.useRefreshData = useRefreshData;
|
|
34
|
+
const useCombinedFetchRefresh = (fetchFunc) => {
|
|
35
|
+
const [isLoading, setIsLoading] = react_1.useState(true);
|
|
36
|
+
const [data, setData] = exports.useFetchData(fetchFunc, setIsLoading);
|
|
37
|
+
const refreshData = exports.useRefreshData(setData, fetchFunc, setIsLoading);
|
|
38
|
+
return { isLoading, data, refreshData };
|
|
39
|
+
};
|
|
40
|
+
exports.useCombinedFetchRefresh = useCombinedFetchRefresh;
|
|
41
|
+
//# sourceMappingURL=useFetchData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchData.js","sourceRoot":"","sources":["../../../../src/widget/hooks/useFetchData.ts"],"names":[],"mappings":";;;AAKA,iCAAyD;AACzD,+CAAkD;AAElD,MAAM,SAAS,GAAG,KAAK,EACrB,OAAkD,EAClD,SAAyC,EACzC,YAA2D,EAC3D,EAAE;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,IAAI,GAAG,MAAM,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,CAAC;KACrB;IAAC,OAAO,KAAU,EAAE;QACnB,mBAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC3B;YAAS;QACR,YAAY,CAAC,KAAK,CAAC,CAAC;KACrB;AACH,CAAC,CAAC;AAEK,MAAM,YAAY,GAAG,CAC1B,SAAyC,EACzC,YAA2D,EACT,EAAE;IACpD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,gBAAQ,CAAM,EAAE,CAAC,CAAC;IAE1C,iBAAS,CAAC,GAAG,EAAE;QACb,KAAK,SAAS,CACZ,OAAO,EACP,SAAS,EACT,YAAY,CACb,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAE9B,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzB,CAAC,CAAC;AAfW,QAAA,YAAY,gBAevB;AAEK,MAAM,cAAc,GAAG,CAC5B,OAAkD,EAClD,SAAyC,EACzC,YAA2D,EACtC,EAAE;IACvB,OAAO,mBAAW,CAAC,KAAK,IAAI,EAAE;QAC5B,OAAO,CAAC,EAAE,CAAC,CAAC;QACZ,MAAM,SAAS,CACb,OAAO,EACP,SAAS,EACT,YAAY,CACb,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC;AAbW,QAAA,cAAc,kBAazB;AAEK,MAAM,uBAAuB,GAAG,CAAI,SAAyC,EAAE,EAAE;IACtF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,gBAAQ,CAAU,IAAI,CAAC,CAAC;IAC1D,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,oBAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,sBAAc,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IACrE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC1C,CAAC,CAAC;AALW,QAAA,uBAAuB,2BAKlC","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 React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { handleError } from \"../components/utils\";\n\nconst fetchData = async<T>(\n setData: React.Dispatch<React.SetStateAction<T[]>>,\n fetchFunc: () => Promise<T[] | undefined>,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n) => {\n try {\n setIsLoading(true);\n const data = await fetchFunc();\n setData(data ?? []);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nexport const useFetchData = <T>(\n fetchFunc: () => Promise<T[] | undefined>,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n): [T[], React.Dispatch<React.SetStateAction<T[]>>] => {\n const [data, setData] = useState<T[]>([]);\n\n useEffect(() => {\n void fetchData(\n setData,\n fetchFunc,\n setIsLoading,\n );\n }, [fetchFunc, setIsLoading]);\n\n return [data, setData];\n};\n\nexport const useRefreshData = <T>(\n setData: React.Dispatch<React.SetStateAction<T[]>>,\n fetchFunc: () => Promise<T[] | undefined>,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n): () => Promise<void> => {\n return useCallback(async () => {\n setData([]);\n await fetchData(\n setData,\n fetchFunc,\n setIsLoading,\n );\n }, [setData, fetchFunc, setIsLoading]);\n};\n\nexport const useCombinedFetchRefresh = <T>(fetchFunc: () => Promise<T[] | undefined>) => {\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [data, setData] = useFetchData(fetchFunc, setIsLoading);\n const refreshData = useRefreshData(setData, fetchFunc, setIsLoading);\n return { isLoading, data, refreshData };\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PropertyMap } from "../../formula/Types";
|
|
2
|
+
export declare function useFormulaValidation(formulaName: string, formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void): {
|
|
3
|
+
isValid: boolean;
|
|
4
|
+
forceValidation: () => boolean;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=useFormulaValidation.d.ts.map
|