@finos/legend-query-builder 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryBuilderConstantExpressionPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderConstantExpressionPanel.js +24 -14
- package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
- package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderParametersPanel.js +26 -15
- package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +1 -1
- package/package.json +8 -8
- package/src/components/QueryBuilderConstantExpressionPanel.tsx +35 -18
- package/src/components/QueryBuilderParametersPanel.tsx +38 -23
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderConstantExpressionPanel.d.ts","sourceRoot":"","sources":["../../src/components/QueryBuilderConstantExpressionPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;
|
1
|
+
{"version":3,"file":"QueryBuilderConstantExpressionPanel.d.ts","sourceRoot":"","sources":["../../src/components/QueryBuilderConstantExpressionPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAgCH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAsKxE,eAAO,MAAM,mCAAmC,WACtC;IAAE,iBAAiB,EAAE,iBAAiB,CAAA;CAAE;;CAsGjD,CAAC"}
|
@@ -15,18 +15,19 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
15
15
|
* limitations under the License.
|
16
16
|
*/
|
17
17
|
import { buildElementOption, getPackageableElementOptionFormatter, } from '@finos/legend-lego/graph-editor';
|
18
|
-
import { BlankPanelPlaceholder, CustomSelectorInput, Dialog, InfoCircleIcon, Modal, ModalBody, ModalFooter, ModalFooterButton, ModalHeader, PanelFormSection,
|
19
|
-
import { PrimitiveType, VariableExpression, Multiplicity, } from '@finos/legend-graph';
|
18
|
+
import { BlankPanelPlaceholder, CustomSelectorInput, Dialog, InfoCircleIcon, Modal, ModalBody, ModalFooter, ModalFooterButton, ModalHeader, PanelFormSection, PanelFormValidatedTextField, PlusIcon, } from '@finos/legend-art';
|
19
|
+
import { PrimitiveType, VariableExpression, Multiplicity, isValidIdentifier, } from '@finos/legend-graph';
|
20
20
|
import { generateEnumerableNameFromToken } from '@finos/legend-shared';
|
21
21
|
import { observer } from 'mobx-react-lite';
|
22
22
|
import { DEFAULT_CONSTANT_VARIABLE_NAME } from '../stores/QueryBuilderConfig.js';
|
23
23
|
import { QueryBuilderConstantExpressionState } from '../stores/QueryBuilderConstantsState.js';
|
24
24
|
import { buildDefaultInstanceValue } from '../stores/shared/ValueSpecificationEditorHelper.js';
|
25
|
-
import { variableExpression_setName } from '../stores/shared/ValueSpecificationModifierHelper.js';
|
26
25
|
import { BasicValueSpecificationEditor } from './shared/BasicValueSpecificationEditor.js';
|
27
26
|
import { VariableViewer } from './shared/QueryBuilderVariableSelector.js';
|
28
27
|
import { QUERY_BUILDER_TEST_ID } from '../__lib__/QueryBuilderTesting.js';
|
29
28
|
import { QUERY_BUILDER_DOCUMENTATION_KEY } from '../__lib__/QueryBuilderDocumentation.js';
|
29
|
+
import { useState } from 'react';
|
30
|
+
import { variableExpression_setName } from '../stores/shared/ValueSpecificationModifierHelper.js';
|
30
31
|
// NOTE: We currently only allow constant variables for primitive types of multiplicity ONE.
|
31
32
|
// This is why we don't show multiplicity in the editor.
|
32
33
|
const QueryBuilderConstantExpressionEditor = observer((props) => {
|
@@ -41,9 +42,6 @@ const QueryBuilderConstantExpressionEditor = observer((props) => {
|
|
41
42
|
const valueSpec = constantState.value;
|
42
43
|
const variableType = constantState.value.genericType?.value.rawType ?? PrimitiveType.STRING;
|
43
44
|
const selectedType = buildElementOption(variableType);
|
44
|
-
const close = () => {
|
45
|
-
variableState.setSelectedConstant(undefined);
|
46
|
-
};
|
47
45
|
const changeType = (val) => {
|
48
46
|
if (variableType !== val.value) {
|
49
47
|
constantState.changeValSpecType(val.value);
|
@@ -52,12 +50,22 @@ const QueryBuilderConstantExpressionEditor = observer((props) => {
|
|
52
50
|
const typeOptions = queryBuilderState.graphManagerState.graph.primitiveTypes
|
53
51
|
.map(buildElementOption)
|
54
52
|
.concat(queryBuilderState.graphManagerState.graph.enumerations.map(buildElementOption));
|
55
|
-
const
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
const [hasFailedValidation, setFailedValidation] = useState(false);
|
54
|
+
const getValidationMessage = (constantInput) => {
|
55
|
+
const possibleMessage = !constantInput
|
56
|
+
? `Constant Name can't be empty`
|
57
|
+
: isValidIdentifier(constantInput) === false
|
58
|
+
? 'Constant name must be text with no spaces and not start with an uppercase letter or number'
|
59
|
+
: allVariableNames.filter((e) => e === constantInput).length >
|
60
|
+
(isCreating ? 0 : 1)
|
61
|
+
? 'Constant name already exists'
|
62
|
+
: undefined;
|
63
|
+
setFailedValidation(possibleMessage !== undefined);
|
64
|
+
return possibleMessage;
|
65
|
+
};
|
66
|
+
const close = () => {
|
67
|
+
variableState.setSelectedConstant(undefined);
|
68
|
+
};
|
61
69
|
const onAction = () => {
|
62
70
|
if (isCreating) {
|
63
71
|
variableState.addConstant(constantState);
|
@@ -72,7 +80,9 @@ const QueryBuilderConstantExpressionEditor = observer((props) => {
|
|
72
80
|
root: 'editor-modal__root-container',
|
73
81
|
container: 'editor-modal__container',
|
74
82
|
paper: 'editor-modal__content',
|
75
|
-
}, children: _jsxs(Modal, { darkMode: true, className: "editor-modal query-builder__variables__modal", children: [_jsx(ModalHeader, { title: `${isCreating ? 'Create Constant' : 'Update Constant'}` }), _jsxs(ModalBody, { className: "query-builder__variables__modal__body", children: [_jsx(
|
83
|
+
}, children: _jsxs(Modal, { darkMode: true, className: "editor-modal query-builder__variables__modal", children: [_jsx(ModalHeader, { title: `${isCreating ? 'Create Constant' : 'Update Constant'}` }), _jsxs(ModalBody, { className: "query-builder__variables__modal__body", children: [_jsx(PanelFormValidatedTextField, { name: "Constant Name", prompt: "Name of constant. Should be descriptive of its purpose.", update: (value) => {
|
84
|
+
variableExpression_setName(varExpression, value ?? '');
|
85
|
+
}, validateInput: getValidationMessage, value: variableName, isReadOnly: false }), _jsxs(PanelFormSection, { children: [_jsx("div", { className: "panel__content__form__section__header__label", children: "Type" }), _jsx("div", { className: "panel__content__form__section__header__prompt", children: "Data type of the constant." }), _jsx(CustomSelectorInput, { placeholder: "Choose a type...", options: typeOptions, onChange: changeType, value: selectedType, darkMode: !applicationStore.layoutService
|
76
86
|
.TEMPORARY__isLightColorThemeEnabled, formatOptionLabel: getPackageableElementOptionFormatter({
|
77
87
|
darkMode: !applicationStore.layoutService
|
78
88
|
.TEMPORARY__isLightColorThemeEnabled,
|
@@ -81,7 +91,7 @@ const QueryBuilderConstantExpressionEditor = observer((props) => {
|
|
81
91
|
}, graph: queryBuilderState.graphManagerState.graph, obseverContext: queryBuilderState.observerContext, typeCheckOption: {
|
82
92
|
expectedType: variableType,
|
83
93
|
match: variableType === PrimitiveType.DATETIME,
|
84
|
-
}, resetValue: resetConstantValue }) })] })] }), _jsxs(ModalFooter, { children: [isCreating && (_jsx(ModalFooterButton, { text: "Create", inProgress:
|
94
|
+
}, resetValue: resetConstantValue }) })] })] }), _jsxs(ModalFooter, { children: [isCreating && (_jsx(ModalFooterButton, { text: "Create", inProgress: hasFailedValidation, onClick: onAction })), _jsx(ModalFooterButton, { text: "Close", onClick: close })] })] }) }));
|
85
95
|
});
|
86
96
|
export const QueryBuilderConstantExpressionPanel = observer((props) => {
|
87
97
|
const { queryBuilderState } = props;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderConstantExpressionPanel.js","sourceRoot":"","sources":["../../src/components/QueryBuilderConstantExpressionPanel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,kBAAkB,EAClB,oCAAoC,GAErC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,EACN,cAAc,EACd,KAAK,EACL,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,
|
1
|
+
{"version":3,"file":"QueryBuilderConstantExpressionPanel.js","sourceRoot":"","sources":["../../src/components/QueryBuilderConstantExpressionPanel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,kBAAkB,EAClB,oCAAoC,GAErC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,EACN,cAAc,EACd,KAAK,EACL,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,2BAA2B,EAC3B,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,mCAAmC,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,oDAAoD,CAAC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sDAAsD,CAAC;AAElG,4FAA4F;AAC5F,wDAAwD;AACxD,MA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,CAWpB,CACH,CAAC,EACH,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,IAAI,CAClC,KAAC,qBAAqB,IACpB,IAAI,EAAC,gBAAgB,EACrB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,WAAW,EACpB,eAAe,EAAC,KAAK,EACrB,WAAW,EAAC,cAAc,EAC1B,WAAW,EAAC,6BAA6B,GACzC,CACH,IACA,GACC,EACL,aAAa,CAAC,gBAAgB,IAAI,CACjC,KAAC,oCAAoC,IACnC,aAAa,EAAE,aAAa,CAAC,gBAAgB,GAC7C,CACH,IACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderParametersPanel.d.ts","sourceRoot":"","sources":["../../src/components/QueryBuilderParametersPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;
|
1
|
+
{"version":3,"file":"QueryBuilderParametersPanel.d.ts","sourceRoot":"","sources":["../../src/components/QueryBuilderParametersPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAkOxE,eAAO,MAAM,2BAA2B,WAC9B;IAAE,iBAAiB,EAAE,iBAAiB,CAAA;CAAE;;CA4GjD,CAAC"}
|
@@ -15,8 +15,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
15
15
|
* limitations under the License.
|
16
16
|
*/
|
17
17
|
import { observer } from 'mobx-react-lite';
|
18
|
-
import { Dialog, BlankPanelContent, CustomSelectorInput, PlusIcon, BlankPanelPlaceholder, Modal, ModalBody, ModalFooter, ModalHeader,
|
19
|
-
import { VariableExpression, GenericTypeExplicitReference, GenericType, PrimitiveType, Multiplicity, getMultiplicityPrettyDescription, } from '@finos/legend-graph';
|
18
|
+
import { Dialog, BlankPanelContent, CustomSelectorInput, PlusIcon, BlankPanelPlaceholder, Modal, ModalBody, ModalFooter, ModalHeader, InfoCircleIcon, ModalFooterButton, PanelFormValidatedTextField, } from '@finos/legend-art';
|
19
|
+
import { VariableExpression, GenericTypeExplicitReference, GenericType, PrimitiveType, Multiplicity, getMultiplicityPrettyDescription, isValidIdentifier, } from '@finos/legend-graph';
|
20
20
|
import { useApplicationStore } from '@finos/legend-application';
|
21
21
|
import { generateEnumerableNameFromToken } from '@finos/legend-shared';
|
22
22
|
import { DEFAULT_VARIABLE_NAME } from '../stores/QueryBuilderConfig.js';
|
@@ -26,6 +26,7 @@ import { LambdaParameterValuesEditor } from './shared/LambdaParameterValuesEdito
|
|
26
26
|
import { VariableViewer } from './shared/QueryBuilderVariableSelector.js';
|
27
27
|
import { QUERY_BUILDER_TEST_ID } from '../__lib__/QueryBuilderTesting.js';
|
28
28
|
import { QUERY_BUILDER_DOCUMENTATION_KEY } from '../__lib__/QueryBuilderDocumentation.js';
|
29
|
+
import { useState } from 'react';
|
29
30
|
import { buildElementOption, getPackageableElementOptionFormatter, } from '@finos/legend-lego/graph-editor';
|
30
31
|
const buildMultiplicityOption = (multiplicity) => ({
|
31
32
|
label: getMultiplicityPrettyDescription(multiplicity),
|
@@ -40,17 +41,6 @@ const VariableExpressionEditor = observer((props) => {
|
|
40
41
|
const isCreating = !queryParametersState.parameterStates.includes(lambdaParameterState);
|
41
42
|
const varState = lambdaParameterState.parameter;
|
42
43
|
const multiplity = varState.multiplicity;
|
43
|
-
const validationMessage = !varState.name
|
44
|
-
? `Parameter name can't be empty`
|
45
|
-
: allVariableNames.filter((e) => e === varState.name).length >
|
46
|
-
(isCreating ? 0 : 1)
|
47
|
-
? 'Parameter Name Already Exists'
|
48
|
-
: (isCreating &&
|
49
|
-
queryParametersState.parameterStates.find((p) => p.parameter.name === varState.name)) ||
|
50
|
-
(!isCreating &&
|
51
|
-
queryParametersState.parameterStates.filter((p) => p.parameter.name === varState.name).length > 1)
|
52
|
-
? 'Parameter name already exists'
|
53
|
-
: undefined;
|
54
44
|
// type
|
55
45
|
const variableType = lambdaParameterState.variableType ?? PrimitiveType.STRING;
|
56
46
|
const selectedType = buildElementOption(variableType);
|
@@ -73,6 +63,25 @@ const VariableExpressionEditor = observer((props) => {
|
|
73
63
|
const changeMultiplicity = (val) => {
|
74
64
|
lambdaParameterState.changeMultiplicity(varState, val.value);
|
75
65
|
};
|
66
|
+
const parameterNameValue = varState.name;
|
67
|
+
const [hasFailedValidation, setFailedValidation] = useState(false);
|
68
|
+
const getValidationMessage = (input) => {
|
69
|
+
const possibleMessage = !input
|
70
|
+
? `Parameter name can't be empty`
|
71
|
+
: allVariableNames.filter((e) => e === input).length >
|
72
|
+
(isCreating ? 0 : 1)
|
73
|
+
? 'Parameter name already exists'
|
74
|
+
: (isCreating &&
|
75
|
+
queryParametersState.parameterStates.find((p) => p.parameter.name === input)) ||
|
76
|
+
(!isCreating &&
|
77
|
+
queryParametersState.parameterStates.filter((p) => p.parameter.name === input).length > 1)
|
78
|
+
? 'Parameter name already exists'
|
79
|
+
: isValidIdentifier(input, true) === false
|
80
|
+
? 'Parameter name must be text with no spaces and not start with an uppercase letter or number'
|
81
|
+
: undefined;
|
82
|
+
setFailedValidation(possibleMessage !== undefined);
|
83
|
+
return possibleMessage;
|
84
|
+
};
|
76
85
|
const close = () => {
|
77
86
|
queryParametersState.setSelectedParameter(undefined);
|
78
87
|
};
|
@@ -86,12 +95,14 @@ const VariableExpressionEditor = observer((props) => {
|
|
86
95
|
root: 'editor-modal__root-container',
|
87
96
|
container: 'editor-modal__container',
|
88
97
|
paper: 'editor-modal__content',
|
89
|
-
}, children: _jsxs(Modal, { darkMode: true, className: "editor-modal query-builder__variables__modal", children: [_jsx(ModalHeader, { title: `${isCreating ? 'Create Parameter' : 'Update Parameter'}` }), _jsxs(ModalBody, { className: "query-builder__variables__modal__body", children: [_jsx(
|
98
|
+
}, children: _jsxs(Modal, { darkMode: true, className: "editor-modal query-builder__variables__modal", children: [_jsx(ModalHeader, { title: `${isCreating ? 'Create Parameter' : 'Update Parameter'}` }), _jsxs(ModalBody, { className: "query-builder__variables__modal__body", children: [_jsx(PanelFormValidatedTextField, { name: "Parameter Name", prompt: "Name of the parameter. Should be descriptive of its purpose.", value: parameterNameValue, validateInput: getValidationMessage, update: (value) => {
|
99
|
+
variableExpression_setName(varState, value ?? '');
|
100
|
+
}, isReadOnly: false }), _jsxs("div", { className: "panel__content__form__section", children: [_jsx("div", { className: "panel__content__form__section__header__label", children: "Type" }), _jsx("div", { className: "panel__content__form__section__header__prompt", children: "Data type of the parameter." }), _jsx(CustomSelectorInput, { placeholder: "Choose a type...", options: typeOptions, onChange: changeType, value: selectedType, darkMode: !applicationStore.layoutService
|
90
101
|
.TEMPORARY__isLightColorThemeEnabled, formatOptionLabel: getPackageableElementOptionFormatter({
|
91
102
|
darkMode: !applicationStore.layoutService
|
92
103
|
.TEMPORARY__isLightColorThemeEnabled,
|
93
104
|
}) })] }), _jsxs("div", { className: "panel__content__form__section", children: [_jsx("div", { className: "panel__content__form__section__header__label", children: "Multiplicity" }), _jsx("div", { className: "panel__content__form__section__header__prompt", children: "The multiplity determines how many values a parameter can have. Default is set to mandatory single vlue." }), _jsx(CustomSelectorInput, { placeholder: "Choose a multiplicity...", options: multilicityOptions, onChange: changeMultiplicity, value: selectedMultiplicity, hasError: !validParamMultiplicityList.includes(selectedMultiplicity.value), darkMode: !applicationStore.layoutService
|
94
|
-
.TEMPORARY__isLightColorThemeEnabled })] })] }), _jsxs(ModalFooter, { children: [isCreating && (_jsx(ModalFooterButton, { text: "Create", inProgress:
|
105
|
+
.TEMPORARY__isLightColorThemeEnabled })] })] }), _jsxs(ModalFooter, { children: [isCreating && (_jsx(ModalFooterButton, { text: "Create", inProgress: hasFailedValidation, onClick: onAction })), _jsx(ModalFooterButton, { onClick: close, text: "Close" })] })] }) }));
|
95
106
|
});
|
96
107
|
export const QueryBuilderParametersPanel = observer((props) => {
|
97
108
|
const { queryBuilderState } = props;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderParametersPanel.js","sourceRoot":"","sources":["../../src/components/QueryBuilderParametersPanel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,EACrB,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,
|
1
|
+
{"version":3,"file":"QueryBuilderParametersPanel.js","sourceRoot":"","sources":["../../src/components/QueryBuilderParametersPanel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,EACrB,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,kBAAkB,EAClB,4BAA4B,EAC5B,WAAW,EACX,aAAa,EACb,YAAY,EACZ,gCAAgC,EAChC,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sDAAsD,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;A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CAAiD,CACpE,IACG,EACL,mBAAmB,CAAC,iBAAiB,IAAI,CACxC,KAAC,wBAAwB,IACvB,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,mBAAmB,CAAC,iBAAiB,GAC3D,CACH,EACA,mBAAmB,CAAC,0BAA0B,CAAC,SAAS,IAAI,CAC3D,KAAC,2BAA2B,IAC1B,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,EAChD,eAAe,EAAE,iBAAiB,CAAC,eAAe,EAClD,qBAAqB,EAAE,mBAAmB,GAC1C,CACH,IACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
package/lib/index.css
CHANGED
package/lib/package.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@finos/legend-query-builder",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.6",
|
4
4
|
"description": "Legend query builder core",
|
5
5
|
"keywords": [
|
6
6
|
"legend",
|
@@ -42,13 +42,13 @@
|
|
42
42
|
"test:watch": "jest --watch"
|
43
43
|
},
|
44
44
|
"dependencies": {
|
45
|
-
"@finos/legend-application": "15.0.
|
46
|
-
"@finos/legend-art": "7.0.
|
47
|
-
"@finos/legend-graph": "28.0
|
48
|
-
"@finos/legend-lego": "0.1.
|
49
|
-
"@finos/legend-server-depot": "6.0.
|
50
|
-
"@finos/legend-shared": "10.0.
|
51
|
-
"@finos/legend-storage": "3.0.
|
45
|
+
"@finos/legend-application": "15.0.3",
|
46
|
+
"@finos/legend-art": "7.0.4",
|
47
|
+
"@finos/legend-graph": "28.1.0",
|
48
|
+
"@finos/legend-lego": "0.1.9",
|
49
|
+
"@finos/legend-server-depot": "6.0.1",
|
50
|
+
"@finos/legend-shared": "10.0.1",
|
51
|
+
"@finos/legend-storage": "3.0.51",
|
52
52
|
"@testing-library/react": "14.0.0",
|
53
53
|
"@types/react": "18.0.37",
|
54
54
|
"@types/react-dom": "18.0.11",
|
@@ -30,7 +30,7 @@ import {
|
|
30
30
|
ModalFooterButton,
|
31
31
|
ModalHeader,
|
32
32
|
PanelFormSection,
|
33
|
-
|
33
|
+
PanelFormValidatedTextField,
|
34
34
|
PlusIcon,
|
35
35
|
} from '@finos/legend-art';
|
36
36
|
import {
|
@@ -39,6 +39,7 @@ import {
|
|
39
39
|
PrimitiveType,
|
40
40
|
VariableExpression,
|
41
41
|
Multiplicity,
|
42
|
+
isValidIdentifier,
|
42
43
|
} from '@finos/legend-graph';
|
43
44
|
import { generateEnumerableNameFromToken } from '@finos/legend-shared';
|
44
45
|
import { observer } from 'mobx-react-lite';
|
@@ -46,11 +47,12 @@ import { DEFAULT_CONSTANT_VARIABLE_NAME } from '../stores/QueryBuilderConfig.js'
|
|
46
47
|
import type { QueryBuilderState } from '../stores/QueryBuilderState.js';
|
47
48
|
import { QueryBuilderConstantExpressionState } from '../stores/QueryBuilderConstantsState.js';
|
48
49
|
import { buildDefaultInstanceValue } from '../stores/shared/ValueSpecificationEditorHelper.js';
|
49
|
-
import { variableExpression_setName } from '../stores/shared/ValueSpecificationModifierHelper.js';
|
50
50
|
import { BasicValueSpecificationEditor } from './shared/BasicValueSpecificationEditor.js';
|
51
51
|
import { VariableViewer } from './shared/QueryBuilderVariableSelector.js';
|
52
52
|
import { QUERY_BUILDER_TEST_ID } from '../__lib__/QueryBuilderTesting.js';
|
53
53
|
import { QUERY_BUILDER_DOCUMENTATION_KEY } from '../__lib__/QueryBuilderDocumentation.js';
|
54
|
+
import { useState } from 'react';
|
55
|
+
import { variableExpression_setName } from '../stores/shared/ValueSpecificationModifierHelper.js';
|
54
56
|
|
55
57
|
// NOTE: We currently only allow constant variables for primitive types of multiplicity ONE.
|
56
58
|
// This is why we don't show multiplicity in the editor.
|
@@ -68,9 +70,7 @@ const QueryBuilderConstantExpressionEditor = observer(
|
|
68
70
|
const variableType =
|
69
71
|
constantState.value.genericType?.value.rawType ?? PrimitiveType.STRING;
|
70
72
|
const selectedType = buildElementOption(variableType);
|
71
|
-
|
72
|
-
variableState.setSelectedConstant(undefined);
|
73
|
-
};
|
73
|
+
|
74
74
|
const changeType = (val: PackageableElementOption<Type>): void => {
|
75
75
|
if (variableType !== val.value) {
|
76
76
|
constantState.changeValSpecType(val.value);
|
@@ -84,12 +84,29 @@ const QueryBuilderConstantExpressionEditor = observer(
|
|
84
84
|
buildElementOption,
|
85
85
|
),
|
86
86
|
);
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
87
|
+
|
88
|
+
const [hasFailedValidation, setFailedValidation] = useState<boolean>(false);
|
89
|
+
|
90
|
+
const getValidationMessage = (
|
91
|
+
constantInput: string,
|
92
|
+
): string | undefined => {
|
93
|
+
const possibleMessage = !constantInput
|
94
|
+
? `Constant Name can't be empty`
|
95
|
+
: isValidIdentifier(constantInput) === false
|
96
|
+
? 'Constant name must be text with no spaces and not start with an uppercase letter or number'
|
97
|
+
: allVariableNames.filter((e) => e === constantInput).length >
|
98
|
+
(isCreating ? 0 : 1)
|
99
|
+
? 'Constant name already exists'
|
100
|
+
: undefined;
|
101
|
+
|
102
|
+
setFailedValidation(possibleMessage !== undefined);
|
103
|
+
return possibleMessage;
|
104
|
+
};
|
105
|
+
|
106
|
+
const close = (): void => {
|
107
|
+
variableState.setSelectedConstant(undefined);
|
108
|
+
};
|
109
|
+
|
93
110
|
const onAction = (): void => {
|
94
111
|
if (isCreating) {
|
95
112
|
variableState.addConstant(constantState);
|
@@ -123,14 +140,14 @@ const QueryBuilderConstantExpressionEditor = observer(
|
|
123
140
|
title={`${isCreating ? 'Create Constant' : 'Update Constant'}`}
|
124
141
|
/>
|
125
142
|
<ModalBody className="query-builder__variables__modal__body">
|
126
|
-
<
|
143
|
+
<PanelFormValidatedTextField
|
127
144
|
name="Constant Name"
|
128
145
|
prompt="Name of constant. Should be descriptive of its purpose."
|
129
|
-
update={(value: string | undefined): void =>
|
130
|
-
variableExpression_setName(varExpression, value ?? '')
|
131
|
-
}
|
132
|
-
|
133
|
-
|
146
|
+
update={(value: string | undefined): void => {
|
147
|
+
variableExpression_setName(varExpression, value ?? '');
|
148
|
+
}}
|
149
|
+
validateInput={getValidationMessage}
|
150
|
+
value={variableName}
|
134
151
|
isReadOnly={false}
|
135
152
|
/>
|
136
153
|
<PanelFormSection>
|
@@ -181,7 +198,7 @@ const QueryBuilderConstantExpressionEditor = observer(
|
|
181
198
|
{isCreating && (
|
182
199
|
<ModalFooterButton
|
183
200
|
text="Create"
|
184
|
-
inProgress={
|
201
|
+
inProgress={hasFailedValidation}
|
185
202
|
onClick={onAction}
|
186
203
|
/>
|
187
204
|
)}
|
@@ -26,9 +26,9 @@ import {
|
|
26
26
|
ModalBody,
|
27
27
|
ModalFooter,
|
28
28
|
ModalHeader,
|
29
|
-
PanelFormTextField,
|
30
29
|
InfoCircleIcon,
|
31
30
|
ModalFooterButton,
|
31
|
+
PanelFormValidatedTextField,
|
32
32
|
} from '@finos/legend-art';
|
33
33
|
import {
|
34
34
|
type Type,
|
@@ -38,6 +38,7 @@ import {
|
|
38
38
|
PrimitiveType,
|
39
39
|
Multiplicity,
|
40
40
|
getMultiplicityPrettyDescription,
|
41
|
+
isValidIdentifier,
|
41
42
|
} from '@finos/legend-graph';
|
42
43
|
import { useApplicationStore } from '@finos/legend-application';
|
43
44
|
import { generateEnumerableNameFromToken } from '@finos/legend-shared';
|
@@ -48,6 +49,7 @@ import { LambdaParameterValuesEditor } from './shared/LambdaParameterValuesEdito
|
|
48
49
|
import { VariableViewer } from './shared/QueryBuilderVariableSelector.js';
|
49
50
|
import { QUERY_BUILDER_TEST_ID } from '../__lib__/QueryBuilderTesting.js';
|
50
51
|
import { QUERY_BUILDER_DOCUMENTATION_KEY } from '../__lib__/QueryBuilderDocumentation.js';
|
52
|
+
import { useState } from 'react';
|
51
53
|
import {
|
52
54
|
buildElementOption,
|
53
55
|
getPackageableElementOptionFormatter,
|
@@ -77,21 +79,6 @@ const VariableExpressionEditor = observer(
|
|
77
79
|
!queryParametersState.parameterStates.includes(lambdaParameterState);
|
78
80
|
const varState = lambdaParameterState.parameter;
|
79
81
|
const multiplity = varState.multiplicity;
|
80
|
-
const validationMessage = !varState.name
|
81
|
-
? `Parameter name can't be empty`
|
82
|
-
: allVariableNames.filter((e) => e === varState.name).length >
|
83
|
-
(isCreating ? 0 : 1)
|
84
|
-
? 'Parameter Name Already Exists'
|
85
|
-
: (isCreating &&
|
86
|
-
queryParametersState.parameterStates.find(
|
87
|
-
(p) => p.parameter.name === varState.name,
|
88
|
-
)) ||
|
89
|
-
(!isCreating &&
|
90
|
-
queryParametersState.parameterStates.filter(
|
91
|
-
(p) => p.parameter.name === varState.name,
|
92
|
-
).length > 1)
|
93
|
-
? 'Parameter name already exists'
|
94
|
-
: undefined;
|
95
82
|
|
96
83
|
// type
|
97
84
|
const variableType =
|
@@ -124,6 +111,34 @@ const VariableExpressionEditor = observer(
|
|
124
111
|
lambdaParameterState.changeMultiplicity(varState, val.value);
|
125
112
|
};
|
126
113
|
|
114
|
+
const parameterNameValue = varState.name;
|
115
|
+
|
116
|
+
const [hasFailedValidation, setFailedValidation] = useState<boolean>(false);
|
117
|
+
|
118
|
+
const getValidationMessage = (input: string): string | undefined => {
|
119
|
+
const possibleMessage = !input
|
120
|
+
? `Parameter name can't be empty`
|
121
|
+
: allVariableNames.filter((e) => e === input).length >
|
122
|
+
(isCreating ? 0 : 1)
|
123
|
+
? 'Parameter name already exists'
|
124
|
+
: (isCreating &&
|
125
|
+
queryParametersState.parameterStates.find(
|
126
|
+
(p) => p.parameter.name === input,
|
127
|
+
)) ||
|
128
|
+
(!isCreating &&
|
129
|
+
queryParametersState.parameterStates.filter(
|
130
|
+
(p) => p.parameter.name === input,
|
131
|
+
).length > 1)
|
132
|
+
? 'Parameter name already exists'
|
133
|
+
: isValidIdentifier(input, true) === false
|
134
|
+
? 'Parameter name must be text with no spaces and not start with an uppercase letter or number'
|
135
|
+
: undefined;
|
136
|
+
|
137
|
+
setFailedValidation(possibleMessage !== undefined);
|
138
|
+
|
139
|
+
return possibleMessage;
|
140
|
+
};
|
141
|
+
|
127
142
|
const close = (): void => {
|
128
143
|
queryParametersState.setSelectedParameter(undefined);
|
129
144
|
};
|
@@ -152,14 +167,14 @@ const VariableExpressionEditor = observer(
|
|
152
167
|
title={`${isCreating ? 'Create Parameter' : 'Update Parameter'}`}
|
153
168
|
/>
|
154
169
|
<ModalBody className="query-builder__variables__modal__body">
|
155
|
-
<
|
170
|
+
<PanelFormValidatedTextField
|
156
171
|
name="Parameter Name"
|
157
172
|
prompt="Name of the parameter. Should be descriptive of its purpose."
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
173
|
+
value={parameterNameValue}
|
174
|
+
validateInput={getValidationMessage}
|
175
|
+
update={(value: string | undefined): void => {
|
176
|
+
variableExpression_setName(varState, value ?? '');
|
177
|
+
}}
|
163
178
|
isReadOnly={false}
|
164
179
|
/>
|
165
180
|
<div className="panel__content__form__section">
|
@@ -214,7 +229,7 @@ const VariableExpressionEditor = observer(
|
|
214
229
|
{isCreating && (
|
215
230
|
<ModalFooterButton
|
216
231
|
text="Create"
|
217
|
-
inProgress={
|
232
|
+
inProgress={hasFailedValidation}
|
218
233
|
onClick={onAction}
|
219
234
|
/>
|
220
235
|
)}
|