@itwin/grouping-mapping-widget 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/formula/FormulaDataTypeResolver.d.ts +12 -0
- package/lib/cjs/formula/FormulaDataTypeResolver.js +50 -0
- package/lib/cjs/formula/FormulaDataTypeResolver.js.map +1 -0
- package/lib/cjs/formula/FormulaFunctionProvider.js +59 -59
- package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/cjs/formula/FormulaOperatorsProvider.js +7 -7
- package/lib/cjs/formula/FormulaOperatorsProvider.js.map +1 -1
- package/lib/cjs/formula/FormulaTokensDataTypeResolver.d.ts +6 -0
- package/lib/cjs/formula/{FormulaTokensValidator.js → FormulaTokensDataTypeResolver.js} +32 -32
- package/lib/cjs/formula/FormulaTokensDataTypeResolver.js.map +1 -0
- package/lib/cjs/formula/Types.d.ts +2 -2
- package/lib/cjs/formula/Types.js.map +1 -1
- package/lib/cjs/grouping-mapping-widget.d.ts +6 -1
- package/lib/cjs/grouping-mapping-widget.js +6 -3
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/cjs/widget/GroupingMappingWidget.d.ts +3 -6
- package/lib/cjs/widget/GroupingMappingWidget.js +3 -5
- package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyAction.js +7 -5
- package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyTable.js +6 -4
- package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/ConfirmMappingsImport.js +6 -4
- package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationAction.js +7 -5
- package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationTable.js +6 -4
- package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.js +9 -7
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.js +19 -8
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyTable.js +6 -4
- package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js +8 -6
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.js +54 -65
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMapping.d.ts +8 -13
- package/lib/cjs/widget/components/GroupingMapping.js +15 -30
- package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
- package/lib/cjs/widget/components/Mapping.js +18 -14
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/MappingAction.js +7 -5
- package/lib/cjs/widget/components/MappingAction.js.map +1 -1
- package/lib/cjs/widget/components/PropertyMenu.js +16 -15
- package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
- package/lib/cjs/widget/components/QueryBuilder.d.ts +2 -2
- package/lib/cjs/widget/components/QueryBuilder.js +6 -12
- package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
- package/lib/cjs/widget/components/SelectIModel.js +13 -4
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
- package/lib/cjs/widget/components/SelectMappings.js +9 -7
- package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
- package/lib/cjs/widget/components/SelectProject.js +13 -4
- package/lib/cjs/widget/components/SelectProject.js.map +1 -1
- package/lib/cjs/widget/components/{GroupQueryBuilderContext.d.ts → context/GroupQueryBuilderContext.d.ts} +1 -1
- package/lib/cjs/widget/components/{GroupQueryBuilderContext.js → context/GroupQueryBuilderContext.js} +1 -1
- package/lib/cjs/widget/components/context/GroupQueryBuilderContext.js.map +1 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.d.ts +11 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.js +37 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.js.map +1 -0
- package/lib/cjs/widget/components/context/MappingClientContext.d.ts +7 -0
- package/lib/cjs/widget/components/context/MappingClientContext.js +30 -0
- package/lib/cjs/widget/components/context/MappingClientContext.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyGrid.d.ts +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGrid.js +5 -5
- package/lib/cjs/widget/components/property-grid/PropertyGrid.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.d.ts +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.js +2 -2
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.js +9 -6
- package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
- package/lib/cjs/widget/hooks/useFormulaValidation.js +3 -2
- package/lib/cjs/widget/hooks/useFormulaValidation.js.map +1 -1
- package/lib/esm/formula/FormulaDataTypeResolver.d.ts +12 -0
- package/lib/esm/formula/FormulaDataTypeResolver.js +46 -0
- package/lib/esm/formula/FormulaDataTypeResolver.js.map +1 -0
- package/lib/esm/formula/FormulaFunctionProvider.js +59 -59
- package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/esm/formula/FormulaOperatorsProvider.js +7 -7
- package/lib/esm/formula/FormulaOperatorsProvider.js.map +1 -1
- package/lib/esm/formula/FormulaTokensDataTypeResolver.d.ts +6 -0
- package/lib/esm/formula/{FormulaTokensValidator.js → FormulaTokensDataTypeResolver.js} +30 -30
- package/lib/esm/formula/FormulaTokensDataTypeResolver.js.map +1 -0
- package/lib/esm/formula/Types.d.ts +2 -2
- package/lib/esm/formula/Types.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +6 -1
- package/lib/esm/grouping-mapping-widget.js +3 -1
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/widget/GroupingMappingWidget.d.ts +3 -6
- package/lib/esm/widget/GroupingMappingWidget.js +3 -5
- package/lib/esm/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyAction.js +8 -6
- package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyTable.js +7 -5
- package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/ConfirmMappingsImport.js +7 -5
- package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationAction.js +8 -6
- package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationTable.js +7 -5
- package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.js +10 -8
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.js +20 -9
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyTable.js +7 -5
- package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js +8 -6
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js.map +1 -1
- package/lib/esm/widget/components/Grouping.js +56 -67
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/GroupingMapping.d.ts +8 -13
- package/lib/esm/widget/components/GroupingMapping.js +13 -26
- package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
- package/lib/esm/widget/components/Mapping.js +19 -15
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/MappingAction.js +8 -6
- package/lib/esm/widget/components/MappingAction.js.map +1 -1
- package/lib/esm/widget/components/PropertyMenu.js +17 -16
- package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
- package/lib/esm/widget/components/QueryBuilder.d.ts +2 -2
- package/lib/esm/widget/components/QueryBuilder.js +6 -12
- package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
- package/lib/esm/widget/components/SelectIModel.js +14 -5
- package/lib/esm/widget/components/SelectIModel.js.map +1 -1
- package/lib/esm/widget/components/SelectMappings.js +10 -8
- package/lib/esm/widget/components/SelectMappings.js.map +1 -1
- package/lib/esm/widget/components/SelectProject.js +14 -5
- package/lib/esm/widget/components/SelectProject.js.map +1 -1
- package/lib/esm/widget/components/{GroupQueryBuilderContext.d.ts → context/GroupQueryBuilderContext.d.ts} +1 -1
- package/lib/esm/widget/components/{GroupQueryBuilderContext.js → context/GroupQueryBuilderContext.js} +1 -1
- package/lib/esm/widget/components/context/GroupQueryBuilderContext.js.map +1 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.d.ts +11 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.js +14 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.js.map +1 -0
- package/lib/esm/widget/components/context/MappingClientContext.d.ts +7 -0
- package/lib/esm/widget/components/context/MappingClientContext.js +25 -0
- package/lib/esm/widget/components/context/MappingClientContext.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyGrid.d.ts +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGrid.js +6 -6
- package/lib/esm/widget/components/property-grid/PropertyGrid.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.d.ts +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.js +2 -2
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.js +9 -6
- package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/esm/widget/components/viewerUtils.js.map +1 -1
- package/lib/esm/widget/hooks/useFormulaValidation.js +3 -2
- package/lib/esm/widget/hooks/useFormulaValidation.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/formula/FormulaTokensValidator.d.ts +0 -5
- package/lib/cjs/formula/FormulaTokensValidator.js.map +0 -1
- package/lib/cjs/formula/FormulaValidator.d.ts +0 -3
- package/lib/cjs/formula/FormulaValidator.js +0 -35
- package/lib/cjs/formula/FormulaValidator.js.map +0 -1
- package/lib/cjs/widget/components/GroupQueryBuilderContext.js.map +0 -1
- package/lib/esm/formula/FormulaTokensValidator.d.ts +0 -5
- package/lib/esm/formula/FormulaTokensValidator.js.map +0 -1
- package/lib/esm/formula/FormulaValidator.d.ts +0 -3
- package/lib/esm/formula/FormulaValidator.js +0 -31
- package/lib/esm/formula/FormulaValidator.js.map +0 -1
- package/lib/esm/widget/components/GroupQueryBuilderContext.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveTokensDataType = void 0;
|
|
4
4
|
/*---------------------------------------------------------------------------------------------
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -21,49 +21,49 @@ function isNumericalConstant(name) {
|
|
|
21
21
|
"sqrt2",
|
|
22
22
|
].includes(name.toLowerCase());
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function resolveTokensDataType(formulaName, tokens, properties) {
|
|
25
25
|
if (tokens.length === 0)
|
|
26
|
-
return "Formula cannot be empty.";
|
|
26
|
+
return { errorMessage: "Formula cannot be empty." };
|
|
27
27
|
const argStack = new Stack_1.Stack();
|
|
28
28
|
while (tokens.length > 0) {
|
|
29
29
|
const token = tokens.dequeue();
|
|
30
30
|
switch (token.type) {
|
|
31
31
|
case InfixToPostfixConverter_1.TokenType.Number:
|
|
32
|
-
argStack.push("
|
|
32
|
+
argStack.push("Number");
|
|
33
33
|
break;
|
|
34
34
|
case InfixToPostfixConverter_1.TokenType.String:
|
|
35
|
-
argStack.push("
|
|
35
|
+
argStack.push("String");
|
|
36
36
|
break;
|
|
37
37
|
case InfixToPostfixConverter_1.TokenType.Boolean:
|
|
38
|
-
argStack.push("
|
|
38
|
+
argStack.push("Boolean");
|
|
39
39
|
break;
|
|
40
40
|
case InfixToPostfixConverter_1.TokenType.Null:
|
|
41
|
-
argStack.push("
|
|
41
|
+
argStack.push("Undefined");
|
|
42
42
|
break;
|
|
43
43
|
case InfixToPostfixConverter_1.TokenType.Variable:
|
|
44
44
|
const isConstant = isNumericalConstant(token.value);
|
|
45
45
|
if (isConstant) {
|
|
46
|
-
argStack.push("
|
|
46
|
+
argStack.push("Number");
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
if (token.value === formulaName)
|
|
50
|
-
return "Formula cannot reference itself.";
|
|
50
|
+
return { errorMessage: "Formula cannot reference itself." };
|
|
51
51
|
const prop = properties[token.value];
|
|
52
52
|
if (!prop)
|
|
53
|
-
return `Variable "${token.value}" is not available
|
|
53
|
+
return { errorMessage: `Variable "${token.value}" is not available.` };
|
|
54
54
|
argStack.push(prop);
|
|
55
55
|
}
|
|
56
56
|
break;
|
|
57
57
|
case InfixToPostfixConverter_1.TokenType.Operator:
|
|
58
58
|
if (!FormulaOperatorsProvider_1.isOperator(token.value))
|
|
59
|
-
return `Operator "${token.value}" is not supported
|
|
59
|
+
return { errorMessage: `Operator "${token.value}" is not supported.` };
|
|
60
60
|
const operatorBounds = FormulaOperatorsProvider_1.getOperatorArgumentCountBounds(token.value);
|
|
61
61
|
if (!operatorBounds)
|
|
62
|
-
return `Operator "${token.value}" is not supported
|
|
62
|
+
return { errorMessage: `Operator "${token.value}" is not supported.` };
|
|
63
63
|
if (operatorBounds[0] === 2 && token.argCount === 1)
|
|
64
|
-
return `Unary operator "${token.value}" is not supported
|
|
64
|
+
return { errorMessage: `Unary operator "${token.value}" is not supported.` };
|
|
65
65
|
if (argStack.length < token.argCount) {
|
|
66
|
-
return `Too few arguments given for ${token.argCount === 1 ? "unary" : "binary"} operator "${token.value}"
|
|
66
|
+
return { errorMessage: `Too few arguments given for ${token.argCount === 1 ? "unary" : "binary"} operator "${token.value}".` };
|
|
67
67
|
}
|
|
68
68
|
const opArgs = argStack.popN(token.argCount).reverse();
|
|
69
69
|
let operationResult;
|
|
@@ -72,66 +72,66 @@ function validateTokens(formulaName, tokens, properties) {
|
|
|
72
72
|
else if (opArgs.length === 2)
|
|
73
73
|
operationResult = FormulaOperatorsProvider_1.getOperatorReturnType(token.value, opArgs[0], opArgs[1]);
|
|
74
74
|
else
|
|
75
|
-
return `Operator "${token.value}" does not support ${token.argCount} operands
|
|
75
|
+
return { errorMessage: `Operator "${token.value}" does not support ${token.argCount} operands.` };
|
|
76
76
|
if (operationResult.errorMessage)
|
|
77
|
-
return operationResult.errorMessage;
|
|
77
|
+
return { errorMessage: operationResult.errorMessage };
|
|
78
78
|
else
|
|
79
79
|
argStack.push(operationResult.value);
|
|
80
80
|
break;
|
|
81
81
|
case InfixToPostfixConverter_1.TokenType.Function:
|
|
82
82
|
const fnArg = FormulaFunctionProvider_1.getFunction(token.value);
|
|
83
83
|
if (!fnArg)
|
|
84
|
-
return `Function "${token.value}" is not supported
|
|
84
|
+
return { errorMessage: `Function "${token.value}" is not supported.` };
|
|
85
85
|
const fnArgBounds = fnArg.argumentCountBounds;
|
|
86
86
|
if (fnArgBounds[0] === 0 && fnArgBounds[1] === 0 && token.argCount > 0) {
|
|
87
|
-
return `Function "${token.value}" does not accept any arguments
|
|
87
|
+
return { errorMessage: `Function "${token.value}" does not accept any arguments.` };
|
|
88
88
|
}
|
|
89
89
|
else if (fnArgBounds[1] === -1 && token.argCount < fnArgBounds[0]) {
|
|
90
90
|
if (fnArgBounds[0] === 1) {
|
|
91
|
-
return `Function "${token.value}" requires at least 1 argument
|
|
91
|
+
return { errorMessage: `Function "${token.value}" requires at least 1 argument.` };
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
if (token.argCount === 1) {
|
|
95
|
-
return `Function "${token.value}" requires at least ${fnArgBounds[0]} arguments, but only 1 argument was given
|
|
95
|
+
return { errorMessage: `Function "${token.value}" requires at least ${fnArgBounds[0]} arguments, but only 1 argument was given.` };
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
|
-
return `Function "${token.value}" requires at least ${fnArgBounds[0]} arguments, but only ${token.argCount} arguments were given
|
|
98
|
+
return { errorMessage: `Function "${token.value}" requires at least ${fnArgBounds[0]} arguments, but only ${token.argCount} arguments were given.` };
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
else if (fnArgBounds[0] === fnArgBounds[1] && token.argCount !== fnArgBounds[0]) {
|
|
103
103
|
if (fnArgBounds[0] === 1) {
|
|
104
|
-
return `Function "${token.value}" requires exactly 1 argument, but ${token.argCount} arguments were given
|
|
104
|
+
return { errorMessage: `Function "${token.value}" requires exactly 1 argument, but ${token.argCount} arguments were given.` };
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
107
|
if (token.argCount === 1) {
|
|
108
|
-
return `Function "${token.value}" requires exactly ${fnArgBounds[0]} arguments, but 1 argument was given
|
|
108
|
+
return { errorMessage: `Function "${token.value}" requires exactly ${fnArgBounds[0]} arguments, but 1 argument was given.` };
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
|
-
return `Function "${token.value}" requires exactly ${fnArgBounds[0]} arguments, but ${token.argCount} arguments were given
|
|
111
|
+
return { errorMessage: `Function "${token.value}" requires exactly ${fnArgBounds[0]} arguments, but ${token.argCount} arguments were given.` };
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
const fArgs = argStack.popN(token.argCount).reverse();
|
|
116
116
|
if (fArgs.length < token.argCount) {
|
|
117
|
-
return `Too few arguments given for function "${token.value}"
|
|
117
|
+
return { errorMessage: `Too few arguments given for function "${token.value}".` };
|
|
118
118
|
}
|
|
119
119
|
const functionResult = FormulaFunctionProvider_1.getFormulaFunctionReturnType(fnArg, fArgs);
|
|
120
120
|
if (functionResult.errorMessage)
|
|
121
|
-
return `Function "${token.value}" is invalid. ${functionResult.errorMessage}
|
|
121
|
+
return { errorMessage: `Function "${token.value}" is invalid. ${functionResult.errorMessage}` };
|
|
122
122
|
else
|
|
123
123
|
argStack.push(functionResult.value);
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
if (argStack.length !== 1) {
|
|
128
|
-
return "Formula is invalid.";
|
|
128
|
+
return { errorMessage: "Formula is invalid." };
|
|
129
129
|
}
|
|
130
130
|
const resultType = argStack.pop();
|
|
131
|
-
if (!resultType || resultType === "
|
|
132
|
-
return "Formula cannot always return null.";
|
|
131
|
+
if (!resultType || resultType === "Undefined") {
|
|
132
|
+
return { errorMessage: "Formula cannot always return null." };
|
|
133
133
|
}
|
|
134
|
-
return
|
|
134
|
+
return { value: resultType };
|
|
135
135
|
}
|
|
136
|
-
exports.
|
|
137
|
-
//# sourceMappingURL=
|
|
136
|
+
exports.resolveTokensDataType = resolveTokensDataType;
|
|
137
|
+
//# sourceMappingURL=FormulaTokensDataTypeResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormulaTokensDataTypeResolver.js","sourceRoot":"","sources":["../../../src/formula/FormulaTokensDataTypeResolver.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,uEAAsF;AACtF,yEAA+G;AAE/G,uEAAsD;AAGtD,mCAAgC;AAGhC,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO;QACL,GAAG;QACH,KAAK;QACL,MAAM;QACN,OAAO;QACP,QAAQ;QACR,IAAI;QACJ,SAAS;QACT,OAAO;KACR,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,SAAgB,qBAAqB,CAAC,WAAmB,EAAE,MAAoB,EAAE,UA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,EAAE,YAAY,EAAE,qBAAqB,EAAE,CAAC;KAChD;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAClC,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,WAAW,EAAE;QAC7C,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;KAC/D;IAED,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC;AAzHD,sDAyHC","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 { getFormulaFunctionReturnType, getFunction } from \"./FormulaFunctionProvider\";\nimport { getOperatorArgumentCountBounds, getOperatorReturnType, isOperator } from \"./FormulaOperatorsProvider\";\nimport type { Token } from \"./InfixToPostfixConverter\";\nimport { TokenType } from \"./InfixToPostfixConverter\";\nimport type { IResult } from \"./IResult\";\nimport type { Queue } from \"./Queue\";\nimport { Stack } from \"./Stack\";\nimport type { DataType, PossibleDataType, PropertyMap } from \"./Types\";\n\nfunction isNumericalConstant(name: string): boolean {\n return [\n \"e\",\n \"ln2\",\n \"ln10\",\n \"log2e\",\n \"log10e\",\n \"pi\",\n \"sqrt1_2\",\n \"sqrt2\",\n ].includes(name.toLowerCase());\n}\n\nexport function resolveTokensDataType(formulaName: string, tokens: Queue<Token>, properties: PropertyMap): IResult<DataType> {\n if (tokens.length === 0)\n return { errorMessage: \"Formula cannot be empty.\" };\n\n const argStack = new Stack<PossibleDataType>();\n\n while (tokens.length > 0) {\n const token = tokens.dequeue()!;\n\n switch (token.type) {\n case TokenType.Number:\n argStack.push(\"Number\");\n break;\n case TokenType.String:\n argStack.push(\"String\");\n break;\n case TokenType.Boolean:\n argStack.push(\"Boolean\");\n break;\n case TokenType.Null:\n argStack.push(\"Undefined\");\n break;\n case TokenType.Variable:\n const isConstant = isNumericalConstant(token.value);\n if (isConstant) {\n argStack.push(\"Number\");\n } else {\n if (token.value === formulaName)\n return { errorMessage: \"Formula cannot reference itself.\" };\n\n const prop = properties[token.value];\n if (!prop)\n return { errorMessage: `Variable \"${token.value}\" is not available.` };\n\n argStack.push(prop);\n }\n break;\n case TokenType.Operator:\n if (!isOperator(token.value))\n return { errorMessage: `Operator \"${token.value}\" is not supported.` };\n\n const operatorBounds = getOperatorArgumentCountBounds(token.value);\n if (!operatorBounds)\n return { errorMessage: `Operator \"${token.value}\" is not supported.` };\n\n if (operatorBounds[0] === 2 && token.argCount === 1)\n return { errorMessage: `Unary operator \"${token.value}\" is not supported.` };\n\n if (argStack.length < token.argCount) {\n return { errorMessage: `Too few arguments given for ${token.argCount === 1 ? \"unary\" : \"binary\"} operator \"${token.value}\".` };\n }\n const opArgs = argStack.popN(token.argCount).reverse();\n let operationResult;\n if (opArgs.length === 1)\n operationResult = getOperatorReturnType(token.value, opArgs[0]);\n else if (opArgs.length === 2)\n operationResult = getOperatorReturnType(token.value, opArgs[0], opArgs[1]);\n else\n return { errorMessage: `Operator \"${token.value}\" does not support ${token.argCount} operands.` };\n\n if (operationResult.errorMessage)\n return { errorMessage: operationResult.errorMessage };\n else\n argStack.push(operationResult.value!);\n\n break;\n case TokenType.Function:\n const fnArg = getFunction(token.value);\n if (!fnArg)\n return { errorMessage: `Function \"${token.value}\" is not supported.` };\n\n const fnArgBounds = fnArg.argumentCountBounds;\n if (fnArgBounds[0] === 0 && fnArgBounds[1] === 0 && token.argCount > 0) {\n return { errorMessage: `Function \"${token.value}\" does not accept any arguments.` };\n } else if (fnArgBounds[1] === -1 && token.argCount < fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return { errorMessage: `Function \"${token.value}\" requires at least 1 argument.` };\n } else {\n if (token.argCount === 1) {\n return { errorMessage: `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only 1 argument was given.` };\n } else {\n return { errorMessage: `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only ${token.argCount} arguments were given.` };\n }\n }\n } else if (fnArgBounds[0] === fnArgBounds[1] && token.argCount !== fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return { errorMessage: `Function \"${token.value}\" requires exactly 1 argument, but ${token.argCount} arguments were given.` };\n } else {\n if (token.argCount === 1) {\n return { errorMessage: `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but 1 argument was given.` };\n } else {\n return { errorMessage: `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but ${token.argCount} arguments were given.` };\n }\n }\n }\n\n const fArgs = argStack.popN(token.argCount).reverse();\n if (fArgs.length < token.argCount) {\n return { errorMessage: `Too few arguments given for function \"${token.value}\".` };\n }\n\n const functionResult = getFormulaFunctionReturnType(fnArg, fArgs);\n if (functionResult.errorMessage)\n return { errorMessage: `Function \"${token.value}\" is invalid. ${functionResult.errorMessage}` };\n else\n argStack.push(functionResult.value!);\n\n break;\n }\n }\n\n if (argStack.length !== 1) {\n return { errorMessage: \"Formula is invalid.\" };\n }\n\n const resultType = argStack.pop();\n if (!resultType || resultType === \"Undefined\") {\n return { errorMessage: \"Formula cannot always return null.\" };\n }\n\n return { value: resultType };\n}\n\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare type ValueType = number | string | boolean;
|
|
2
2
|
export declare type PossibleValueType = ValueType | undefined;
|
|
3
|
-
export declare type DataType = "
|
|
4
|
-
export declare type PossibleDataType = DataType | "
|
|
3
|
+
export declare type DataType = "Number" | "String" | "Boolean";
|
|
4
|
+
export declare type PossibleDataType = DataType | "Undefined";
|
|
5
5
|
export interface PropertyMap {
|
|
6
6
|
[key: string]: PossibleDataType;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../src/formula/Types.ts"],"names":[],"mappings":"","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*--------------------------------------------------------------------------------------------*/\nexport type ValueType = number | string | boolean;\n\nexport type PossibleValueType = ValueType | undefined;\n\nexport type DataType = \"
|
|
1
|
+
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../src/formula/Types.ts"],"names":[],"mappings":"","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*--------------------------------------------------------------------------------------------*/\nexport type ValueType = number | string | boolean;\n\nexport type PossibleValueType = ValueType | undefined;\n\nexport type DataType = \"Number\" | \"String\" | \"Boolean\";\n\nexport type PossibleDataType = DataType | \"Undefined\";\n\nexport interface PropertyMap { [key: string]: PossibleDataType }\n"]}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/** UI Provider for iTwin Viewer Applications */
|
|
2
2
|
export * from "./widget/GroupingMappingWidget";
|
|
3
3
|
/** Interfaces for providing custom MappingClient */
|
|
4
|
-
export { createDefaultMappingClient
|
|
4
|
+
export { createDefaultMappingClient } from "./widget/components/context/MappingClientContext";
|
|
5
|
+
export { ClientPrefix } from "./widget/components/context/GroupingApiConfigContext";
|
|
5
6
|
export * from "@itwin/insights-client";
|
|
6
7
|
export * from "./widget/IMappingClient";
|
|
7
8
|
/** Internal components for custom UIs */
|
|
8
9
|
export { Mappings } from "./widget/components/Mapping";
|
|
9
10
|
export { Groupings } from "./widget/components/Grouping";
|
|
10
11
|
export { PropertyMenu } from "./widget/components/PropertyMenu";
|
|
12
|
+
/** Formula DataType resolver */
|
|
13
|
+
export { resolveFormulaDataType } from "./formula/FormulaDataTypeResolver";
|
|
14
|
+
export { DataType, PropertyMap } from "./formula/Types";
|
|
15
|
+
export { IResult } from "./formula/IResult";
|
|
11
16
|
//# sourceMappingURL=grouping-mapping-widget.d.ts.map
|
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.PropertyMenu = exports.Groupings = exports.Mappings = exports.createDefaultMappingClient = void 0;
|
|
13
|
+
exports.resolveFormulaDataType = exports.PropertyMenu = exports.Groupings = exports.Mappings = exports.createDefaultMappingClient = void 0;
|
|
14
14
|
/*---------------------------------------------------------------------------------------------
|
|
15
15
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
16
16
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -18,8 +18,8 @@ exports.PropertyMenu = exports.Groupings = exports.Mappings = exports.createDefa
|
|
|
18
18
|
/** UI Provider for iTwin Viewer Applications */
|
|
19
19
|
__exportStar(require("./widget/GroupingMappingWidget"), exports);
|
|
20
20
|
/** Interfaces for providing custom MappingClient */
|
|
21
|
-
var
|
|
22
|
-
Object.defineProperty(exports, "createDefaultMappingClient", { enumerable: true, get: function () { return
|
|
21
|
+
var MappingClientContext_1 = require("./widget/components/context/MappingClientContext");
|
|
22
|
+
Object.defineProperty(exports, "createDefaultMappingClient", { enumerable: true, get: function () { return MappingClientContext_1.createDefaultMappingClient; } });
|
|
23
23
|
__exportStar(require("@itwin/insights-client"), exports);
|
|
24
24
|
__exportStar(require("./widget/IMappingClient"), exports);
|
|
25
25
|
/** Internal components for custom UIs */
|
|
@@ -29,4 +29,7 @@ var Grouping_1 = require("./widget/components/Grouping");
|
|
|
29
29
|
Object.defineProperty(exports, "Groupings", { enumerable: true, get: function () { return Grouping_1.Groupings; } });
|
|
30
30
|
var PropertyMenu_1 = require("./widget/components/PropertyMenu");
|
|
31
31
|
Object.defineProperty(exports, "PropertyMenu", { enumerable: true, get: function () { return PropertyMenu_1.PropertyMenu; } });
|
|
32
|
+
/** Formula DataType resolver */
|
|
33
|
+
var FormulaDataTypeResolver_1 = require("./formula/FormulaDataTypeResolver");
|
|
34
|
+
Object.defineProperty(exports, "resolveFormulaDataType", { enumerable: true, get: function () { return FormulaDataTypeResolver_1.resolveFormulaDataType; } });
|
|
32
35
|
//# sourceMappingURL=grouping-mapping-widget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouping-mapping-widget.js","sourceRoot":"","sources":["../../src/grouping-mapping-widget.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,iEAA+C;AAE/C,oDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"grouping-mapping-widget.js","sourceRoot":"","sources":["../../src/grouping-mapping-widget.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,iEAA+C;AAE/C,oDAAoD;AACpD,yFAA8F;AAArF,kIAAA,0BAA0B,OAAA;AAEnC,yDAAuC;AACvC,0DAAwC;AAExC,yCAAyC;AACzC,uDAAuD;AAA9C,mGAAA,QAAQ,OAAA;AACjB,yDAAyD;AAAhD,qGAAA,SAAS,OAAA;AAClB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AAErB,gCAAgC;AAChC,6EAA2E;AAAlE,iIAAA,sBAAsB,OAAA","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*--------------------------------------------------------------------------------------------*/\n/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widget/GroupingMappingWidget\";\n\n/** Interfaces for providing custom MappingClient */\nexport { createDefaultMappingClient } from \"./widget/components/context/MappingClientContext\";\nexport { ClientPrefix } from \"./widget/components/context/GroupingApiConfigContext\";\nexport * from \"@itwin/insights-client\";\nexport * from \"./widget/IMappingClient\";\n\n/** Internal components for custom UIs */\nexport { Mappings } from \"./widget/components/Mapping\";\nexport { Groupings } from \"./widget/components/Grouping\";\nexport { PropertyMenu } from \"./widget/components/PropertyMenu\";\n\n/** Formula DataType resolver */\nexport { resolveFormulaDataType } from \"./formula/FormulaDataTypeResolver\";\nexport { DataType, PropertyMap } from \"./formula/Types\";\nexport { IResult } from \"./formula/IResult\";\n"]}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { AbstractWidgetProps, UiItemsProvider } from "@itwin/appui-abstract";
|
|
2
2
|
import { AbstractZoneLocation, StagePanelLocation, StagePanelSection } from "@itwin/appui-abstract";
|
|
3
|
-
import type {
|
|
4
|
-
import type { IMappingClient } from "./IMappingClient";
|
|
3
|
+
import type { GroupingMappingProps } from "./components/GroupingMapping";
|
|
5
4
|
export declare class GroupingMappingProvider implements UiItemsProvider {
|
|
5
|
+
private readonly _props;
|
|
6
6
|
readonly id = "GroupingMappingProvider";
|
|
7
|
-
|
|
8
|
-
private readonly _prefix?;
|
|
9
|
-
private readonly _client?;
|
|
10
|
-
constructor(accessToken?: AccessToken, prefix?: "" | "dev" | "qa", client?: IMappingClient);
|
|
7
|
+
constructor(_props?: GroupingMappingProps);
|
|
11
8
|
provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zonelocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
|
|
12
9
|
}
|
|
13
10
|
//# sourceMappingURL=GroupingMappingWidget.d.ts.map
|
|
@@ -8,11 +8,9 @@ const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const GroupingMapping_1 = __importDefault(require("./components/GroupingMapping"));
|
|
10
10
|
class GroupingMappingProvider {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(_props = {}) {
|
|
12
|
+
this._props = _props;
|
|
12
13
|
this.id = "GroupingMappingProvider";
|
|
13
|
-
this._accessToken = accessToken;
|
|
14
|
-
this._prefix = prefix;
|
|
15
|
-
this._client = client;
|
|
16
14
|
}
|
|
17
15
|
provideWidgets(_stageId, stageUsage, location, section, zonelocation) {
|
|
18
16
|
const widgets = [];
|
|
@@ -24,7 +22,7 @@ class GroupingMappingProvider {
|
|
|
24
22
|
id: "GroupingMappingWidget",
|
|
25
23
|
label: "Grouping & Mapping",
|
|
26
24
|
getWidgetContent: () => {
|
|
27
|
-
return react_1.default.createElement(GroupingMapping_1.default, {
|
|
25
|
+
return react_1.default.createElement(GroupingMapping_1.default, { ...this._props });
|
|
28
26
|
},
|
|
29
27
|
};
|
|
30
28
|
widgets.push(GroupingMappingWidget);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":";;;;;;AAQA,0DAK+B;
|
|
1
|
+
{"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":";;;;;;AAQA,0DAK+B;AAC/B,kDAA0B;AAE1B,mFAA2D;AAE3D,MAAa,uBAAuB;IAGlC,YAA6B,SAA+B,EAAE;QAAjC,WAAM,GAAN,MAAM,CAA2B;QAF9C,OAAE,GAAG,yBAAyB,CAAC;IAEmB,CAAC;IAE5D,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B,EAC3B,YAAmC;QAEnC,MAAM,OAAO,GAA0B,EAAE,CAAC;QAC1C,IACE,CAAC,QAAQ,KAAK,mCAAkB,CAAC,IAAI;YACnC,OAAO,KAAK,kCAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,2BAAU,CAAC,OAAO,CAAC;YACpC,YAAY,KAAK,qCAAoB,CAAC,UAAU,EAChD;YACA,MAAM,qBAAqB,GAAwB;gBACjD,EAAE,EAAE,uBAAuB;gBAC3B,KAAK,EAAE,oBAAoB;gBAC3B,gBAAgB,EAAE,GAAG,EAAE;oBACrB,OAAO,8BAAC,yBAAe,OAAK,IAAI,CAAC,MAAM,GAAI,CAAC;gBAC9C,CAAC;aACF,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACrC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAhCD,0DAgCC","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 AbstractWidgetProps,\n UiItemsProvider,\n} from \"@itwin/appui-abstract\";\nimport {\n AbstractZoneLocation,\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-abstract\";\nimport React from \"react\";\nimport type { GroupingMappingProps } from \"./components/GroupingMapping\";\nimport GroupingMapping from \"./components/GroupingMapping\";\n\nexport class GroupingMappingProvider implements UiItemsProvider {\n public readonly id = \"GroupingMappingProvider\";\n\n constructor(private readonly _props: GroupingMappingProps = {}) { }\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n zonelocation?: AbstractZoneLocation\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n if (\n (location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General) ||\n zonelocation === AbstractZoneLocation.CenterLeft\n ) {\n const GroupingMappingWidget: AbstractWidgetProps = {\n id: \"GroupingMappingWidget\",\n label: \"Grouping & Mapping\",\n getWidgetContent: () => {\n return <GroupingMapping {...this._props} />;\n },\n };\n\n widgets.push(GroupingMappingWidget);\n }\n\n return widgets;\n }\n}\n"]}
|
|
@@ -35,11 +35,12 @@ const useValidator_1 = __importStar(require("../hooks/useValidator"));
|
|
|
35
35
|
const utils_1 = require("./utils");
|
|
36
36
|
const viewerUtils_1 = require("./viewerUtils");
|
|
37
37
|
require("./CalculatedPropertyAction.scss");
|
|
38
|
-
const
|
|
38
|
+
const MappingClientContext_1 = require("./context/MappingClientContext");
|
|
39
|
+
const GroupingApiConfigContext_1 = require("./context/GroupingApiConfigContext");
|
|
39
40
|
const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids, returnFn, }) => {
|
|
40
41
|
var _a, _b, _c;
|
|
41
|
-
const
|
|
42
|
-
const mappingClient =
|
|
42
|
+
const { getAccessToken } = GroupingApiConfigContext_1.useGroupingMappingApiConfig();
|
|
43
|
+
const mappingClient = MappingClientContext_1.useMappingClient();
|
|
43
44
|
const [propertyName, setPropertyName] = react_1.useState((_a = property === null || property === void 0 ? void 0 : property.propertyName) !== null && _a !== void 0 ? _a : "");
|
|
44
45
|
const [type, setType] = react_1.useState((_b = property === null || property === void 0 ? void 0 : property.type) !== null && _b !== void 0 ? _b : "");
|
|
45
46
|
const [bboxDecorator, setBboxDecorator] = react_1.useState();
|
|
@@ -88,12 +89,13 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
|
|
|
88
89
|
}
|
|
89
90
|
try {
|
|
90
91
|
setIsLoading(true);
|
|
92
|
+
const accessToken = await getAccessToken();
|
|
91
93
|
property
|
|
92
|
-
? await mappingClient.updateCalculatedProperty(
|
|
94
|
+
? await mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, groupId, (_a = property.id) !== null && _a !== void 0 ? _a : "", {
|
|
93
95
|
propertyName,
|
|
94
96
|
type,
|
|
95
97
|
})
|
|
96
|
-
: await mappingClient.createCalculatedProperty(
|
|
98
|
+
: await mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, groupId, {
|
|
97
99
|
propertyName,
|
|
98
100
|
type,
|
|
99
101
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAiD;AAIjD,wDAM8B;AAC9B,+CAA+D;AAC/D,gEAAwC;AACxC,sFAGkD;AAClD,sEAAwE;AACxE,mCAAoD;AACpD,+CAAkE;AA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C9B;wBACD;4BACE,KAAK,EAAE,2BAA2B;4BAClC,KAAK,EAAE,iBAAiB;yBACzB;wBACD;4BACE,KAAK,EAAE,sCAAsC;4BAC7C,KAAK,EAAE,8BAA8B;yBACtC;wBACD;4BACE,KAAK,EAAE,2CAA2C;4BAClD,KAAK,EAAE,mCAAmC;yBAC3C;wBACD;4BACE,KAAK,EAAE,uCAAuC;4BAC9C,KAAK,EAAE,+BAA+B;yBACvC;qBACF,EACD,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CAC9C,8BAAC,wBAAQ;wBACP,uCAAK,SAAS,EAAC,iBAAiB;4BAC9B,2CAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,uCAAK,SAAS,EAAC,aAAa;wBAC1B,2CAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACrC,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,wBAAwB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedPropertyType } from \"./CalculatedPropertyTable\";\nimport { ApiContext, MappingClientContext } from \"./GroupingMapping\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: CalculatedPropertyType;\n ids: string[];\n returnFn: (modified: boolean) => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const apiContext = useContext(ApiContext);\n const mappingClient = useContext(MappingClientContext);\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<string>(property?.type ?? \"\");\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n property\n ? await mappingClient.updateCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n property.id ?? \"\",\n {\n propertyName,\n type,\n },\n )\n : await mappingClient.createCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n {\n propertyName,\n type,\n },\n );\n await returnFn(true);\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={async () => returnFn(false)}\n />\n <div className='calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledSelect<string>\n label='Quantity Type'\n required\n options={[\n { value: \"Length\", label: \"Length\" },\n { value: \"Area\", label: \"Area\" },\n { value: \"Volume\", label: \"Volume\" },\n {\n value: \"BoundingBoxLongestEdgeLength\",\n label: \"Longest Edge Length\",\n },\n {\n value: \"BoundingBoxIntermediateEdgeLength\",\n label: \"Intermediate Edge Length\",\n },\n {\n value: \"BoundingBoxShortestEdgeLength\",\n label: \"Shortest Edge Length\",\n },\n {\n value: \"BoundingBoxDiagonalLength\",\n label: \"Diagonal Length\",\n },\n {\n value: \"BoundingBoxLongestFaceDiagonalLength\",\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxIntermediateFaceDiagonalLength\",\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxShortestFaceDiagonalLength\",\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={async () => returnFn(false)}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction;\n"]}
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAiD;AAIjD,wDAM8B;AAC9B,+CAAmD;AACnD,gEAAwC;AACxC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BAA0B;yBAClC;wBACD;4BACE,KAAK,EAAE,+BAA+B;4BACtC,KAAK,EAAE,sBAAsB;yBAC9B;wBACD;4BACE,KAAK,EAAE,2BAA2B;4BAClC,KAAK,EAAE,iBAAiB;yBACzB;wBACD;4BACE,KAAK,EAAE,sCAAsC;4BAC7C,KAAK,EAAE,8BAA8B;yBACtC;wBACD;4BACE,KAAK,EAAE,2CAA2C;4BAClD,KAAK,EAAE,mCAAmC;yBAC3C;wBACD;4BACE,KAAK,EAAE,uCAAuC;4BAC9C,KAAK,EAAE,+BAA+B;yBACvC;qBACF,EACD,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CAC9C,8BAAC,wBAAQ;wBACP,uCAAK,SAAS,EAAC,iBAAiB;4BAC9B,2CAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,uCAAK,SAAS,EAAC,aAAa;wBAC1B,2CAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACrC,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,wBAAwB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedPropertyType } from \"./CalculatedPropertyTable\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: CalculatedPropertyType;\n ids: string[];\n returnFn: (modified: boolean) => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<string>(property?.type ?? \"\");\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const accessToken = await getAccessToken();\n\n property\n ? await mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n property.id ?? \"\",\n {\n propertyName,\n type,\n },\n )\n : await mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n {\n propertyName,\n type,\n },\n );\n await returnFn(true);\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={async () => returnFn(false)}\n />\n <div className='calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledSelect<string>\n label='Quantity Type'\n required\n options={[\n { value: \"Length\", label: \"Length\" },\n { value: \"Area\", label: \"Area\" },\n { value: \"Volume\", label: \"Volume\" },\n {\n value: \"BoundingBoxLongestEdgeLength\",\n label: \"Longest Edge Length\",\n },\n {\n value: \"BoundingBoxIntermediateEdgeLength\",\n label: \"Intermediate Edge Length\",\n },\n {\n value: \"BoundingBoxShortestEdgeLength\",\n label: \"Shortest Edge Length\",\n },\n {\n value: \"BoundingBoxDiagonalLength\",\n label: \"Diagonal Length\",\n },\n {\n value: \"BoundingBoxLongestFaceDiagonalLength\",\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxIntermediateFaceDiagonalLength\",\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxShortestFaceDiagonalLength\",\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={async () => returnFn(false)}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction;\n"]}
|
|
@@ -31,11 +31,12 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
32
|
const PropertyMenu_1 = require("./PropertyMenu");
|
|
33
33
|
const DeleteModal_1 = __importDefault(require("./DeleteModal"));
|
|
34
|
-
const
|
|
34
|
+
const MappingClientContext_1 = require("./context/MappingClientContext");
|
|
35
|
+
const GroupingApiConfigContext_1 = require("./context/GroupingApiConfigContext");
|
|
35
36
|
const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, isLoadingCalculatedProperties: isLoadingGroupProperties, calculatedProperties, refreshCalculatedProperties, selectedCalculatedProperty, }) => {
|
|
36
37
|
var _a;
|
|
37
|
-
const
|
|
38
|
-
const mappingClient =
|
|
38
|
+
const { getAccessToken } = GroupingApiConfigContext_1.useGroupingMappingApiConfig();
|
|
39
|
+
const mappingClient = MappingClientContext_1.useMappingClient();
|
|
39
40
|
const [showCalculatedPropertyDeleteModal, setShowCalculatedPropertyDeleteModal,] = react_1.useState(false);
|
|
40
41
|
const calculatedPropertiesColumns = react_1.useMemo(() => [
|
|
41
42
|
{
|
|
@@ -77,7 +78,8 @@ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalc
|
|
|
77
78
|
react_1.default.createElement(itwinui_react_1.Table, { data: calculatedProperties, density: 'extra-condensed', columns: calculatedPropertiesColumns, emptyTableContent: 'No Calculated Properties', isSortable: true, isLoading: isLoadingGroupProperties }),
|
|
78
79
|
react_1.default.createElement(DeleteModal_1.default, { entityName: (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.propertyName) !== null && _a !== void 0 ? _a : "", show: showCalculatedPropertyDeleteModal, setShow: setShowCalculatedPropertyDeleteModal, onDelete: async () => {
|
|
79
80
|
var _a;
|
|
80
|
-
|
|
81
|
+
const accessToken = await getAccessToken();
|
|
82
|
+
await mappingClient.deleteCalculatedProperty(accessToken, iModelId, mappingId, groupId, (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.id) !== null && _a !== void 0 ? _a : "");
|
|
81
83
|
}, refresh: refreshCalculatedProperties })));
|
|
82
84
|
};
|
|
83
85
|
exports.default = CalculatedPropertyTable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,oEAKoC;AACpC,wDAM8B;AAC9B,+
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,oEAKoC;AACpC,wDAM8B;AAC9B,+CAAiD;AAEjD,iDAAkD;AAElD,gEAAwC;AAExC,yEAAkE;AAClE,iFAAiF;AAkBjF,MAAM,uBAAuB,GAAG,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,6BAA6B,EAC7B,kBAAkB,EAClB,0BAA0B,EAC1B,6BAA6B,EAAE,wBAAwB,EACvD,oBAAoB,EACpB,2BAA2B,EAC3B,0BAA0B,GACG,EAAE,EAAE;;IACjC,MAAM,EAAE,cAAc,EAAE,GAAG,sDAA2B,EAAE,CAAC;IACzD,MAAM,aAAa,GAAG,uCAAgB,EAAE,CAAC;IACzC,MAAM,CACJ,iCAAiC,EACjC,oCAAoC,EACrC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IAE7B,MAAM,2BAA2B,GAAG,eAAO,CACzC,GAAG,EAAE,CAAC;QACJ;YACE,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP;oBACE,EAAE,EAAE,cAAc;oBAClB,MAAM,EAAE,qBAAqB;oBAC7B,QAAQ,EAAE,cAAc;oBACxB,IAAI,EAAE,CAAC,KAAwC,EAAE,EAAE,CAAC,CAClD,uCACE,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,8BAAC,qBAAK,IACJ,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAC,iBAAiB,EACzB,OAAO,EAAE,2BAA2B,EACpC,iBAAiB,EAAC,0BAA0B,EAC5C,UAAU,QACV,SAAS,EAAE,wBAAwB,GACnC;QAEF,8BAAC,qBAAW,IACV,UAAU,EAAE,MAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,YAAY,mCAAI,EAAE,EAC1D,IAAI,EAAE,iCAAiC,EACvC,OAAO,EAAE,oCAAoC,EAC7C,QAAQ,EAAE,KAAK,IAAI,EAAE;;gBACnB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;gBAC3C,MAAM,aAAa,CAAC,wBAAwB,CAC1C,WAAW,EACX,QAAQ,EACR,SAAS,EACT,OAAO,EACP,MAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,EAAE,mCAAI,EAAE,CACrC,CAAC;YACJ,CAAC,EACD,OAAO,EAAE,2BAA2B,GACpC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uBAAuB,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 SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Table,\n} from \"@itwin/itwinui-react\";\nimport React, { useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { PropertyMenuView } from \"./PropertyMenu\";\nimport type { CellProps } from \"react-table\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { CalculatedProperty } from \"@itwin/insights-client\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\nexport type CalculatedPropertyType =\n CreateTypeFromInterface<CalculatedProperty>;\n\ninterface CalculatedPropertyTableProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n setSelectedCalculatedProperty: React.Dispatch<React.SetStateAction<CreateTypeFromInterface<CalculatedPropertyType> | undefined>>;\n setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;\n onCalculatedPropertyModify: (value: CellProps<CalculatedPropertyType>) => void;\n isLoadingCalculatedProperties: boolean;\n calculatedProperties: CalculatedPropertyType[];\n refreshCalculatedProperties: () => Promise<void>;\n selectedCalculatedProperty?: CalculatedPropertyType;\n}\n\nconst CalculatedPropertyTable = ({\n iModelId,\n mappingId,\n groupId,\n setSelectedCalculatedProperty,\n setGroupModifyView,\n onCalculatedPropertyModify,\n isLoadingCalculatedProperties: isLoadingGroupProperties,\n calculatedProperties,\n refreshCalculatedProperties,\n selectedCalculatedProperty,\n}: CalculatedPropertyTableProps) => {\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [\n showCalculatedPropertyDeleteModal,\n setShowCalculatedPropertyDeleteModal,\n ] = useState<boolean>(false);\n\n const calculatedPropertiesColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"propertyName\",\n Header: \"Calculated Property\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CalculatedPropertyType>) => (\n <div\n className='iui-anchor'\n onClick={() => onCalculatedPropertyModify(value)}\n >\n {value.row.original.propertyName}\n </div>\n ),\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CalculatedPropertyType>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => onCalculatedPropertyModify(value)}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedCalculatedProperty(value.row.original);\n setShowCalculatedPropertyDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton styleType='borderless'>\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [onCalculatedPropertyModify, setSelectedCalculatedProperty],\n );\n\n return (\n <>\n <Button\n startIcon={<SvgAdd />}\n styleType='high-visibility'\n onClick={() => {\n setGroupModifyView(PropertyMenuView.ADD_CALCULATED_PROPERTY);\n }}\n >\n Add Calculated Property\n </Button>\n <Table<CalculatedPropertyType>\n data={calculatedProperties}\n density='extra-condensed'\n columns={calculatedPropertiesColumns}\n emptyTableContent='No Calculated Properties'\n isSortable\n isLoading={isLoadingGroupProperties}\n />\n\n <DeleteModal\n entityName={selectedCalculatedProperty?.propertyName ?? \"\"}\n show={showCalculatedPropertyDeleteModal}\n setShow={setShowCalculatedPropertyDeleteModal}\n onDelete={async () => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n selectedCalculatedProperty?.id ?? \"\",\n );\n }}\n refresh={refreshCalculatedProperties}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyTable;\n"]}
|
|
@@ -30,12 +30,13 @@ const appui_react_1 = require("@itwin/appui-react");
|
|
|
30
30
|
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
31
31
|
const useValidator_1 = __importStar(require("../hooks/useValidator"));
|
|
32
32
|
const utils_1 = require("./utils");
|
|
33
|
-
const
|
|
33
|
+
const MappingClientContext_1 = require("./context/MappingClientContext");
|
|
34
|
+
const GroupingApiConfigContext_1 = require("./context/GroupingApiConfigContext");
|
|
34
35
|
const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, setImporting, setSelectedMappings, backFn, onCancel, onFinish, }) => {
|
|
35
36
|
var _a;
|
|
36
37
|
const iModelId = (_a = appui_react_1.useActiveIModelConnection()) === null || _a === void 0 ? void 0 : _a.iModelId;
|
|
37
|
-
const
|
|
38
|
-
const mappingClient =
|
|
38
|
+
const { getAccessToken } = GroupingApiConfigContext_1.useGroupingMappingApiConfig();
|
|
39
|
+
const mappingClient = MappingClientContext_1.useMappingClient();
|
|
39
40
|
const [importCount, setImportCount] = react_1.useState(0);
|
|
40
41
|
const [currentlyImporting, setCurrentlyImporting] = react_1.useState("");
|
|
41
42
|
const [validator, showValidationMessage] = useValidator_1.default();
|
|
@@ -64,7 +65,8 @@ const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, set
|
|
|
64
65
|
try {
|
|
65
66
|
for (const selectedMapping of selectedMappings) {
|
|
66
67
|
setCurrentlyImporting((_a = selectedMapping.mappingName) !== null && _a !== void 0 ? _a : "");
|
|
67
|
-
|
|
68
|
+
const accessToken = await getAccessToken();
|
|
69
|
+
await mappingClient.copyMapping(accessToken, sourceiModelId, (_b = selectedMapping.id) !== null && _b !== void 0 ? _b : "", {
|
|
68
70
|
targetIModelId: iModelId !== null && iModelId !== void 0 ? iModelId : "",
|
|
69
71
|
mappingName: (_c = selectedMapping.mappingName) !== null && _c !== void 0 ? _c : "",
|
|
70
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmMappingsImport.js","sourceRoot":"","sources":["../../../../src/widget/components/ConfirmMappingsImport.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAM8B;AAC9B,+CAA+D;AAE/D,wCAAsC;AACtC,oDAA+D;AAC/D,oEAAoE;AACpE,sEAAwE;AACxE,mCAAsC;AACtC,uDAAqE;AAarE,MAAM,oBAAoB,GAAG,CAAC,EAC5B,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,QAAQ,GACkB,EAAE,EAAE;;IAC9B,MAAM,QAAQ,GAAG,MAAA,uCAAyB,EAAE,0CAAE,QAAQ,CAAC;IACvD,MAAM,UAAU,GAAG,kBAA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qBAAqB;YAClC,8BAAC,sBAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,8BAAC,sBAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,aAE1D;YACT,8BAAC,sBAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Button,\n LabeledInput,\n MiddleTextTruncation,\n ProgressLinear,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useEffect, useState } from \"react\";\nimport type { MappingType } from \"./Mapping\";\nimport \"./ConfirmMappingsImport.scss\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SvgStatusSuccessHollow } from \"@itwin/itwinui-icons-react\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport { ApiContext, MappingClientContext } from \"./GroupingMapping\";\n\ninterface ConfirmMappingImportProps {\n sourceiModelId: string;\n selectedMappings: MappingType[];\n importing: boolean;\n setImporting: React.Dispatch<React.SetStateAction<boolean>>;\n setSelectedMappings: React.Dispatch<React.SetStateAction<MappingType[]>>;\n backFn: () => void;\n onCancel: () => void;\n onFinish: () => void;\n}\n\nconst ConfirmMappingImport = ({\n sourceiModelId,\n selectedMappings,\n importing,\n setImporting,\n setSelectedMappings,\n backFn,\n onCancel,\n onFinish,\n}: ConfirmMappingImportProps) => {\n const iModelId = useActiveIModelConnection()?.iModelId;\n const apiContext = useContext(ApiContext);\n const mappingClient = useContext(MappingClientContext);\n\n const [importCount, setImportCount] = useState<number>(0);\n const [currentlyImporting, setCurrentlyImporting] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [errored, setErrored] = useState<boolean>(false);\n\n useEffect(() => {\n setSelectedMappings((selectedMappings) =>\n selectedMappings.map((mapping) => ({\n ...mapping,\n mappingName: `${mapping.mappingName}_Copy`,\n })),\n );\n }, [setSelectedMappings]);\n\n const handleChange = (\n e: React.ChangeEvent<HTMLInputElement>,\n index: number,\n ) => {\n const newState = [...selectedMappings];\n newState[index] = {\n ...newState[index],\n mappingName: e.target.value,\n };\n setSelectedMappings(newState);\n };\n\n const onImport = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setImporting(true);\n try {\n for (const selectedMapping of selectedMappings) {\n setCurrentlyImporting(selectedMapping.mappingName ?? \"\");\n await mappingClient.copyMapping(\n apiContext.accessToken,\n sourceiModelId,\n selectedMapping.id ?? \"\",\n {\n targetIModelId: iModelId ?? \"\",\n mappingName: selectedMapping.mappingName ?? \"\",\n },\n );\n setImportCount((importCount) => importCount + 1);\n }\n } catch (error: any) {\n handleError(error);\n setErrored(true);\n }\n };\n\n return (\n <>\n {importing ? (\n <div className='import-progress-container'>\n <div className='import-progress-bar'>\n <div className='import-progress-bar-description'>\n {\n !errored ? importCount !== selectedMappings.length ? (\n <>\n <Text variant='title'>Importing</Text>\n <Text>We are currently importing the mappings.</Text>\n </>\n ) : (\n <>\n <Text variant='title'>Done!</Text>\n <Text>Your mapping(s) are ready.</Text>\n </>\n ) :\n <>\n <Text variant='title'>Error!</Text>\n <Text>Sorry, there was an error importing some or all mappings.</Text>\n </>}\n </div>\n <ProgressLinear\n value={(importCount / selectedMappings.length) * 100}\n labels={\n importCount === selectedMappings.length\n ? [\"Import done!\", <SvgStatusSuccessHollow key='0' />]\n : [\n <>\n <Text>Copying</Text>\n <MiddleTextTruncation text={currentlyImporting} />\n </>,\n `${importCount}/${selectedMappings.length}`,\n ]\n }\n status={\n !errored ?\n importCount === selectedMappings.length ? \"positive\" : undefined : \"negative\"\n }\n />\n </div>\n <div className='import-action-panel'>\n <Button\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => {\n setImporting(false);\n setImportCount(0);\n setCurrentlyImporting(\"\");\n setErrored(false);\n }}\n >\n Back\n </Button>\n <Button\n styleType='high-visibility'\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => onFinish()}\n >\n Close\n </Button>\n </div>\n </div>\n ) : (\n <div className='rename-confirm-container '>\n <div className='mapping-rename-container'>\n <div className='mapping-row-header-container'>\n <div className='mapping-row'>\n <Text variant='leading'>Mapping </Text>\n <Text variant='leading'>Description</Text>\n </div>\n </div>\n <div className='mapping-row-body'>\n {selectedMappings.map((mapping, index) => (\n <div className='mapping-row-container' key={mapping.id}>\n <div className='mapping-row'>\n <LabeledInput\n value={mapping.mappingName}\n name={`mapping_${mapping.id}`}\n required\n onChange={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n message={validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )}\n status={\n validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n onBlurCapture={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n />\n <div>{mapping.description}</div>\n </div>\n <div className='border-div' />\n </div>\n ))}\n </div>\n </div>\n <div className='import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button styleType='high-visibility' onClick={async () => onImport()}>\n Import\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport default ConfirmMappingImport;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfirmMappingsImport.js","sourceRoot":"","sources":["../../../../src/widget/components/ConfirmMappingsImport.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAM8B;AAC9B,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AAc,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,EACD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;4BACvB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;4BAC3B,SAAS,CAAC,cAAc,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,GACD;oBACF,2CAAM,OAAO,CAAC,WAAW,CAAO,CAC5B;gBACN,uCAAK,SAAS,EAAC,YAAY,GAAG,CAC1B,CACP,CAAC,CACE,CACF;QACN,uCAAK,SAAS,EAAC,qBAAqB;YAClC,8BAAC,sBAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,8BAAC,sBAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,aAE1D;YACT,8BAAC,sBAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Button,\n LabeledInput,\n MiddleTextTruncation,\n ProgressLinear,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport type { MappingType } from \"./Mapping\";\nimport \"./ConfirmMappingsImport.scss\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SvgStatusSuccessHollow } from \"@itwin/itwinui-icons-react\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\ninterface ConfirmMappingImportProps {\n sourceiModelId: string;\n selectedMappings: MappingType[];\n importing: boolean;\n setImporting: React.Dispatch<React.SetStateAction<boolean>>;\n setSelectedMappings: React.Dispatch<React.SetStateAction<MappingType[]>>;\n backFn: () => void;\n onCancel: () => void;\n onFinish: () => void;\n}\n\nconst ConfirmMappingImport = ({\n sourceiModelId,\n selectedMappings,\n importing,\n setImporting,\n setSelectedMappings,\n backFn,\n onCancel,\n onFinish,\n}: ConfirmMappingImportProps) => {\n const iModelId = useActiveIModelConnection()?.iModelId;\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n\n const [importCount, setImportCount] = useState<number>(0);\n const [currentlyImporting, setCurrentlyImporting] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [errored, setErrored] = useState<boolean>(false);\n\n useEffect(() => {\n setSelectedMappings((selectedMappings) =>\n selectedMappings.map((mapping) => ({\n ...mapping,\n mappingName: `${mapping.mappingName}_Copy`,\n })),\n );\n }, [setSelectedMappings]);\n\n const handleChange = (\n e: React.ChangeEvent<HTMLInputElement>,\n index: number,\n ) => {\n const newState = [...selectedMappings];\n newState[index] = {\n ...newState[index],\n mappingName: e.target.value,\n };\n setSelectedMappings(newState);\n };\n\n const onImport = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setImporting(true);\n try {\n for (const selectedMapping of selectedMappings) {\n setCurrentlyImporting(selectedMapping.mappingName ?? \"\");\n const accessToken = await getAccessToken();\n await mappingClient.copyMapping(\n accessToken,\n sourceiModelId,\n selectedMapping.id ?? \"\",\n {\n targetIModelId: iModelId ?? \"\",\n mappingName: selectedMapping.mappingName ?? \"\",\n },\n );\n setImportCount((importCount) => importCount + 1);\n }\n } catch (error: any) {\n handleError(error);\n setErrored(true);\n }\n };\n\n return (\n <>\n {importing ? (\n <div className='import-progress-container'>\n <div className='import-progress-bar'>\n <div className='import-progress-bar-description'>\n {\n !errored ? importCount !== selectedMappings.length ? (\n <>\n <Text variant='title'>Importing</Text>\n <Text>We are currently importing the mappings.</Text>\n </>\n ) : (\n <>\n <Text variant='title'>Done!</Text>\n <Text>Your mapping(s) are ready.</Text>\n </>\n ) :\n <>\n <Text variant='title'>Error!</Text>\n <Text>Sorry, there was an error importing some or all mappings.</Text>\n </>}\n </div>\n <ProgressLinear\n value={(importCount / selectedMappings.length) * 100}\n labels={\n importCount === selectedMappings.length\n ? [\"Import done!\", <SvgStatusSuccessHollow key='0' />]\n : [\n <>\n <Text>Copying</Text>\n <MiddleTextTruncation text={currentlyImporting} />\n </>,\n `${importCount}/${selectedMappings.length}`,\n ]\n }\n status={\n !errored ?\n importCount === selectedMappings.length ? \"positive\" : undefined : \"negative\"\n }\n />\n </div>\n <div className='import-action-panel'>\n <Button\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => {\n setImporting(false);\n setImportCount(0);\n setCurrentlyImporting(\"\");\n setErrored(false);\n }}\n >\n Back\n </Button>\n <Button\n styleType='high-visibility'\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => onFinish()}\n >\n Close\n </Button>\n </div>\n </div>\n ) : (\n <div className='rename-confirm-container '>\n <div className='mapping-rename-container'>\n <div className='mapping-row-header-container'>\n <div className='mapping-row'>\n <Text variant='leading'>Mapping </Text>\n <Text variant='leading'>Description</Text>\n </div>\n </div>\n <div className='mapping-row-body'>\n {selectedMappings.map((mapping, index) => (\n <div className='mapping-row-container' key={mapping.id}>\n <div className='mapping-row'>\n <LabeledInput\n value={mapping.mappingName}\n name={`mapping_${mapping.id}`}\n required\n onChange={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n message={validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )}\n status={\n validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n onBlurCapture={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n />\n <div>{mapping.description}</div>\n </div>\n <div className='border-div' />\n </div>\n ))}\n </div>\n </div>\n <div className='import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button styleType='high-visibility' onClick={async () => onImport()}>\n Import\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport default ConfirmMappingImport;\n"]}
|