@finos/legend-query-builder 4.13.8 → 4.13.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/lib/__lib__/QueryBuilderTesting.d.ts +1 -0
  2. package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderTesting.js +1 -0
  4. package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
  5. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  6. package/lib/components/filter/QueryBuilderFilterPanel.js +1 -1
  7. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  8. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  9. package/lib/components/result/QueryBuilderResultPanel.js +3 -3
  10. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  11. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts +1 -1
  12. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
  13. package/lib/components/result/tds/QueryBuilderTDSResultShared.js +3 -2
  14. package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
  15. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  16. package/lib/components/shared/BasicValueSpecificationEditor.js +7 -1
  17. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  18. package/lib/components/shared/CustomDatePicker.js +14 -14
  19. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  20. package/lib/graph/QueryBuilderMetaModelConst.d.ts +4 -2
  21. package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
  22. package/lib/graph/QueryBuilderMetaModelConst.js +4 -2
  23. package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
  24. package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.d.ts.map +1 -1
  25. package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js +2 -0
  26. package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
  27. package/lib/index.css +2 -2
  28. package/lib/index.css.map +1 -1
  29. package/lib/package.json +1 -1
  30. package/lib/stores/QueryBuilderStateBuilder.d.ts +2 -1
  31. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  32. package/lib/stores/QueryBuilderStateBuilder.js +28 -1
  33. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  34. package/package.json +8 -8
  35. package/src/__lib__/QueryBuilderTesting.ts +1 -0
  36. package/src/components/filter/QueryBuilderFilterPanel.tsx +3 -0
  37. package/src/components/result/QueryBuilderResultPanel.tsx +3 -6
  38. package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +3 -1
  39. package/src/components/shared/BasicValueSpecificationEditor.tsx +16 -11
  40. package/src/components/shared/CustomDatePicker.tsx +15 -15
  41. package/src/graph/QueryBuilderMetaModelConst.ts +4 -2
  42. package/src/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +2 -0
  43. package/src/stores/QueryBuilderStateBuilder.ts +54 -12
@@ -26,25 +26,25 @@ import {
26
26
  } from '@finos/legend-shared';
27
27
  import type { QueryBuilderState } from './QueryBuilderState.js';
28
28
  import {
29
+ type AbstractPropertyExpression,
29
30
  type EnumValueInstanceValue,
30
31
  type FunctionExpression,
31
32
  type GraphFetchTreeInstanceValue,
32
33
  type ValueSpecificationVisitor,
33
- InstanceValue,
34
- INTERNAL__UnknownValueSpecification,
35
34
  type LambdaFunction,
36
35
  type KeyExpressionInstanceValue,
37
- matchFunctionName,
38
- Class,
36
+ type INTERNAL__PropagatedValue,
37
+ type ValueSpecification,
39
38
  type CollectionInstanceValue,
40
39
  type LambdaFunctionInstanceValue,
40
+ InstanceValue,
41
+ INTERNAL__UnknownValueSpecification,
42
+ matchFunctionName,
43
+ Class,
41
44
  PrimitiveInstanceValue,
42
45
  SimpleFunctionExpression,
43
46
  VariableExpression,
44
- type AbstractPropertyExpression,
45
47
  getMilestoneTemporalStereotype,
46
- type INTERNAL__PropagatedValue,
47
- type ValueSpecification,
48
48
  SUPPORTED_FUNCTIONS,
49
49
  isSuperType,
50
50
  PackageableElementReference,
@@ -206,6 +206,33 @@ const processGetAllVersionsInRangeExpression = (
206
206
  );
207
207
  };
208
208
 
209
+ // a recursive function to check if there are some date functions
210
+ // unsupported in the custom date picker dropdown.
211
+ // For now, it's just QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR and QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH.
212
+ export const isUsedDateFunctionSupportedInFormMode = (
213
+ valueSpec: ValueSpecification,
214
+ ): boolean => {
215
+ if (valueSpec instanceof SimpleFunctionExpression) {
216
+ if (
217
+ matchFunctionName(
218
+ valueSpec.functionName,
219
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR,
220
+ ) ||
221
+ matchFunctionName(
222
+ valueSpec.functionName,
223
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH,
224
+ )
225
+ ) {
226
+ return false;
227
+ }
228
+ return !valueSpec.parametersValues
229
+ .map((value) => isUsedDateFunctionSupportedInFormMode(value))
230
+ .includes(false);
231
+ } else {
232
+ return true;
233
+ }
234
+ };
235
+
209
236
  const processLetExpression = (
210
237
  expression: SimpleFunctionExpression,
211
238
  queryBuilderState: QueryBuilderState,
@@ -239,11 +266,26 @@ const processLetExpression = (
239
266
  rightSide.content,
240
267
  );
241
268
  } else {
242
- constantExpression = new QueryBuilderSimpleConstantExpressionState(
243
- queryBuilderState,
244
- varExp,
245
- rightSide,
246
- );
269
+ // Even if a valueSpecification is successfully built, it might contain some date functions
270
+ // unsupported in the custom date picker dropdown, e.g., QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR
271
+ // or QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH.
272
+ // If it doesn't contain any unsupported date functions, a QueryBuilderSimpleConstantExpressionState should be created.
273
+ // Otherwise, a QueryBuilderCalculatedConstantExpressionState should be created.
274
+ if (isUsedDateFunctionSupportedInFormMode(rightSide)) {
275
+ constantExpression = new QueryBuilderSimpleConstantExpressionState(
276
+ queryBuilderState,
277
+ varExp,
278
+ rightSide,
279
+ );
280
+ } else {
281
+ constantExpression = new QueryBuilderCalculatedConstantExpressionState(
282
+ queryBuilderState,
283
+ varExp,
284
+ queryBuilderState.graphManagerState.graphManager.serializeValueSpecification(
285
+ rightSide,
286
+ ),
287
+ );
288
+ }
247
289
  }
248
290
  queryBuilderState.constantState.setShowConstantPanel(true);
249
291
  queryBuilderState.constantState.addConstant(constantExpression);