@finos/legend-query-builder 4.14.38 → 4.14.40
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/QueryBuilder.d.ts.map +1 -1
- package/lib/components/QueryBuilder.js +1 -1
- package/lib/components/QueryBuilder.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 +5 -5
- package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +1 -0
- package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +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 +13 -13
- package/src/__lib__/QueryBuilderTesting.ts +1 -0
- package/src/components/QueryBuilder.tsx +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/QueryBuilder_LegendApplicationPlugin_Extension.ts +1 -0
- package/src/stores/watermark/QueryBuilderWatermarkState.ts +0 -1
@@ -60,7 +60,6 @@ import {
|
|
60
60
|
import { useDrag, useDragLayer, useDrop } from 'react-dnd';
|
61
61
|
import {
|
62
62
|
type QueryBuilderExplorerTreeDragSource,
|
63
|
-
type QueryBuilderExplorerTreePropertyNodeData,
|
64
63
|
buildPropertyExpressionFromExplorerTreeNodeData,
|
65
64
|
QUERY_BUILDER_EXPLORER_TREE_DND_TYPE,
|
66
65
|
} from '../../stores/explorer/QueryBuilderExplorerState.js';
|
@@ -729,15 +728,6 @@ const QueryBuilderFilterConditionEditor = observer(
|
|
729
728
|
const applicationStore = useApplicationStore();
|
730
729
|
const changeOperator = (val: QueryBuilderFilterOperator) => (): void =>
|
731
730
|
node.condition.changeOperator(val);
|
732
|
-
const changeProperty = (
|
733
|
-
propertyNode: QueryBuilderExplorerTreePropertyNodeData,
|
734
|
-
): void =>
|
735
|
-
node.condition.changeProperty(
|
736
|
-
buildPropertyExpressionFromExplorerTreeNodeData(
|
737
|
-
propertyNode,
|
738
|
-
queryBuilderState.explorerState,
|
739
|
-
),
|
740
|
-
);
|
741
731
|
// Drag and Drop on filter condition value
|
742
732
|
const handleDrop = useCallback(
|
743
733
|
(item: QueryBuilderVariableDragSource): void => {
|
@@ -815,7 +805,6 @@ const QueryBuilderFilterConditionEditor = observer(
|
|
815
805
|
<div className="query-builder-filter-tree__condition-node__property">
|
816
806
|
<QueryBuilderPropertyExpressionBadge
|
817
807
|
propertyExpressionState={node.condition.propertyExpressionState}
|
818
|
-
onPropertyExpressionChange={changeProperty}
|
819
808
|
/>
|
820
809
|
</div>
|
821
810
|
<DropdownMenu
|
@@ -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"
|
@@ -86,6 +86,7 @@ export type QueryBuilderHeaderActionConfiguration = {
|
|
86
86
|
export type QueryBuilderMenuActionConfiguration = {
|
87
87
|
key: string;
|
88
88
|
title?: string;
|
89
|
+
disableFunc?: (queryBuilderState: QueryBuilderState) => void;
|
89
90
|
label: string;
|
90
91
|
onClick: (queryBuilderState: QueryBuilderState) => void;
|
91
92
|
icon?: React.ReactNode;
|