@finos/legend-query-builder 4.14.46 → 4.14.48

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/lib/__lib__/QueryBuilderDocumentation.d.ts +3 -1
  2. package/lib/__lib__/QueryBuilderDocumentation.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderDocumentation.js +2 -0
  4. package/lib/__lib__/QueryBuilderDocumentation.js.map +1 -1
  5. package/lib/components/QueryBuilder.d.ts.map +1 -1
  6. package/lib/components/QueryBuilder.js +14 -2
  7. package/lib/components/QueryBuilder.js.map +1 -1
  8. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  9. package/lib/components/QueryBuilderSideBar.js +1 -5
  10. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  11. package/lib/components/explorer/{QueryBuilderMilestoningEditor.d.ts → QueryBuilderMilestoningParameterEditor.d.ts} +5 -2
  12. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.d.ts.map +1 -0
  13. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.js +52 -0
  14. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.js.map +1 -0
  15. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  16. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +192 -21
  17. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  18. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  19. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +13 -3
  20. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  21. package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
  22. package/lib/components/result/tds/QueryBuilderTDSGridResult.js +4 -1
  23. package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
  24. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
  25. package/lib/components/result/tds/QueryBuilderTDSResultShared.js +2 -5
  26. package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
  27. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.d.ts.map +1 -1
  28. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js +4 -1
  29. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js.map +1 -1
  30. package/lib/graph-manager/QueryBuilderConfig.d.ts +4 -0
  31. package/lib/graph-manager/QueryBuilderConfig.d.ts.map +1 -1
  32. package/lib/graph-manager/QueryBuilderConfig.js +5 -0
  33. package/lib/graph-manager/QueryBuilderConfig.js.map +1 -1
  34. package/lib/index.css +1 -17
  35. package/lib/index.css.map +1 -1
  36. package/lib/package.json +1 -1
  37. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts +2 -1
  38. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts.map +1 -1
  39. package/lib/stores/QueryBuilderValueSpecificationHelper.js +2 -2
  40. package/lib/stores/QueryBuilderValueSpecificationHelper.js.map +1 -1
  41. package/lib/stores/QueryLoaderState.d.ts +1 -0
  42. package/lib/stores/QueryLoaderState.d.ts.map +1 -1
  43. package/lib/stores/QueryLoaderState.js +1 -0
  44. package/lib/stores/QueryLoaderState.js.map +1 -1
  45. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +1 -0
  46. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  47. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +8 -0
  48. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  49. package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_Percentile.d.ts.map +1 -1
  50. package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_Percentile.js +4 -2
  51. package/lib/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_Percentile.js.map +1 -1
  52. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
  53. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +1 -1
  54. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
  55. package/lib/stores/filter/QueryBuilderFilterStateBuilder.d.ts.map +1 -1
  56. package/lib/stores/filter/QueryBuilderFilterStateBuilder.js +1 -1
  57. package/lib/stores/filter/QueryBuilderFilterStateBuilder.js.map +1 -1
  58. package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.d.ts +2 -0
  59. package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.d.ts.map +1 -1
  60. package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.js +13 -2
  61. package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.js.map +1 -1
  62. package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.d.ts +2 -0
  63. package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.d.ts.map +1 -1
  64. package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.js +8 -1
  65. package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.js.map +1 -1
  66. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts +1 -1
  67. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts.map +1 -1
  68. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js +25 -1
  69. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js.map +1 -1
  70. package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.d.ts +2 -0
  71. package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.d.ts.map +1 -1
  72. package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.js.map +1 -1
  73. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts +2 -0
  74. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts.map +1 -1
  75. package/lib/stores/milestoning/QueryBuilderMilestoningState.js +22 -3
  76. package/lib/stores/milestoning/QueryBuilderMilestoningState.js.map +1 -1
  77. package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.d.ts +2 -0
  78. package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.d.ts.map +1 -1
  79. package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.js +8 -1
  80. package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.js.map +1 -1
  81. package/package.json +4 -4
  82. package/src/__lib__/QueryBuilderDocumentation.ts +2 -0
  83. package/src/components/QueryBuilder.tsx +44 -0
  84. package/src/components/QueryBuilderSideBar.tsx +0 -22
  85. package/src/components/explorer/QueryBuilderMilestoningParameterEditor.tsx +114 -0
  86. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +445 -19
  87. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +118 -21
  88. package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +3 -0
  89. package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +1 -6
  90. package/src/components/result/tds/QueryBuilderTDSSimpleGridResult.tsx +8 -1
  91. package/src/graph-manager/QueryBuilderConfig.ts +6 -0
  92. package/src/stores/QueryBuilderValueSpecificationHelper.ts +3 -0
  93. package/src/stores/QueryLoaderState.ts +1 -0
  94. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +11 -0
  95. package/src/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_Percentile.ts +6 -2
  96. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +1 -0
  97. package/src/stores/filter/QueryBuilderFilterStateBuilder.ts +1 -0
  98. package/src/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.ts +23 -0
  99. package/src/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.ts +13 -0
  100. package/src/stores/milestoning/QueryBuilderMilestoningHelper.ts +45 -0
  101. package/src/stores/milestoning/QueryBuilderMilestoningImplementation.ts +3 -0
  102. package/src/stores/milestoning/QueryBuilderMilestoningState.ts +41 -7
  103. package/src/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.ts +13 -0
  104. package/tsconfig.json +1 -1
  105. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +0 -1
  106. package/lib/components/explorer/QueryBuilderMilestoningEditor.js +0 -102
  107. package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +0 -1
  108. package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +0 -364
@@ -33,6 +33,8 @@ import {
33
33
  PanelFormSection,
34
34
  ArrowUpIcon,
35
35
  ArrowDownIcon,
36
+ PanelFormBooleanField,
37
+ PanelFormListItems,
36
38
  } from '@finos/legend-art';
37
39
  import { SortColumnState } from '../../stores/fetch-structure/tds/QueryResultSetModifierState.js';
38
40
  import {
@@ -41,21 +43,36 @@ import {
41
43
  deepClone,
42
44
  deleteEntry,
43
45
  guaranteeNonNullable,
46
+ isNonNullable,
44
47
  } from '@finos/legend-shared';
45
48
  import { useApplicationStore } from '@finos/legend-application';
46
49
  import type { QueryBuilderTDSState } from '../../stores/fetch-structure/tds/QueryBuilderTDSState.js';
47
50
  import type { QueryBuilderTDSColumnState } from '../../stores/fetch-structure/tds/QueryBuilderTDSColumnState.js';
48
- import { COLUMN_SORT_TYPE } from '../../graph/QueryBuilderMetaModelConst.js';
51
+ import {
52
+ COLUMN_SORT_TYPE,
53
+ QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
54
+ } from '../../graph/QueryBuilderMetaModelConst.js';
49
55
  import { useCallback, useEffect, useState } from 'react';
50
56
  import type { QueryBuilderProjectionColumnState } from '../../stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js';
51
57
  import { QUERY_BUILDER_TEST_ID } from '../../__lib__/QueryBuilderTesting.js';
52
- import { VariableSelector } from '../shared/QueryBuilderVariableSelector.js';
58
+ import {
59
+ VariableSelector,
60
+ VariableViewer,
61
+ } from '../shared/QueryBuilderVariableSelector.js';
53
62
  import {
54
63
  type ValueSpecification,
55
- type VariableExpression,
64
+ VariableExpression,
56
65
  PrimitiveType,
57
66
  Multiplicity,
58
67
  areMultiplicitiesEqual,
68
+ PRIMITIVE_TYPE,
69
+ MILESTONING_START_DATE_PARAMETER_NAME,
70
+ GenericType,
71
+ GenericTypeExplicitReference,
72
+ MILESTONING_END_DATE_PARAMETER_NAME,
73
+ getMilestoneTemporalStereotype,
74
+ BUSINESS_DATE_MILESTONING_PROPERTY_NAME,
75
+ PROCESSING_DATE_MILESTONING_PROPERTY_NAME,
59
76
  } from '@finos/legend-graph';
60
77
  import {
61
78
  BasicValueSpecificationEditor,
@@ -63,6 +80,9 @@ import {
63
80
  type QueryBuilderVariableDragSource,
64
81
  } from '../shared/BasicValueSpecificationEditor.js';
65
82
  import { useDrop } from 'react-dnd';
83
+ import { MilestoningParameterEditor } from '../explorer/QueryBuilderMilestoningParameterEditor.js';
84
+ import { QueryBuilderSimpleConstantExpressionState } from '../../stores/QueryBuilderConstantsState.js';
85
+ import { LambdaParameterState } from '../../stores/shared/LambdaParameterState.js';
66
86
 
67
87
  const ColumnSortEditor = observer(
68
88
  (props: {
@@ -275,21 +295,6 @@ export const QueryResultModifierModal = observer(
275
295
  stateSlice,
276
296
  ]);
277
297
 
278
- // Handle user actions
279
- const closeModal = (): void => resultSetModifierState.setShowModal(false);
280
- const applyChanges = (): void => {
281
- resultSetModifierState.setSortColumns(sortColumns);
282
- resultSetModifierState.setDistinct(distinct);
283
- resultSetModifierState.setLimit(limitResults);
284
- if (slice[0] !== undefined && slice[1] !== undefined) {
285
- resultSetModifierState.setSlice([slice[0], slice[1]]);
286
- } else {
287
- resultSetModifierState.setSlice(undefined);
288
- }
289
- resultSetModifierState.setShowModal(false);
290
- watermarkState.setValue(watermarkValue);
291
- };
292
-
293
298
  const handleLimitResultsChange: React.ChangeEventHandler<
294
299
  HTMLInputElement
295
300
  > = (event) => {
@@ -380,6 +385,292 @@ export const QueryResultModifierModal = observer(
380
385
  [handleDrop],
381
386
  );
382
387
 
388
+ //milestoning config
389
+ const isCompatibleMilestoningParameter = (
390
+ variable: VariableExpression,
391
+ ): boolean =>
392
+ variable.genericType?.value.rawType.name === PRIMITIVE_TYPE.STRICTDATE ||
393
+ variable.genericType?.value.rawType.name === PRIMITIVE_TYPE.LATESTDATE ||
394
+ variable.genericType?.value.rawType.name === PRIMITIVE_TYPE.DATE ||
395
+ variable.genericType?.value.rawType.name === PRIMITIVE_TYPE.DATETIME;
396
+
397
+ const milestoningState = tdsState.queryBuilderState.milestoningState;
398
+ const [parameterStates, setParameterStates] = useState(
399
+ milestoningState.queryBuilderState.parametersState.parameterStates,
400
+ );
401
+ const filteredParameterStates = parameterStates.filter((p) =>
402
+ isCompatibleMilestoningParameter(p.parameter),
403
+ );
404
+ const filteredConstantState =
405
+ milestoningState.queryBuilderState.constantState.constants.filter((c) =>
406
+ isCompatibleMilestoningParameter(c.variable),
407
+ );
408
+
409
+ const [isAllVersionsEnabled, setIsAllVersionsEnabled] = useState(
410
+ milestoningState.isAllVersionsEnabled,
411
+ );
412
+ const [isAllVersionsInRangeEnabled, setIsAllVersionsInRangeEnabled] =
413
+ useState(milestoningState.isAllVersionsInRangeEnabled);
414
+ const [businessDate, setBusinessDate] = useState(
415
+ milestoningState.businessDate,
416
+ );
417
+ const [processingDate, setProcessingDate] = useState(
418
+ milestoningState.processingDate,
419
+ );
420
+ const [startDate, setStartDate] = useState(milestoningState.startDate);
421
+ const [endDate, setEndDate] = useState(milestoningState.endDate);
422
+
423
+ const shouldFilterMilestoningParamIfNotUsed = (
424
+ param: ValueSpecification | undefined,
425
+ resetParameter: (val: ValueSpecification | undefined) => void,
426
+ ): ((lambdaParamState: LambdaParameterState) => boolean) => {
427
+ if (param && param instanceof VariableExpression) {
428
+ if (
429
+ !milestoningState.queryBuilderState.isVariableUsed(param, {
430
+ exculdeMilestoningState: true,
431
+ })
432
+ ) {
433
+ resetParameter(undefined);
434
+ return (lambdaParamState: LambdaParameterState) =>
435
+ lambdaParamState.parameter.name !== param.name;
436
+ }
437
+ }
438
+ return (lambdaParamState: LambdaParameterState) => true;
439
+ };
440
+
441
+ const setAllVersions = (value: boolean | undefined): void => {
442
+ if (value) {
443
+ //clean all unused milestoning parameters e.g. businessDate, ..., endDate.
444
+ setParameterStates([
445
+ ...parameterStates.filter(
446
+ (ps) =>
447
+ shouldFilterMilestoningParamIfNotUsed(
448
+ businessDate,
449
+ setBusinessDate,
450
+ )(ps) &&
451
+ shouldFilterMilestoningParamIfNotUsed(
452
+ processingDate,
453
+ setProcessingDate,
454
+ )(ps) &&
455
+ shouldFilterMilestoningParamIfNotUsed(
456
+ startDate,
457
+ setStartDate,
458
+ )(ps) &&
459
+ shouldFilterMilestoningParamIfNotUsed(endDate, setEndDate)(ps),
460
+ ),
461
+ ]);
462
+ } else {
463
+ //get or initialize getAll() parameters
464
+ setIsAllVersionsInRangeEnabled(false);
465
+ let newParamStates: LambdaParameterState[] = [];
466
+ if (
467
+ (!businessDate || !processingDate) &&
468
+ milestoningState.queryBuilderState.class
469
+ ) {
470
+ const stereotype = getMilestoneTemporalStereotype(
471
+ milestoningState.queryBuilderState.class,
472
+ milestoningState.queryBuilderState.graphManagerState.graph,
473
+ );
474
+ if (stereotype) {
475
+ const existingParamStates = parameterStates.map(
476
+ (ps) => ps.variableName,
477
+ );
478
+ newParamStates = milestoningState
479
+ .getMilestoningImplementation(stereotype)
480
+ .buildParameterStatesFromMilestoningParameters()
481
+ .filter((ps) => !existingParamStates.includes(ps.parameter.name));
482
+ }
483
+ }
484
+ const allParamStates = [...newParamStates, ...parameterStates].filter(
485
+ (ps) =>
486
+ shouldFilterMilestoningParamIfNotUsed(
487
+ startDate,
488
+ setStartDate,
489
+ )(ps) &&
490
+ shouldFilterMilestoningParamIfNotUsed(endDate, setEndDate)(ps),
491
+ );
492
+ setParameterStates(allParamStates);
493
+ if (!businessDate) {
494
+ setBusinessDate(
495
+ allParamStates.find(
496
+ (ps) =>
497
+ ps.variableName ===
498
+ (milestoningState.businessDate &&
499
+ milestoningState.businessDate instanceof VariableExpression
500
+ ? milestoningState.businessDate.name
501
+ : BUSINESS_DATE_MILESTONING_PROPERTY_NAME),
502
+ )?.parameter,
503
+ );
504
+ }
505
+ if (!processingDate) {
506
+ setProcessingDate(
507
+ allParamStates.find(
508
+ (ps) =>
509
+ ps.variableName ===
510
+ (milestoningState.businessDate &&
511
+ milestoningState.processingDate instanceof VariableExpression
512
+ ? milestoningState.processingDate.name
513
+ : PROCESSING_DATE_MILESTONING_PROPERTY_NAME),
514
+ )?.parameter,
515
+ );
516
+ }
517
+ }
518
+ setIsAllVersionsEnabled(Boolean(value));
519
+ };
520
+
521
+ const getOrCreateNewLambdaParameterState = (
522
+ lamdaStates: LambdaParameterState[],
523
+ varName: string,
524
+ ): LambdaParameterState => {
525
+ const lamdaState = lamdaStates.find((ls) => ls.variableName === varName);
526
+ if (lamdaState) {
527
+ return lamdaState;
528
+ } else {
529
+ const varExp = new VariableExpression(
530
+ varName,
531
+ Multiplicity.ONE,
532
+ GenericTypeExplicitReference.create(
533
+ new GenericType(PrimitiveType.DATE),
534
+ ),
535
+ );
536
+ const newParamState = new LambdaParameterState(
537
+ varExp,
538
+ milestoningState.queryBuilderState.observerContext,
539
+ milestoningState.queryBuilderState.graphManagerState.graph,
540
+ );
541
+ newParamState.mockParameterValue();
542
+ return newParamState;
543
+ }
544
+ };
545
+
546
+ const buildAllVersionsInRangeParameters = (): void => {
547
+ let startDateParameterState;
548
+ let endDateParameterState;
549
+ if (!(startDate && startDate instanceof VariableExpression)) {
550
+ startDateParameterState = getOrCreateNewLambdaParameterState(
551
+ parameterStates,
552
+ MILESTONING_START_DATE_PARAMETER_NAME,
553
+ );
554
+ setStartDate(startDateParameterState.parameter);
555
+ }
556
+ if (!(endDate && endDate instanceof VariableExpression)) {
557
+ endDateParameterState = getOrCreateNewLambdaParameterState(
558
+ parameterStates,
559
+ MILESTONING_END_DATE_PARAMETER_NAME,
560
+ );
561
+ setEndDate(endDateParameterState.parameter);
562
+ }
563
+ setParameterStates([
564
+ ...new Set([
565
+ ...parameterStates.filter(
566
+ (ps) =>
567
+ shouldFilterMilestoningParamIfNotUsed(
568
+ businessDate,
569
+ setBusinessDate,
570
+ )(ps) &&
571
+ shouldFilterMilestoningParamIfNotUsed(
572
+ processingDate,
573
+ setProcessingDate,
574
+ )(ps),
575
+ ),
576
+ ...[startDateParameterState, endDateParameterState].filter(
577
+ isNonNullable,
578
+ ),
579
+ ]),
580
+ ]);
581
+ };
582
+
583
+ const setAllVersionsInRange = (value: boolean | undefined): void => {
584
+ if (value) {
585
+ buildAllVersionsInRangeParameters();
586
+ } else {
587
+ setAllVersions(true);
588
+ }
589
+ setIsAllVersionsInRangeEnabled(Boolean(value));
590
+ };
591
+
592
+ const resetMilestoningConfig = (): void => {
593
+ setIsAllVersionsEnabled(milestoningState.isAllVersionsEnabled);
594
+ setIsAllVersionsInRangeEnabled(
595
+ milestoningState.isAllVersionsInRangeEnabled,
596
+ );
597
+ setStartDate(milestoningState.startDate);
598
+ setEndDate(milestoningState.endDate);
599
+ setBusinessDate(milestoningState.businessDate);
600
+ setProcessingDate(milestoningState.processingDate);
601
+ setParameterStates(
602
+ milestoningState.queryBuilderState.parametersState.parameterStates,
603
+ );
604
+ };
605
+
606
+ // Handle user actions
607
+ const closeModal = (): void => {
608
+ resetMilestoningConfig();
609
+ resultSetModifierState.setShowModal(false);
610
+ };
611
+
612
+ const applyChanges = (): void => {
613
+ resultSetModifierState.setSortColumns(sortColumns);
614
+ resultSetModifierState.setDistinct(distinct);
615
+ resultSetModifierState.setLimit(limitResults);
616
+ if (slice[0] !== undefined && slice[1] !== undefined) {
617
+ resultSetModifierState.setSlice([slice[0], slice[1]]);
618
+ } else {
619
+ resultSetModifierState.setSlice(undefined);
620
+ }
621
+ resultSetModifierState.setShowModal(false);
622
+ watermarkState.setValue(watermarkValue);
623
+ milestoningState.queryBuilderState.parametersState.setParameters(
624
+ parameterStates,
625
+ );
626
+ if (isAllVersionsInRangeEnabled) {
627
+ milestoningState.setStartDate(startDate);
628
+ milestoningState.setEndDate(endDate);
629
+ milestoningState.clearGetAllParameters();
630
+ milestoningState.queryBuilderState.setGetAllFunction(
631
+ QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
632
+ );
633
+ } else if (isAllVersionsEnabled) {
634
+ milestoningState.clearGetAllParameters();
635
+ milestoningState.queryBuilderState.setGetAllFunction(
636
+ QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
637
+ );
638
+ } else if (
639
+ tdsState.queryBuilderState.milestoningState.isMilestonedQuery
640
+ ) {
641
+ milestoningState.clearAllVersionsInRangeParameters();
642
+ milestoningState.setBusinessDate(businessDate);
643
+ milestoningState.setProcessingDate(processingDate);
644
+ milestoningState.queryBuilderState.setGetAllFunction(
645
+ QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
646
+ );
647
+ }
648
+ milestoningState.updateQueryBuilderState();
649
+ };
650
+
651
+ useEffect(() => {
652
+ setIsAllVersionsEnabled(milestoningState.isAllVersionsEnabled);
653
+ setIsAllVersionsInRangeEnabled(
654
+ milestoningState.isAllVersionsInRangeEnabled,
655
+ );
656
+ setStartDate(milestoningState.startDate);
657
+ setEndDate(milestoningState.endDate);
658
+ setBusinessDate(milestoningState.businessDate);
659
+ setProcessingDate(milestoningState.processingDate);
660
+ setParameterStates(
661
+ milestoningState.queryBuilderState.parametersState.parameterStates,
662
+ );
663
+ }, [
664
+ milestoningState.isAllVersionsEnabled,
665
+ milestoningState.isAllVersionsInRangeEnabled,
666
+ milestoningState.queryBuilderState.parametersState.parameterStates,
667
+ milestoningState.businessDate,
668
+ milestoningState.processingDate,
669
+ milestoningState.startDate,
670
+ milestoningState.endDate,
671
+ milestoningState.queryBuilderState.class,
672
+ ]);
673
+
383
674
  return (
384
675
  <Dialog
385
676
  open={Boolean(resultSetModifierState.showModal)}
@@ -397,9 +688,144 @@ export const QueryResultModifierModal = observer(
397
688
  }
398
689
  className="editor-modal query-builder__projection__modal"
399
690
  >
400
- <ModalHeader title="Result Set Modifier" />
691
+ <ModalHeader title="Query Options" />
401
692
  <ModalBody className="query-builder__projection__modal__body">
402
693
  <div className="query-builder__projection__options">
694
+ {tdsState.queryBuilderState.milestoningState
695
+ .isMilestonedQuery && (
696
+ <>
697
+ <div className="query-builder__projection__options__section-name">
698
+ Milestoning
699
+ </div>
700
+ {milestoningState.isCurrentClassMilestoned && (
701
+ <PanelFormBooleanField
702
+ isReadOnly={false}
703
+ value={isAllVersionsEnabled}
704
+ name="all Versions"
705
+ prompt="Query All Milestoned Versions of the Root Class"
706
+ update={setAllVersions}
707
+ />
708
+ )}
709
+ {isAllVersionsEnabled &&
710
+ milestoningState.isCurrentClassSupportsVersionsInRange && (
711
+ <>
712
+ <PanelFormBooleanField
713
+ isReadOnly={false}
714
+ value={isAllVersionsInRangeEnabled}
715
+ name=" All Versions In Range"
716
+ prompt="Optionally apply a date range to get All Versions for"
717
+ update={setAllVersionsInRange}
718
+ />
719
+ {isAllVersionsInRangeEnabled &&
720
+ startDate &&
721
+ endDate && (
722
+ <div className="query-builder__milestoning-panel__all-versions-in-range-editor">
723
+ <PanelFormSection>
724
+ <div className="panel__content__form__section__header__label">
725
+ Start Date
726
+ </div>
727
+ <MilestoningParameterEditor
728
+ queryBuilderState={
729
+ milestoningState.queryBuilderState
730
+ }
731
+ parameter={startDate}
732
+ setParameter={setStartDate}
733
+ />
734
+ </PanelFormSection>
735
+ <PanelFormSection>
736
+ <div className="panel__content__form__section__header__label">
737
+ End Date
738
+ </div>
739
+ <MilestoningParameterEditor
740
+ queryBuilderState={
741
+ milestoningState.queryBuilderState
742
+ }
743
+ parameter={endDate}
744
+ setParameter={setEndDate}
745
+ />
746
+ </PanelFormSection>
747
+ </div>
748
+ )}
749
+ </>
750
+ )}
751
+ {!isAllVersionsEnabled && (
752
+ <>
753
+ {processingDate && (
754
+ <PanelFormSection>
755
+ <div className="panel__content__form__section__header__label">
756
+ Processing Date
757
+ </div>
758
+ <MilestoningParameterEditor
759
+ queryBuilderState={
760
+ milestoningState.queryBuilderState
761
+ }
762
+ parameter={processingDate}
763
+ setParameter={setProcessingDate}
764
+ />
765
+ </PanelFormSection>
766
+ )}
767
+ {businessDate && (
768
+ <PanelFormSection>
769
+ <div className="panel__content__form__section__header__label">
770
+ Business Date
771
+ </div>
772
+ <MilestoningParameterEditor
773
+ queryBuilderState={
774
+ milestoningState.queryBuilderState
775
+ }
776
+ parameter={businessDate}
777
+ setParameter={setBusinessDate}
778
+ />
779
+ </PanelFormSection>
780
+ )}
781
+ </>
782
+ )}
783
+ <PanelFormSection>
784
+ <div className="panel__content__form__section__header__label">
785
+ List of compatible milestoning parameters
786
+ </div>
787
+ </PanelFormSection>
788
+ <div className="panel__content__form__section__list__items">
789
+ <PanelFormListItems title="Available parameters">
790
+ {filteredParameterStates.length === 0 && (
791
+ <> No available parameters </>
792
+ )}
793
+ {filteredParameterStates.map((pState) => (
794
+ <VariableViewer
795
+ key={pState.uuid}
796
+ variable={pState.parameter}
797
+ isReadOnly={true}
798
+ queryBuilderState={milestoningState.queryBuilderState}
799
+ />
800
+ ))}
801
+ </PanelFormListItems>
802
+ {Boolean(filteredConstantState.length) && (
803
+ <PanelFormListItems title="Available constants">
804
+ {filteredConstantState.map((constantState) => (
805
+ <VariableViewer
806
+ key={constantState.uuid}
807
+ variable={constantState.variable}
808
+ value={{
809
+ val:
810
+ constantState instanceof
811
+ QueryBuilderSimpleConstantExpressionState
812
+ ? constantState.value
813
+ : undefined,
814
+ }}
815
+ queryBuilderState={
816
+ milestoningState.queryBuilderState
817
+ }
818
+ isReadOnly={true}
819
+ />
820
+ ))}
821
+ </PanelFormListItems>
822
+ )}
823
+ </div>
824
+ <div className="query-builder__projection__options__section-name">
825
+ Other
826
+ </div>
827
+ </>
828
+ )}
403
829
  <ColumnsSortEditor
404
830
  projectionColumns={tdsState.projectionColumns}
405
831
  sortColumns={sortColumns}