@finos/legend-query-builder 4.14.39 → 4.14.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +1 -1
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderParametersPanel.js +20 -2
  6. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  7. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  8. package/lib/components/QueryBuilderSideBar.js +5 -14
  9. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  10. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  11. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +12 -4
  12. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  13. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  14. package/lib/components/filter/QueryBuilderFilterPanel.js +6 -2
  15. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  16. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  17. package/lib/components/result/QueryBuilderResultPanel.js +2 -1
  18. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  19. package/lib/components/shared/BasicValueSpecificationEditor.d.ts +11 -9
  20. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  21. package/lib/components/shared/BasicValueSpecificationEditor.js +158 -143
  22. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  23. package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
  24. package/lib/components/shared/QueryBuilderVariableSelector.js +8 -1
  25. package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
  26. package/lib/index.css +2 -2
  27. package/lib/index.css.map +1 -1
  28. package/lib/package.json +5 -5
  29. package/lib/stores/QueryBuilderPropertyEditorState.d.ts +1 -0
  30. package/lib/stores/QueryBuilderPropertyEditorState.d.ts.map +1 -1
  31. package/lib/stores/QueryBuilderPropertyEditorState.js +2 -1
  32. package/lib/stores/QueryBuilderPropertyEditorState.js.map +1 -1
  33. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  34. package/lib/stores/QueryBuilderState.js +12 -0
  35. package/lib/stores/QueryBuilderState.js.map +1 -1
  36. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +1 -0
  37. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
  38. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js +2 -2
  39. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js.map +1 -1
  40. package/lib/stores/filter/QueryBuilderFilterState.d.ts +1 -1
  41. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  42. package/lib/stores/filter/QueryBuilderFilterState.js +4 -3
  43. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  44. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js +2 -2
  45. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js.map +1 -1
  46. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts +1 -0
  47. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts.map +1 -1
  48. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js +16 -0
  49. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js.map +1 -1
  50. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts +3 -0
  51. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts.map +1 -1
  52. package/lib/stores/milestoning/QueryBuilderMilestoningState.js +40 -0
  53. package/lib/stores/milestoning/QueryBuilderMilestoningState.js.map +1 -1
  54. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts +1 -0
  55. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -1
  56. package/lib/stores/shared/ValueSpecificationEditorHelper.js +48 -0
  57. package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -1
  58. package/package.json +13 -13
  59. package/src/components/QueryBuilder.tsx +1 -0
  60. package/src/components/QueryBuilderParametersPanel.tsx +55 -0
  61. package/src/components/QueryBuilderSideBar.tsx +0 -35
  62. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +22 -6
  63. package/src/components/filter/QueryBuilderFilterPanel.tsx +13 -5
  64. package/src/components/result/QueryBuilderResultPanel.tsx +9 -1
  65. package/src/components/shared/BasicValueSpecificationEditor.tsx +288 -285
  66. package/src/components/shared/QueryBuilderVariableSelector.tsx +22 -0
  67. package/src/stores/QueryBuilderPropertyEditorState.ts +2 -1
  68. package/src/stores/QueryBuilderState.ts +14 -0
  69. package/src/stores/QueryBuilder_LegendApplicationPlugin_Extension.ts +1 -0
  70. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.ts +2 -2
  71. package/src/stores/filter/QueryBuilderFilterState.ts +6 -3
  72. package/src/stores/filter/operators/QueryBuilderFilterOperator_In.ts +2 -2
  73. package/src/stores/milestoning/QueryBuilderMilestoningHelper.ts +24 -0
  74. package/src/stores/milestoning/QueryBuilderMilestoningState.ts +54 -0
  75. package/src/stores/shared/ValueSpecificationEditorHelper.ts +63 -0
@@ -29,9 +29,11 @@ import {
29
29
  ModalFooterButton,
30
30
  PanelFormValidatedTextField,
31
31
  QuestionCircleIcon,
32
+ PanelFormSection,
32
33
  } from '@finos/legend-art';
33
34
  import {
34
35
  type Type,
36
+ type ValueSpecification,
35
37
  VariableExpression,
36
38
  GenericTypeExplicitReference,
37
39
  GenericType,
@@ -53,6 +55,10 @@ import {
53
55
  getPackageableElementOptionFormatter,
54
56
  type PackageableElementOption,
55
57
  } from '@finos/legend-lego/graph-editor';
58
+ import { deepClone } from '@finos/legend-shared';
59
+ import { BasicValueSpecificationEditor } from './shared/BasicValueSpecificationEditor.js';
60
+ import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../graph/QueryBuilderMetaModelConst.js';
61
+ import { createSupportedFunctionExpression } from '../stores/shared/ValueSpecificationEditorHelper.js';
56
62
 
57
63
  type MultiplicityOption = { label: string; value: Multiplicity };
58
64
 
@@ -118,6 +124,13 @@ const VariableExpressionEditor = observer(
118
124
  const nameInputRef = useCallback((ref: HTMLInputElement | null): void => {
119
125
  ref?.focus();
120
126
  }, []);
127
+ const [defaultMilestoningValue, setDefaultMilestoningValue] = useState(
128
+ deepClone(lambdaParameterState.value),
129
+ );
130
+ const isMilestoningParameter =
131
+ queryBuilderState.milestoningState.isMilestoningParameter(
132
+ lambdaParameterState.parameter,
133
+ );
121
134
 
122
135
  const getValidationMessage = (input: string): string | undefined =>
123
136
  !hasEditedName
@@ -146,6 +159,13 @@ const VariableExpressionEditor = observer(
146
159
  if (isCreating) {
147
160
  queryParametersState.addParameter(lambdaParameterState);
148
161
  }
162
+ if (isMilestoningParameter) {
163
+ queryBuilderState.milestoningState.updateMilestoningParameterValue(
164
+ lambdaParameterState.parameter,
165
+ defaultMilestoningValue,
166
+ );
167
+ }
168
+
149
169
  handleCancel();
150
170
  };
151
171
 
@@ -231,6 +251,41 @@ const VariableExpressionEditor = observer(
231
251
  }
232
252
  />
233
253
  </div>
254
+ {isMilestoningParameter && defaultMilestoningValue && (
255
+ <PanelFormSection>
256
+ <div className="panel__content__form__section__header__label">
257
+ Value
258
+ </div>
259
+ <div className="panel__content__form__section__header__prompt">
260
+ Choose a default value for this milestoning parameter
261
+ </div>
262
+ <div className="query-builder__variable-editor">
263
+ <BasicValueSpecificationEditor
264
+ valueSpecification={defaultMilestoningValue}
265
+ setValueSpecification={(val: ValueSpecification): void => {
266
+ setDefaultMilestoningValue(deepClone(val));
267
+ }}
268
+ graph={queryBuilderState.graphManagerState.graph}
269
+ obseverContext={queryBuilderState.observerContext}
270
+ typeCheckOption={{
271
+ expectedType: selectedType.value,
272
+ match: selectedType.value === PrimitiveType.DATETIME,
273
+ }}
274
+ resetValue={() => {
275
+ const now = createSupportedFunctionExpression(
276
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.NOW,
277
+ PrimitiveType.DATETIME,
278
+ );
279
+ setDefaultMilestoningValue(now);
280
+ queryBuilderState.milestoningState.updateMilestoningParameterValue(
281
+ lambdaParameterState.parameter,
282
+ now,
283
+ );
284
+ }}
285
+ />
286
+ </div>
287
+ </PanelFormSection>
288
+ )}
234
289
  </ModalBody>
235
290
  <ModalFooter>
236
291
  <ModalFooterButton
@@ -18,7 +18,6 @@ import {
18
18
  CustomSelectorInput,
19
19
  createFilter,
20
20
  CogIcon,
21
- ClockIcon,
22
21
  clsx,
23
22
  PanelHeader,
24
23
  compareLabelFn,
@@ -34,7 +33,6 @@ import {
34
33
  LATEST_DATE,
35
34
  PrimitiveInstanceValue,
36
35
  VariableExpression,
37
- getMilestoneTemporalStereotype,
38
36
  PackageableElementExplicitReference,
39
37
  RuntimePointer,
40
38
  VARIABLE_REFERENCE_TOKEN,
@@ -75,23 +73,11 @@ const generateClassLabel = (
75
73
  val: Class,
76
74
  queryBuilderState: QueryBuilderState,
77
75
  ): React.ReactNode => {
78
- const milestoneStereotype = getMilestoneTemporalStereotype(
79
- val,
80
- queryBuilderState.graphManagerState.graph,
81
- );
82
-
83
76
  const isDeprecatedClass = isElementDeprecated(
84
77
  val,
85
78
  queryBuilderState.graphManagerState.graph,
86
79
  );
87
80
 
88
- let milestoningTooltipText: string | undefined;
89
- if (milestoneStereotype) {
90
- milestoningTooltipText = queryBuilderState.milestoningState
91
- .getMilestoningImplementation(milestoneStereotype)
92
- .getMilestoningToolTipText();
93
- }
94
-
95
81
  return (
96
82
  <div
97
83
  className={clsx('query-builder__setup__class-option-label', {
@@ -102,12 +88,6 @@ const generateClassLabel = (
102
88
  <div className="query-builder__setup__class-option-label__name">
103
89
  {val.name}
104
90
  </div>
105
- {milestoningTooltipText && (
106
- <ClockIcon
107
- className="query-builder__setup__class-option-label__milestoning"
108
- title={`This class is milestoned:\n${milestoningTooltipText}`}
109
- />
110
- )}
111
91
  </div>
112
92
  );
113
93
  };
@@ -151,10 +131,6 @@ export const QueryBuilderClassSelector = observer(
151
131
  onClassChange?.(val.value);
152
132
  };
153
133
 
154
- // milestoning
155
- const showMilestoningEditor = (): void =>
156
- milestoningState.setShowMilestoningEditor(true);
157
-
158
134
  return (
159
135
  <div className="query-builder__setup__config-group query-builder__setup__config-group--class">
160
136
  <div className="query-builder__setup__config-group__item ">
@@ -192,17 +168,6 @@ export const QueryBuilderClassSelector = observer(
192
168
  .TEMPORARY__isLightColorThemeEnabled,
193
169
  })}
194
170
  />
195
- {queryBuilderState.isQuerySupported && (
196
- <button
197
- className="btn--dark btn__icon--dark query-builder__setup__milestoning"
198
- tabIndex={-1}
199
- onClick={showMilestoningEditor}
200
- disabled={!milestoningState.isMilestonedQuery}
201
- title="Edit Milestoning Parameters"
202
- >
203
- <ClockIcon />
204
- </button>
205
- )}
206
171
  {milestoningState.isMilestonedQuery && (
207
172
  <MilestoningParametersEditor
208
173
  queryBuilderState={queryBuilderState}
@@ -1163,8 +1163,12 @@ export const QueryBuilderTDSPanel = observer(
1163
1163
  >
1164
1164
  <div className="query-builder__projection__result-modifier-prompt__header__label__title">
1165
1165
  {getNameOfValueSpecification(
1166
- tdsState.queryBuilderState.milestoningState
1167
- .businessDate,
1166
+ tdsState.queryBuilderState.milestoningState.getMilestoningParameterValue(
1167
+ tdsState.queryBuilderState.milestoningState
1168
+ .businessDate,
1169
+ ) ??
1170
+ tdsState.queryBuilderState.milestoningState
1171
+ .businessDate,
1168
1172
  tdsState.queryBuilderState,
1169
1173
  )}
1170
1174
  </div>
@@ -1182,8 +1186,12 @@ export const QueryBuilderTDSPanel = observer(
1182
1186
  >
1183
1187
  <div className="query-builder__projection__result-modifier-prompt__header__label__title">
1184
1188
  {getNameOfValueSpecification(
1185
- tdsState.queryBuilderState.milestoningState
1186
- .processingDate,
1189
+ tdsState.queryBuilderState.milestoningState.getMilestoningParameterValue(
1190
+ tdsState.queryBuilderState.milestoningState
1191
+ .processingDate,
1192
+ ) ??
1193
+ tdsState.queryBuilderState.milestoningState
1194
+ .processingDate,
1187
1195
  tdsState.queryBuilderState,
1188
1196
  )}
1189
1197
  </div>
@@ -1223,12 +1231,20 @@ export const QueryBuilderTDSPanel = observer(
1223
1231
  <div className="query-builder__projection__result-modifier-prompt__header__label__title">
1224
1232
  (
1225
1233
  {getNameOfValueSpecification(
1226
- tdsState.queryBuilderState.milestoningState.startDate,
1234
+ tdsState.queryBuilderState.milestoningState.getMilestoningParameterValue(
1235
+ tdsState.queryBuilderState.milestoningState
1236
+ .startDate,
1237
+ ) ??
1238
+ tdsState.queryBuilderState.milestoningState
1239
+ .startDate,
1227
1240
  tdsState.queryBuilderState,
1228
1241
  )}{' '}
1229
1242
  -{' '}
1230
1243
  {getNameOfValueSpecification(
1231
- tdsState.queryBuilderState.milestoningState.endDate,
1244
+ tdsState.queryBuilderState.milestoningState.getMilestoningParameterValue(
1245
+ tdsState.queryBuilderState.milestoningState.endDate,
1246
+ ) ??
1247
+ tdsState.queryBuilderState.milestoningState.endDate,
1232
1248
  tdsState.queryBuilderState,
1233
1249
  )}
1234
1250
  )
@@ -92,6 +92,7 @@ import {
92
92
  SimpleFunctionExpression,
93
93
  type ValueSpecification,
94
94
  VariableExpression,
95
+ PrimitiveType,
95
96
  } from '@finos/legend-graph';
96
97
  import {
97
98
  type QueryBuilderProjectionColumnDragSource,
@@ -111,6 +112,7 @@ import { getPropertyChainName } from '../../stores/QueryBuilderPropertyEditorSta
111
112
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graph/QueryBuilderMetaModelConst.js';
112
113
  import { buildPropertyExpressionChain } from '../../stores/QueryBuilderValueSpecificationBuilderHelper.js';
113
114
  import { QueryBuilderPanelIssueCountBadge } from '../shared/QueryBuilderPanelIssueCountBadge.js';
115
+ import { convertTextToPrimitiveInstanceValue } from '../../stores/shared/ValueSpecificationEditorHelper.js';
114
116
 
115
117
  const isCollectionProperty = (
116
118
  propertyExpression: AbstractPropertyExpression,
@@ -771,11 +773,17 @@ const QueryBuilderFilterConditionEditor = observer(
771
773
  };
772
774
  const debouncedTypeaheadSearch = useMemo(
773
775
  () =>
774
- debounce(
775
- (inputVal: string) => node.condition.handleTypeaheadSearch(),
776
- 1000,
777
- ),
778
- [node],
776
+ debounce((inputValue: string) => {
777
+ const inputValueSpec = convertTextToPrimitiveInstanceValue(
778
+ PrimitiveType.STRING,
779
+ inputValue,
780
+ queryBuilderState.observerContext,
781
+ );
782
+ return node.condition.handleTypeaheadSearch(
783
+ inputValueSpec ?? undefined,
784
+ );
785
+ }, 1000),
786
+ [node, queryBuilderState.observerContext],
779
787
  );
780
788
  const cleanUpReloadValues = (): void => {
781
789
  node.condition.typeaheadSearchState.complete();
@@ -204,7 +204,15 @@ export const QueryBuilderResultPanel = observer(
204
204
  const runQuery = (): void => {
205
205
  resultState.setSelectedCells([]);
206
206
  resultState.pressedRunQuery.inProgress();
207
- if (queryParametersState.parameterStates.length) {
207
+ if (
208
+ queryParametersState.parameterStates.length &&
209
+ queryParametersState.parameterStates.find(
210
+ (param) =>
211
+ !queryBuilderState.milestoningState.isMilestoningParameter(
212
+ param.parameter,
213
+ ),
214
+ )
215
+ ) {
208
216
  queryParametersState.parameterValuesEditorState.open(
209
217
  (): Promise<void> =>
210
218
  flowResult(resultState.runQuery()).catch(