@finos/legend-query-builder 4.14.38 → 4.14.39
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/__lib__/QueryBuilderTesting.d.ts +2 -1
- package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
- package/lib/__lib__/QueryBuilderTesting.js +1 -0
- package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
- package/lib/components/QueryBuilderParametersPanel.js +2 -2
- package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
- package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts +0 -2
- package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
- package/lib/components/QueryBuilderPropertyExpressionEditor.js +10 -26
- package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +10 -9
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +3 -5
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.js +1 -2
- package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
- package/lib/components/shared/BasicValueSpecificationEditor.js +49 -8
- package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkState.js +0 -1
- package/lib/stores/watermark/QueryBuilderWatermarkState.js.map +1 -1
- package/package.json +8 -8
- package/src/__lib__/QueryBuilderTesting.ts +1 -0
- package/src/components/QueryBuilderParametersPanel.tsx +2 -2
- package/src/components/QueryBuilderPropertyExpressionEditor.tsx +40 -92
- package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +25 -31
- package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +5 -15
- package/src/components/filter/QueryBuilderFilterPanel.tsx +0 -11
- package/src/components/shared/BasicValueSpecificationEditor.tsx +141 -34
- package/src/stores/watermark/QueryBuilderWatermarkState.ts +0 -1
@@ -776,6 +776,98 @@ const setCollectionValue = (
|
|
776
776
|
instanceValue_setValues(valueSpecification, result, obseverContext);
|
777
777
|
};
|
778
778
|
|
779
|
+
const EnumCollectionInstanceValueEditor = observer(
|
780
|
+
(props: {
|
781
|
+
valueSpecification: CollectionInstanceValue;
|
782
|
+
observerContext: ObserverContext;
|
783
|
+
saveEdit: () => void;
|
784
|
+
}) => {
|
785
|
+
const { valueSpecification, observerContext, saveEdit } = props;
|
786
|
+
const applicationStore = useApplicationStore();
|
787
|
+
const enumType = guaranteeType(
|
788
|
+
valueSpecification.genericType?.value.rawType,
|
789
|
+
Enumeration,
|
790
|
+
);
|
791
|
+
|
792
|
+
const [selectedOptions, setSelectedOptions] = useState<
|
793
|
+
{ label: string; value: Enum }[]
|
794
|
+
>(
|
795
|
+
(valueSpecification.values as EnumValueInstanceValue[])
|
796
|
+
.filter((valueSpec) => valueSpec.values[0]?.value !== undefined)
|
797
|
+
.map((valueSpec) => ({
|
798
|
+
label: valueSpec.values[0]!.value.name,
|
799
|
+
value: valueSpec.values[0]!.value,
|
800
|
+
})),
|
801
|
+
);
|
802
|
+
|
803
|
+
const availableOptions = enumType.values
|
804
|
+
.filter(
|
805
|
+
(value) =>
|
806
|
+
!selectedOptions.some(
|
807
|
+
(selectedValue) => selectedValue.value.name === value.name,
|
808
|
+
),
|
809
|
+
)
|
810
|
+
.map((value) => ({
|
811
|
+
label: value.name,
|
812
|
+
value: value,
|
813
|
+
}));
|
814
|
+
|
815
|
+
const changeValue = (
|
816
|
+
newSelectedOptions: { value: Enum; label: string }[],
|
817
|
+
): void => {
|
818
|
+
setSelectedOptions(newSelectedOptions);
|
819
|
+
};
|
820
|
+
|
821
|
+
const updateValueSpecAndSaveEdit = (): void => {
|
822
|
+
const result = selectedOptions
|
823
|
+
.map((value) => {
|
824
|
+
const enumValueInstanceValue = new EnumValueInstanceValue(
|
825
|
+
GenericTypeExplicitReference.create(new GenericType(enumType)),
|
826
|
+
);
|
827
|
+
instanceValue_setValues(
|
828
|
+
enumValueInstanceValue,
|
829
|
+
[EnumValueExplicitReference.create(value.value)],
|
830
|
+
observerContext,
|
831
|
+
);
|
832
|
+
return enumValueInstanceValue;
|
833
|
+
})
|
834
|
+
.filter(isNonNullable);
|
835
|
+
instanceValue_setValues(valueSpecification, result, observerContext);
|
836
|
+
saveEdit();
|
837
|
+
};
|
838
|
+
|
839
|
+
return (
|
840
|
+
<>
|
841
|
+
<CustomSelectorInput
|
842
|
+
className="value-spec-editor__enum-collection-selector"
|
843
|
+
options={availableOptions}
|
844
|
+
isMulti={true}
|
845
|
+
onChange={changeValue}
|
846
|
+
onBlur={updateValueSpecAndSaveEdit}
|
847
|
+
onKeyDown={(event: KeyboardEvent): void => {
|
848
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
849
|
+
updateValueSpecAndSaveEdit();
|
850
|
+
}
|
851
|
+
}}
|
852
|
+
value={selectedOptions}
|
853
|
+
darkMode={
|
854
|
+
!applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
|
855
|
+
}
|
856
|
+
placeholder="Select value"
|
857
|
+
autoFocus={true}
|
858
|
+
menuIsOpen={true}
|
859
|
+
/>
|
860
|
+
<button
|
861
|
+
className="value-spec-editor__list-editor__save-button btn--dark"
|
862
|
+
onClick={updateValueSpecAndSaveEdit}
|
863
|
+
>
|
864
|
+
<SaveIcon />
|
865
|
+
</button>
|
866
|
+
</>
|
867
|
+
);
|
868
|
+
},
|
869
|
+
);
|
870
|
+
|
779
871
|
const COLLECTION_PREVIEW_CHAR_LIMIT = 50;
|
780
872
|
|
781
873
|
const getPlaceHolder = (expectedType: Type): string => {
|
@@ -836,6 +928,11 @@ const CollectionValueInstanceValueEditor = observer(
|
|
836
928
|
if (editable) {
|
837
929
|
setEditable(false);
|
838
930
|
setShowAdvancedEditorPopover(false);
|
931
|
+
setValueSpecification(valueSpecification);
|
932
|
+
}
|
933
|
+
};
|
934
|
+
const updateValueSpecAndSaveEdit = (): void => {
|
935
|
+
if (editable) {
|
839
936
|
setCollectionValue(
|
840
937
|
valueSpecification,
|
841
938
|
expectedType,
|
@@ -843,7 +940,7 @@ const CollectionValueInstanceValueEditor = observer(
|
|
843
940
|
obseverContext,
|
844
941
|
);
|
845
942
|
setText(stringifyValue(valueSpecification.values));
|
846
|
-
|
943
|
+
saveEdit();
|
847
944
|
}
|
848
945
|
};
|
849
946
|
|
@@ -861,7 +958,7 @@ const CollectionValueInstanceValueEditor = observer(
|
|
861
958
|
(event.relatedTarget as HTMLButtonElement | undefined)?.name !==
|
862
959
|
expandButtonName
|
863
960
|
) {
|
864
|
-
|
961
|
+
updateValueSpecAndSaveEdit();
|
865
962
|
}
|
866
963
|
};
|
867
964
|
|
@@ -891,7 +988,7 @@ const CollectionValueInstanceValueEditor = observer(
|
|
891
988
|
onChange={changeValueTextArea}
|
892
989
|
onKeyDown={(event): void => {
|
893
990
|
if (event.key === 'Enter' && !event.shiftKey) {
|
894
|
-
|
991
|
+
updateValueSpecAndSaveEdit();
|
895
992
|
}
|
896
993
|
}}
|
897
994
|
/>
|
@@ -903,37 +1000,47 @@ const CollectionValueInstanceValueEditor = observer(
|
|
903
1000
|
</BasePopover>
|
904
1001
|
)}
|
905
1002
|
<div className={clsx('value-spec-editor', className)}>
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
1003
|
+
{expectedType instanceof Enumeration ? (
|
1004
|
+
<EnumCollectionInstanceValueEditor
|
1005
|
+
valueSpecification={valueSpecification}
|
1006
|
+
observerContext={obseverContext}
|
1007
|
+
saveEdit={saveEdit}
|
1008
|
+
/>
|
1009
|
+
) : (
|
1010
|
+
<>
|
1011
|
+
<textarea
|
1012
|
+
ref={inputRef}
|
1013
|
+
className={clsx(
|
1014
|
+
'panel__content__form__section__input value-spec-editor__input value-spec-editor__textarea ',
|
1015
|
+
)}
|
1016
|
+
spellCheck={false}
|
1017
|
+
value={text}
|
1018
|
+
placeholder={placeholder}
|
1019
|
+
onChange={changeValueTextArea}
|
1020
|
+
onKeyDown={(event): void => {
|
1021
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
1022
|
+
updateValueSpecAndSaveEdit();
|
1023
|
+
}
|
1024
|
+
}}
|
1025
|
+
onBlur={handleOnBlur}
|
1026
|
+
/>
|
1027
|
+
<button
|
1028
|
+
className="value-spec-editor__list-editor__expand-button btn--dark"
|
1029
|
+
onClick={() => setShowAdvancedEditorPopover(true)}
|
1030
|
+
tabIndex={-1}
|
1031
|
+
name={expandButtonName}
|
1032
|
+
title="Expand window..."
|
1033
|
+
>
|
1034
|
+
<FilledWindowMaximizeIcon />
|
1035
|
+
</button>
|
1036
|
+
<button
|
1037
|
+
className="value-spec-editor__list-editor__save-button btn--dark"
|
1038
|
+
onClick={saveEdit}
|
1039
|
+
>
|
1040
|
+
<SaveIcon />
|
1041
|
+
</button>
|
1042
|
+
</>
|
1043
|
+
)}
|
937
1044
|
<button
|
938
1045
|
className="value-spec-editor__reset-btn"
|
939
1046
|
name="Reset"
|