@adaptabletools/adaptable-cjs 18.0.17 → 18.1.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agGrid.d.ts +4 -3
- package/agGrid.js +6 -1
- package/base.css +7 -2
- package/base.css.map +1 -1
- package/index.css +11 -2
- package/index.css.map +1 -1
- package/package.json +2 -2
- package/src/AdaptableInterfaces/IAdaptable.d.ts +3 -4
- package/src/AdaptableOptions/ActionColumnOptions.d.ts +1 -1
- package/src/AdaptableOptions/ColumnFilterOptions.d.ts +52 -11
- package/src/AdaptableOptions/ExportOptions.d.ts +20 -7
- package/src/AdaptableOptions/ExpressionOptions.d.ts +12 -2
- package/src/AdaptableOptions/Fdc3Options.d.ts +48 -43
- package/src/Api/ColumnApi.d.ts +5 -0
- package/src/Api/Events/Fdc3MessageInfo.d.ts +5 -7
- package/src/Api/ExpressionApi.d.ts +2 -2
- package/src/Api/Fdc3Api.d.ts +14 -19
- package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
- package/src/Api/Implementation/ColumnApiImpl.js +3 -0
- package/src/Api/Implementation/ConfigApiImpl.js +3 -0
- package/src/Api/Implementation/Fdc3ApiImpl.d.ts +14 -16
- package/src/Api/Implementation/Fdc3ApiImpl.js +35 -11
- package/src/Api/Internal/AlertInternalApi.d.ts +17 -2
- package/src/Api/Internal/AlertInternalApi.js +196 -25
- package/src/Api/Internal/ColumnFilterInternalApi.d.ts +2 -0
- package/src/Api/Internal/ColumnFilterInternalApi.js +20 -0
- package/src/Api/Internal/ExportInternalApi.d.ts +3 -3
- package/src/Api/Internal/ExportInternalApi.js +31 -17
- package/src/Api/Internal/ExpressionInternalApi.d.ts +5 -1
- package/src/Api/Internal/ExpressionInternalApi.js +80 -0
- package/src/Api/Internal/Fdc3InternalApi.d.ts +8 -10
- package/src/Api/Internal/Fdc3InternalApi.js +5 -9
- package/src/Api/Internal/GridInternalApi.d.ts +29 -13
- package/src/Api/Internal/GridInternalApi.js +129 -39
- package/src/PredefinedConfig/Common/AdaptableField.d.ts +18 -0
- package/src/PredefinedConfig/Common/AdaptableField.js +2 -0
- package/src/PredefinedConfig/Common/AdaptableIcon.d.ts +1 -1
- package/src/PredefinedConfig/Common/AdaptablePredicate.js +22 -1
- package/src/PredefinedConfig/Common/Fdc3Context.d.ts +7 -226
- package/src/PredefinedConfig/Common/Fdc3Context.js +44 -32
- package/src/PredefinedConfig/Common/Fdc3Intent.d.ts +6 -89
- package/src/PredefinedConfig/Common/Fdc3Intent.js +27 -74
- package/src/PredefinedConfig/Common/RowSummary.d.ts +2 -1
- package/src/PredefinedConfig/StyledColumnState.d.ts +1 -1
- package/src/Redux/ActionsReducers/FormatColumnRedux.js +0 -3
- package/src/Strategy/AdaptableModuleBase.js +1 -3
- package/src/Strategy/AlertModule.d.ts +1 -1
- package/src/Strategy/AlertModule.js +8 -8
- package/src/Utilities/Constants/DocumentationLinkConstants.js +4 -4
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +3 -1
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +14 -13
- package/src/Utilities/Services/Fdc3Service.d.ts +1 -1
- package/src/Utilities/Services/QueryLanguageService.d.ts +8 -4
- package/src/Utilities/Services/QueryLanguageService.js +105 -6
- package/src/Utilities/Services/ReportService.js +8 -5
- package/src/Utilities/Services/RowSummaryService.js +3 -1
- package/src/Utilities/divideBy100.d.ts +1 -0
- package/src/Utilities/divideBy100.js +34 -0
- package/src/Utilities/times100.d.ts +1 -0
- package/src/Utilities/times100.js +27 -0
- package/src/View/Alert/Wizard/AlertMessageWizardSection.js +1 -1
- package/src/View/Alert/Wizard/AlertNotificationWizardSection.js +2 -2
- package/src/View/Alert/Wizard/AlertScopeWizardSection.js +2 -1
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +1 -1
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnTypeSection.js +5 -5
- package/src/View/Components/EntityRulesEditor/index.d.ts +1 -0
- package/src/View/Components/EntityRulesEditor/index.js +11 -7
- package/src/View/Components/ExpressionWizard.js +1 -1
- package/src/View/Components/FilterForm/FilterForm.js +2 -2
- package/src/View/Components/FilterForm/ListBoxFilterForm.js +2 -1
- package/src/View/Components/FilterForm/QuickFilterValues.d.ts +1 -1
- package/src/View/Components/FilterForm/QuickFilterValues.js +5 -5
- package/src/View/Components/Popups/AdaptablePopup/AdaptablePopupModuleView.js +6 -2
- package/src/View/Components/Selectors/FieldSelector.d.ts +13 -0
- package/src/View/Components/Selectors/FieldSelector.js +26 -0
- package/src/View/Components/Selectors/PermittedValuesSelector.js +9 -5
- package/src/View/Export/Wizard/ReportRowsWizardSection.js +1 -1
- package/src/View/FormatColumn/Wizard/FormatColumnRuleWizardSection.js +1 -1
- package/src/View/GridFilter/GridFilterExpressionEditor.js +1 -1
- package/src/View/Layout/Wizard/sections/GridFilterSection.js +4 -2
- package/src/View/Layout/Wizard/sections/RowSummarySection.js +7 -1
- package/src/View/NamedQuery/Wizard/NamedQueryExpressionWizardSection.js +1 -1
- package/src/View/Wizard/OnePageAdaptableWizard.js +3 -2
- package/src/agGrid/AdaptableAgGrid.d.ts +4 -6
- package/src/agGrid/AdaptableAgGrid.js +66 -47
- package/src/agGrid/AgGridColumnAdapter.d.ts +3 -0
- package/src/agGrid/AgGridColumnAdapter.js +24 -1
- package/src/agGrid/AgGridMenuAdapter.js +1 -1
- package/src/agGrid/FilterWrapper.js +12 -7
- package/src/agGrid/defaultAdaptableOptions.js +2 -2
- package/src/agGrid/editors/AdaptableDateEditor/InternalAdaptableDateEditor.d.ts +0 -1
- package/src/agGrid/editors/AdaptableDateEditor/InternalAdaptableDateEditor.js +0 -2
- package/src/agGrid/editors/AdaptableDateEditor/index.d.ts +4 -16
- package/src/agGrid/editors/AdaptableDateEditor/index.js +6 -19
- package/src/agGrid/editors/AdaptableNumberEditor/InternalAdaptableNumberEditor.js +6 -1
- package/src/agGrid/editors/AdaptableNumberEditor/index.d.ts +4 -3
- package/src/agGrid/editors/AdaptableNumberEditor/index.js +6 -2
- package/src/agGrid/editors/AdaptablePercentageEditor/InternalAdaptablePercentageEditor.d.ts +23 -0
- package/src/agGrid/editors/AdaptablePercentageEditor/InternalAdaptablePercentageEditor.js +84 -0
- package/src/agGrid/editors/AdaptablePercentageEditor/index.d.ts +47 -0
- package/src/agGrid/editors/AdaptablePercentageEditor/index.js +153 -0
- package/src/components/Accordion.js +1 -1
- package/src/components/Datepicker/DatepickerContext.d.ts +0 -2
- package/src/components/Datepicker/index.js +3 -4
- package/src/components/ExpressionEditor/DataTableEditor.d.ts +17 -0
- package/src/components/ExpressionEditor/DataTableEditor.js +68 -0
- package/src/components/ExpressionEditor/EditorInput.js +21 -8
- package/src/components/ExpressionEditor/NamedQueryEditor.d.ts +5 -0
- package/src/components/ExpressionEditor/NamedQueryEditor.js +35 -0
- package/src/components/ExpressionEditor/QueryBuilder/QueryBuilder.d.ts +10 -0
- package/src/components/ExpressionEditor/QueryBuilder/QueryBuilder.js +7 -4
- package/src/components/ExpressionEditor/QueryBuilder/QueryBuilderInputs.d.ts +3 -2
- package/src/components/ExpressionEditor/QueryBuilder/QueryBuilderInputs.js +72 -14
- package/src/components/ExpressionEditor/QueryBuilder/QueryPredicateBuilder.js +27 -19
- package/src/components/ExpressionEditor/QueryBuilder/utils.d.ts +9 -1
- package/src/components/ExpressionEditor/QueryBuilder/utils.js +46 -4
- package/src/components/ExpressionEditor/index.d.ts +3 -1
- package/src/components/ExpressionEditor/index.js +68 -95
- package/src/components/Input/NumberInput.d.ts +2 -1
- package/src/components/Input/NumberInput.js +6 -5
- package/src/components/OverlayTrigger/index.js +10 -6
- package/src/components/icons/column-outline.d.ts +3 -0
- package/src/components/icons/column-outline.js +7 -0
- package/src/components/icons/index.js +5 -1
- package/src/components/icons/sync.d.ts +3 -0
- package/src/components/icons/sync.js +7 -0
- package/src/env.js +2 -2
- package/src/metamodel/adaptable.metamodel.d.ts +121 -200
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/src/parser/src/predicate/mapExpressionToQlPredicate.d.ts +1 -0
- package/src/parser/src/predicate/mapExpressionToQlPredicate.js +14 -3
- package/src/parser/src/predicate/mapQlPredicateToExpression.js +4 -1
- package/src/parser/src/types.d.ts +101 -1
- package/src/types.d.ts +8 -6
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -59,7 +59,8 @@ const QueryBuilder = (props) => {
|
|
|
59
59
|
}, []);
|
|
60
60
|
const context = React.useMemo(() => {
|
|
61
61
|
return {
|
|
62
|
-
|
|
62
|
+
getColumns: props.getColumns,
|
|
63
|
+
getFields: props.getFields,
|
|
63
64
|
getExpressions: (columnType) => {
|
|
64
65
|
return booleanExpressions
|
|
65
66
|
? (0, utils_1.getFunctionsForColumnType)(columnType, Object.keys(booleanExpressions))
|
|
@@ -71,10 +72,12 @@ const QueryBuilder = (props) => {
|
|
|
71
72
|
const clearExpressionButton = (React.createElement(SimpleButton_1.default, { onClick: () => {
|
|
72
73
|
clearExpression();
|
|
73
74
|
} }, "Clear Expression"));
|
|
74
|
-
const unsupportedExpressionFunction = (0, utils_1.getUnsuportedExpressionFromQlPredicate)(qlPredicate
|
|
75
|
+
const unsupportedExpressionFunction = (0, utils_1.getUnsuportedExpressionFromQlPredicate)(qlPredicate, {
|
|
76
|
+
supportedFields: props.getFields(),
|
|
77
|
+
});
|
|
75
78
|
let errorOrEditor = null;
|
|
76
79
|
if (qlPredicate && 'errorMessage' in qlPredicate) {
|
|
77
|
-
errorOrEditor = ((_b = (_a = props.query) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, 'QUERY')) ? (React.createElement(WarningBox_1.WarningBox,
|
|
80
|
+
errorOrEditor = ((_b = (_a = props.query) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, 'QUERY')) ? (React.createElement(WarningBox_1.WarningBox, { "data-name": "unsupported-query-warning" },
|
|
78
81
|
React.createElement(rebass_1.Flex, { alignItems: "center" },
|
|
79
82
|
"Named Queries are not supported in the Query Builder",
|
|
80
83
|
React.createElement(rebass_1.Box, { flex: 1 }),
|
|
@@ -85,7 +88,7 @@ const QueryBuilder = (props) => {
|
|
|
85
88
|
clearExpressionButton)));
|
|
86
89
|
}
|
|
87
90
|
else if (unsupportedExpressionFunction) {
|
|
88
|
-
errorOrEditor = React.createElement(WarningBox_1.WarningBox,
|
|
91
|
+
errorOrEditor = (React.createElement(WarningBox_1.WarningBox, { "data-name": "unsupported-expression-warning" }, unsupportedExpressionFunction));
|
|
89
92
|
}
|
|
90
93
|
else if (qlPredicate && !('errorMessage' in qlPredicate)) {
|
|
91
94
|
errorOrEditor = (React.createElement(QueryPredicateBuilder_1.QueryPredicateBuilder, { isRoot: true, index: 0, id: "0", predicate: qlPredicate, onNewPredicate: (type) => {
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import { QlLogicalOperator } from '../../../parser/src/predicate';
|
|
3
3
|
import { ExpressionFunctionInputType } from '../../../parser/src/types';
|
|
4
4
|
import { AdaptableColumn, AdaptableColumnDataType, BooleanFunctionName } from '../../../types';
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
5
|
+
export declare const PrimitiveColumnOrFieldSelector: (props: {
|
|
6
|
+
fieldOrColumn: string;
|
|
7
7
|
type?: AdaptableColumnDataType;
|
|
8
8
|
onChange: (colId: string) => void;
|
|
9
|
+
hideFields?: boolean;
|
|
9
10
|
}) => JSX.Element;
|
|
10
11
|
export declare const PrimiteValueInput: (props: {
|
|
11
12
|
inputType: ExpressionFunctionInputType;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CombinatorSelector = exports.ExpressionSelector = exports.PrimitiveMultiValueInput = exports.PrimiteValueInput = exports.
|
|
3
|
+
exports.CombinatorSelector = exports.ExpressionSelector = exports.PrimitiveMultiValueInput = exports.PrimiteValueInput = exports.PrimitiveColumnOrFieldSelector = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const rebass_1 = require("rebass");
|
|
7
7
|
const mapQlPredicateToExpression_1 = require("../../../parser/src/predicate/mapQlPredicateToExpression");
|
|
8
|
+
const AdaptableContext_1 = require("../../../View/AdaptableContext");
|
|
8
9
|
const AdaptableInput_1 = tslib_1.__importDefault(require("../../../View/Components/AdaptableInput"));
|
|
9
10
|
const ColumnSelector_1 = require("../../../View/Components/Selectors/ColumnSelector");
|
|
11
|
+
const FieldSelector_1 = require("../../../View/Components/Selectors/FieldSelector");
|
|
10
12
|
const PermittedValuesSelector_1 = require("../../../View/Components/Selectors/PermittedValuesSelector");
|
|
11
13
|
const CheckBox_1 = require("../../CheckBox");
|
|
12
14
|
const DropdownButton_1 = tslib_1.__importDefault(require("../../DropdownButton"));
|
|
@@ -15,20 +17,61 @@ const InputGroup_1 = require("../../InputGroup");
|
|
|
15
17
|
const Select_1 = require("../../Select");
|
|
16
18
|
const QueryBuilder_1 = require("./QueryBuilder");
|
|
17
19
|
const utils_1 = require("./utils");
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const PrimitiveColumnOrFieldSelector = (props) => {
|
|
21
|
+
const adaptable = (0, AdaptableContext_1.useAdaptable)();
|
|
22
|
+
const [type, setType] = react_1.default.useState(() => {
|
|
23
|
+
return (
|
|
24
|
+
// default to column
|
|
25
|
+
(!props.fieldOrColumn || props.fieldOrColumn.includes('[') ? 'column' : 'field')
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
const hasFields = react_1.default.useMemo(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
return ((_a = adaptable.api.expressionApi.internalApi.getAvailableFields()) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
31
|
+
}, []);
|
|
32
|
+
const hasFieldsOrValueIsField = hasFields || (0, utils_1.isFieldValue)(props.fieldOrColumn);
|
|
33
|
+
let input = null;
|
|
34
|
+
if (type === 'column') {
|
|
35
|
+
const columnId = (0, utils_1.mapColumnExpressionToColumnId)(props.fieldOrColumn);
|
|
36
|
+
input = (react_1.default.createElement(ColumnSelector_1.ColumnSelector, { value: columnId, type: props.type, onChange: (columnId) => {
|
|
21
37
|
props.onChange(`[${columnId}]`);
|
|
22
|
-
} }))
|
|
38
|
+
} }));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
input = (react_1.default.createElement(FieldSelector_1.FieldSelector, { value: (0, utils_1.mapExpressionToFieldValue)(props.fieldOrColumn), type: props.type, onChange: (fieldValue) => {
|
|
42
|
+
props.onChange((0, utils_1.mapFieldValueToExpression)(fieldValue));
|
|
43
|
+
} }));
|
|
44
|
+
}
|
|
45
|
+
const typeOptions = [
|
|
46
|
+
{ label: 'Column', value: 'column', icon: 'grid' },
|
|
47
|
+
{ label: 'Field', value: 'field', icon: 'column-outline' },
|
|
48
|
+
];
|
|
49
|
+
return !hasFieldsOrValueIsField || props.hideFields ? (react_1.default.createElement(rebass_1.Box, null, input)) : (react_1.default.createElement(InputGroup_1.InputGroup, { Component: rebass_1.Flex, "data-id": "query-first-arg-wrapper" },
|
|
50
|
+
react_1.default.createElement(Select_1.Select, { renderSingleValue: (value) => {
|
|
51
|
+
return react_1.default.createElement(react_1.default.Fragment, null, type === 'column' ? react_1.default.createElement(icons_1.Icon, { name: "grid" }) : react_1.default.createElement(icons_1.Icon, { name: "column-outline" }));
|
|
52
|
+
}, value: type, options: typeOptions, onChange: (value) => {
|
|
53
|
+
props.onChange(null);
|
|
54
|
+
setType(value);
|
|
55
|
+
} }),
|
|
56
|
+
input));
|
|
23
57
|
};
|
|
24
|
-
exports.
|
|
58
|
+
exports.PrimitiveColumnOrFieldSelector = PrimitiveColumnOrFieldSelector;
|
|
25
59
|
const PrimiteValueInput = (props) => {
|
|
26
|
-
|
|
27
|
-
const
|
|
60
|
+
const adaptable = (0, AdaptableContext_1.useAdaptable)();
|
|
61
|
+
const hasFields = react_1.default.useMemo(() => {
|
|
28
62
|
var _a;
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
63
|
+
return ((_a = adaptable.api.expressionApi.internalApi.getAvailableFields()) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
64
|
+
}, []);
|
|
65
|
+
const hasFieldsOrValueIsField = hasFields || (0, utils_1.isFieldValue)(props.value);
|
|
66
|
+
const [type, setType] = react_1.default.useState(() => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
if (typeof (props === null || props === void 0 ? void 0 : props.value) === 'string' && ((_a = props === null || props === void 0 ? void 0 : props.value) === null || _a === void 0 ? void 0 : _a.includes('['))) {
|
|
69
|
+
return 'column-name';
|
|
70
|
+
}
|
|
71
|
+
if (typeof (props === null || props === void 0 ? void 0 : props.value) === 'string' && ((_b = props === null || props === void 0 ? void 0 : props.value) === null || _b === void 0 ? void 0 : _b.includes('FIELD'))) {
|
|
72
|
+
return 'field';
|
|
73
|
+
}
|
|
74
|
+
return 'input-value';
|
|
32
75
|
});
|
|
33
76
|
const handleTypeChange = (newType) => {
|
|
34
77
|
if (type !== newType) {
|
|
@@ -72,12 +115,18 @@ const PrimiteValueInput = (props) => {
|
|
|
72
115
|
};
|
|
73
116
|
let editor = null;
|
|
74
117
|
if (type === 'column-name') {
|
|
75
|
-
const columnId = props.value ? (_b = (_a = props === null || props === void 0 ? void 0 : props.value) === null || _a === void 0 ? void 0 : _a.replace) === null || _b === void 0 ? void 0 : _b.call(_a, '[', '').replace(']', '') : undefined;
|
|
76
118
|
const abColType = (0, utils_1.mapExpressionFunctionTypeToColumnDataType)(props.inputType);
|
|
77
|
-
editor = (react_1.default.createElement(exports.
|
|
119
|
+
editor = (react_1.default.createElement(exports.PrimitiveColumnOrFieldSelector, { hideFields: true, fieldOrColumn: props.value, type: abColType, onChange: (columnId) => {
|
|
120
|
+
props.onChange(columnId);
|
|
121
|
+
} }));
|
|
122
|
+
}
|
|
123
|
+
else if (type === 'field') {
|
|
124
|
+
editor = (react_1.default.createElement(FieldSelector_1.FieldSelector, { value: (0, utils_1.mapExpressionToFieldValue)(props.value), onChange: (fieldValue) => {
|
|
125
|
+
props.onChange((0, utils_1.mapFieldValueToExpression)(fieldValue));
|
|
126
|
+
} }));
|
|
78
127
|
}
|
|
79
128
|
else if (!['date', 'boolean'].includes(props.inputType)) {
|
|
80
|
-
editor = (react_1.default.createElement(PermittedValuesSelector_1.PermittedValuesSelector, { allowNewValues: true, value: props.value, columnId: props.lefthandColumnIdParam, onChange: (value) => {
|
|
129
|
+
editor = (react_1.default.createElement(PermittedValuesSelector_1.PermittedValuesSelector, { allowNewValues: true, value: props.value, columnId: (0, utils_1.mapColumnExpressionToColumnId)(props.lefthandColumnIdParam), onChange: (value) => {
|
|
81
130
|
props.onChange(value);
|
|
82
131
|
} }));
|
|
83
132
|
}
|
|
@@ -100,6 +149,15 @@ const PrimiteValueInput = (props) => {
|
|
|
100
149
|
value: 'input-value',
|
|
101
150
|
},
|
|
102
151
|
];
|
|
152
|
+
if (hasFieldsOrValueIsField || type === 'field') {
|
|
153
|
+
options.push({
|
|
154
|
+
label: (react_1.default.createElement(rebass_1.Flex, null,
|
|
155
|
+
react_1.default.createElement(icons_1.Icon, { name: "column-outline" }),
|
|
156
|
+
react_1.default.createElement(rebass_1.Text, { ml: 2 }, "Field"))),
|
|
157
|
+
icon: 'column-outline',
|
|
158
|
+
value: 'field',
|
|
159
|
+
});
|
|
160
|
+
}
|
|
103
161
|
const typeOption = options.find((option) => option.value === type);
|
|
104
162
|
return (react_1.default.createElement(InputGroup_1.InputGroup, { Component: rebass_1.Flex, "data-id": "query-input-wrapper", mr: 2 },
|
|
105
163
|
react_1.default.createElement(Select_1.Select, { renderSingleValue: (value) => {
|
|
@@ -22,8 +22,8 @@ const Handle = (props) => (react_1.default.createElement(rebass_1.Flex, Object.a
|
|
|
22
22
|
const QueryPredicateButtons = (props) => {
|
|
23
23
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
24
24
|
!props.hideAdd && (react_1.default.createElement(DropdownButton_1.default, { listMinWidth: 150, columns: ['label'], items: [
|
|
25
|
-
{ label: '
|
|
26
|
-
{ label: '
|
|
25
|
+
{ label: 'Condition', onClick: () => props.onNewPredicate('filter') },
|
|
26
|
+
{ label: 'AND / OR Group', onClick: () => props.onNewPredicate('group') },
|
|
27
27
|
], variant: "text" },
|
|
28
28
|
react_1.default.createElement(icons_1.Icon, { name: "plus" }))),
|
|
29
29
|
!props.hideDelete && (react_1.default.createElement(SimpleButton_1.default, { icon: "delete", variant: "text", onClick: () => {
|
|
@@ -100,22 +100,31 @@ const PrimitiveFunctionEditor = (props) => {
|
|
|
100
100
|
var _a;
|
|
101
101
|
// [handle] [column] [operator-dropdown] [...args] [delete-button] [plus-button]
|
|
102
102
|
const adaptable = (0, AdaptableContext_1.useAdaptable)();
|
|
103
|
-
const [
|
|
104
|
-
const
|
|
105
|
-
let
|
|
106
|
-
let
|
|
103
|
+
const [columnOrFieldExpression, ...restOfArgs] = props.predicate.args;
|
|
104
|
+
const columnOrField = columnOrFieldExpression;
|
|
105
|
+
let columnOrFieldId = null;
|
|
106
|
+
let columnOrFieldDataType = null;
|
|
107
107
|
let columnInputDataType = null;
|
|
108
108
|
let functionInputInputDataTypes = null;
|
|
109
109
|
// Thsese are the type of inputs ommiting the column
|
|
110
110
|
// [[column-data-type], number, number]
|
|
111
111
|
let restOfFunctionInputDataTypes = [];
|
|
112
|
-
if (
|
|
113
|
-
if (
|
|
114
|
-
return react_1.default.createElement(ErrorBox_1.default, null, "Expression must start with a column!");
|
|
112
|
+
if (columnOrField) {
|
|
113
|
+
if (!(0, predicate_1.isArgumentColumnOrField)(columnOrField)) {
|
|
114
|
+
return react_1.default.createElement(ErrorBox_1.default, null, "Expression must start with a column or a filed!");
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
if (columnOrField.includes('FIELD')) {
|
|
117
|
+
// we let the full expression so we can difirienciate between column and field
|
|
118
|
+
columnOrFieldId = columnOrField;
|
|
119
|
+
const fieldValue = (0, utils_1.mapExpressionToFieldValue)(columnOrField);
|
|
120
|
+
columnOrFieldDataType = adaptable.api.expressionApi.internalApi.getFieldType(fieldValue);
|
|
121
|
+
}
|
|
122
|
+
else if (columnOrField.includes('[')) {
|
|
123
|
+
columnOrFieldId = columnOrField;
|
|
124
|
+
const columnId = columnOrField.replace(/[\[\]]/g, '');
|
|
125
|
+
columnOrFieldDataType = adaptable.api.columnApi.getColumnDataTypeForColumnId(columnId);
|
|
126
|
+
}
|
|
127
|
+
columnInputDataType = (0, adaptableQlUtils_1.mapColumnDataTypeToExpressionFunctionType)(columnOrFieldDataType);
|
|
119
128
|
functionInputInputDataTypes = (_a = booleanExpressionFunctions_1.booleanExpressionFunctions[props.predicate.operator]) === null || _a === void 0 ? void 0 : _a.inputs;
|
|
120
129
|
restOfFunctionInputDataTypes = functionInputInputDataTypes
|
|
121
130
|
? (0, utils_1.getOperatorMatchingInputs)(columnInputDataType, functionInputInputDataTypes)
|
|
@@ -132,12 +141,12 @@ const PrimitiveFunctionEditor = (props) => {
|
|
|
132
141
|
react_1.default.createElement(Handle, Object.assign({}, provided.dragHandleProps)),
|
|
133
142
|
react_1.default.createElement(rebass_1.Flex, { alignItems: "center", height: ITEM_HEIGHT },
|
|
134
143
|
react_1.default.createElement(rebass_1.Box, { mr: 2 },
|
|
135
|
-
react_1.default.createElement(QueryBuilderInputs_1.
|
|
136
|
-
props.onChange(Object.assign(Object.assign({}, props.predicate), { args: [
|
|
137
|
-
},
|
|
138
|
-
|
|
144
|
+
react_1.default.createElement(QueryBuilderInputs_1.PrimitiveColumnOrFieldSelector, { onChange: (colOrField) => {
|
|
145
|
+
props.onChange(Object.assign(Object.assign({}, props.predicate), { args: [colOrField], operator: null }));
|
|
146
|
+
}, fieldOrColumn: columnOrFieldId })),
|
|
147
|
+
columnOrFieldId && columnOrFieldDataType && (react_1.default.createElement(QueryBuilderInputs_1.ExpressionSelector, { dataType: columnOrFieldDataType, onExpressionChange: (operator) => {
|
|
139
148
|
let args = [props.predicate.args[0]];
|
|
140
|
-
if (
|
|
149
|
+
if (columnOrFieldDataType === 'Boolean' && operator !== 'NOT') {
|
|
141
150
|
args = [props.predicate.args[0], 'TRUE'];
|
|
142
151
|
}
|
|
143
152
|
props.onChange(Object.assign(Object.assign({}, props.predicate), { operator,
|
|
@@ -146,10 +155,9 @@ const PrimitiveFunctionEditor = (props) => {
|
|
|
146
155
|
}, value: props.predicate.operator })),
|
|
147
156
|
react_1.default.createElement(rebass_1.Flex, { flex: 1, ml: 2 }, restOfFunctionInputDataTypes.map((type, index) => {
|
|
148
157
|
var _a;
|
|
149
|
-
let value = restOfArgs[index];
|
|
150
158
|
const commonProps = {
|
|
151
159
|
key: type + index,
|
|
152
|
-
lefthandColumnIdParam:
|
|
160
|
+
lefthandColumnIdParam: columnOrFieldId,
|
|
153
161
|
inputType: type,
|
|
154
162
|
};
|
|
155
163
|
if (type.includes('[]')) {
|
|
@@ -5,4 +5,12 @@ export declare const reorder: (predicate: QlPredicate, from: string, to: string)
|
|
|
5
5
|
export declare const mapExpressionFunctionTypeToColumnDataType: (type: ExpressionFunctionInputType) => AdaptableColumnDataType;
|
|
6
6
|
export declare const getOperatorMatchingInputs: (columnType: ExpressionFunctionInputType, inputs: ExpressionFunctionInputType[] | Array<ExpressionFunctionInputType>[]) => ExpressionFunctionInputType[];
|
|
7
7
|
export declare const getFunctionsForColumnType: (dataType: AdaptableColumnDataType, availableBooleanFunctions: BooleanFunctionName[]) => BooleanFunctionName[];
|
|
8
|
-
export declare const getUnsuportedExpressionFromQlPredicate: (predicate: QlPredicate | QlPredicateError
|
|
8
|
+
export declare const getUnsuportedExpressionFromQlPredicate: (predicate: QlPredicate | QlPredicateError, context: {
|
|
9
|
+
supportedFields: {
|
|
10
|
+
value: string;
|
|
11
|
+
}[];
|
|
12
|
+
}) => string;
|
|
13
|
+
export declare const mapFieldValueToExpression: (field: string) => string;
|
|
14
|
+
export declare const mapExpressionToFieldValue: (expression: string) => string;
|
|
15
|
+
export declare const mapColumnExpressionToColumnId: (expression: string) => string;
|
|
16
|
+
export declare const isFieldValue: (expression: string) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUnsuportedExpressionFromQlPredicate = exports.getFunctionsForColumnType = exports.getOperatorMatchingInputs = exports.mapExpressionFunctionTypeToColumnDataType = exports.reorder = void 0;
|
|
3
|
+
exports.isFieldValue = exports.mapColumnExpressionToColumnId = exports.mapExpressionToFieldValue = exports.mapFieldValueToExpression = exports.getUnsuportedExpressionFromQlPredicate = exports.getFunctionsForColumnType = exports.getOperatorMatchingInputs = exports.mapExpressionFunctionTypeToColumnDataType = exports.reorder = void 0;
|
|
4
4
|
const adaptableQlUtils_1 = require("../../../Utilities/adaptableQlUtils");
|
|
5
5
|
const predicate_1 = require("../../../parser/src/predicate");
|
|
6
6
|
const booleanExpressionFunctions_1 = require("../../../Utilities/ExpressionFunctions/booleanExpressionFunctions");
|
|
@@ -50,7 +50,7 @@ exports.mapExpressionFunctionTypeToColumnDataType = mapExpressionFunctionTypeToC
|
|
|
50
50
|
const getOperatorMatchingInputs = (columnType, inputs) => {
|
|
51
51
|
if (Array.isArray(inputs[0])) {
|
|
52
52
|
const matchingInput = inputs.find((input) => input[0] === columnType);
|
|
53
|
-
const [_, ...restOfArgs] = matchingInput;
|
|
53
|
+
const [_, ...restOfArgs] = matchingInput !== null && matchingInput !== void 0 ? matchingInput : [];
|
|
54
54
|
return restOfArgs;
|
|
55
55
|
}
|
|
56
56
|
const [_, ...restOfArgs] = inputs;
|
|
@@ -76,10 +76,20 @@ const getFunctionsForColumnType = (dataType, availableBooleanFunctions) => {
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
exports.getFunctionsForColumnType = getFunctionsForColumnType;
|
|
79
|
-
const getUnsuportedExpressionFromQlPredicate = (predicate) => {
|
|
79
|
+
const getUnsuportedExpressionFromQlPredicate = (predicate, context) => {
|
|
80
|
+
var _a;
|
|
80
81
|
if (!predicate) {
|
|
81
82
|
return null;
|
|
82
83
|
}
|
|
84
|
+
if (typeof predicate === 'string' && (0, exports.isFieldValue)(predicate)) {
|
|
85
|
+
const field = (0, exports.mapExpressionToFieldValue)(predicate);
|
|
86
|
+
if (!((_a = context.supportedFields) === null || _a === void 0 ? void 0 : _a.some((field) => (field === null || field === void 0 ? void 0 : field.value) === (0, exports.mapExpressionToFieldValue)(predicate)))) {
|
|
87
|
+
return `Expression uses an unregistered field: "${field}"`;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
83
93
|
if (typeof predicate === 'object' && 'errorMessage' in predicate) {
|
|
84
94
|
return null;
|
|
85
95
|
}
|
|
@@ -95,7 +105,7 @@ const getUnsuportedExpressionFromQlPredicate = (predicate) => {
|
|
|
95
105
|
}
|
|
96
106
|
let firstInvalidArg = null;
|
|
97
107
|
for (let arg of predicate.args) {
|
|
98
|
-
firstInvalidArg = (0, exports.getUnsuportedExpressionFromQlPredicate)(arg);
|
|
108
|
+
firstInvalidArg = (0, exports.getUnsuportedExpressionFromQlPredicate)(arg, context);
|
|
99
109
|
if (firstInvalidArg) {
|
|
100
110
|
break;
|
|
101
111
|
}
|
|
@@ -106,3 +116,35 @@ const getUnsuportedExpressionFromQlPredicate = (predicate) => {
|
|
|
106
116
|
return null;
|
|
107
117
|
};
|
|
108
118
|
exports.getUnsuportedExpressionFromQlPredicate = getUnsuportedExpressionFromQlPredicate;
|
|
119
|
+
const mapFieldValueToExpression = (field) => `FIELD('${field}')`;
|
|
120
|
+
exports.mapFieldValueToExpression = mapFieldValueToExpression;
|
|
121
|
+
const mapExpressionToFieldValue = (expression) => {
|
|
122
|
+
var _a;
|
|
123
|
+
if (!expression) {
|
|
124
|
+
return '';
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
return (_a = expression.match(/FIELD\(['"](.+)['"]\)/)) === null || _a === void 0 ? void 0 : _a[1];
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
return '';
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
exports.mapExpressionToFieldValue = mapExpressionToFieldValue;
|
|
134
|
+
const mapColumnExpressionToColumnId = (expression) => {
|
|
135
|
+
var _a;
|
|
136
|
+
if (!expression) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
return (_a = expression.match(/\[(.+)\]/)) === null || _a === void 0 ? void 0 : _a[1];
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
return expression;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
exports.mapColumnExpressionToColumnId = mapColumnExpressionToColumnId;
|
|
147
|
+
const isFieldValue = (expression) => {
|
|
148
|
+
return typeof expression === 'string' && expression.includes('FIELD');
|
|
149
|
+
};
|
|
150
|
+
exports.isFieldValue = isFieldValue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { AdaptableApi, AdaptableColumn, AdaptableModule, NamedQuery } from '../../types';
|
|
2
|
+
import { AdaptableApi, AdaptableColumn, AdaptableField, AdaptableModule, NamedQuery } from '../../types';
|
|
3
3
|
export type ExpressionEditorType = 'boolean' | 'scalar' | 'observable' | 'aggregatedBoolean' | 'aggregatedScalar' | 'cumulativeAggregatedScalar' | 'quantileAggregatedScalar';
|
|
4
4
|
interface ExpressionEditorProps {
|
|
5
5
|
value: string;
|
|
@@ -10,6 +10,7 @@ interface ExpressionEditorProps {
|
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
};
|
|
12
12
|
columns: AdaptableColumn[];
|
|
13
|
+
fields?: AdaptableField[];
|
|
13
14
|
namedQueries: NamedQuery[];
|
|
14
15
|
allowSaveNamedQuery?: boolean;
|
|
15
16
|
style?: React.CSSProperties;
|
|
@@ -18,5 +19,6 @@ interface ExpressionEditorProps {
|
|
|
18
19
|
showQueryBuilder?: boolean;
|
|
19
20
|
showExpressionEditor?: boolean;
|
|
20
21
|
}
|
|
22
|
+
export declare const baseClassName = "ab-ExpressionEditor";
|
|
21
23
|
export declare function ExpressionEditor(props: ExpressionEditorProps): JSX.Element;
|
|
22
24
|
export {};
|
|
@@ -1,40 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExpressionEditor = void 0;
|
|
3
|
+
exports.ExpressionEditor = exports.baseClassName = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const React = tslib_1.__importStar(require("react"));
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const rebass_1 = require("rebass");
|
|
8
|
-
const CheckBox_1 = require("../CheckBox");
|
|
9
|
-
const FormLayout_1 = tslib_1.__importStar(require("../FormLayout"));
|
|
10
|
-
const HelpBlock_1 = tslib_1.__importDefault(require("../HelpBlock"));
|
|
11
|
-
const Input_1 = tslib_1.__importDefault(require("../Input"));
|
|
12
|
-
const EditorButton_1 = tslib_1.__importDefault(require("./EditorButton"));
|
|
13
|
-
const AdaptableInput_1 = tslib_1.__importDefault(require("../../View/Components/AdaptableInput"));
|
|
14
|
-
const Radio_1 = tslib_1.__importDefault(require("../Radio"));
|
|
15
|
-
const ArrayExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/ArrayExtensions"));
|
|
16
|
-
const EditorInputWithWhereClause_1 = tslib_1.__importDefault(require("./EditorInputWithWhereClause"));
|
|
17
|
-
const EditorInput_1 = tslib_1.__importDefault(require("./EditorInput"));
|
|
18
|
-
const EditorContext_1 = require("./EditorContext");
|
|
19
|
-
const ExpressionFunctionDocumentation_1 = require("./ExpressionFunctionDocumentation");
|
|
20
8
|
const DocumentationLinkConstants_1 = require("../../Utilities/Constants/DocumentationLinkConstants");
|
|
9
|
+
const ModuleConstants_1 = require("../../Utilities/Constants/ModuleConstants");
|
|
10
|
+
const ArrayExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/ArrayExtensions"));
|
|
21
11
|
const StringExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/StringExtensions"));
|
|
12
|
+
const AdaptableInput_1 = tslib_1.__importDefault(require("../../View/Components/AdaptableInput"));
|
|
22
13
|
const ButtonInfo_1 = require("../../View/Components/Buttons/ButtonInfo");
|
|
14
|
+
const CheckBox_1 = require("../CheckBox");
|
|
23
15
|
const CodeBlock_1 = require("../CodeBlock");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const DateHelper_1 = require("../../Utilities/Helpers/DateHelper");
|
|
27
|
-
const AdaptableFormControlTextClear_1 = require("../../View/Components/Forms/AdaptableFormControlTextClear");
|
|
16
|
+
const HelpBlock_1 = tslib_1.__importDefault(require("../HelpBlock"));
|
|
17
|
+
const Panel_1 = tslib_1.__importDefault(require("../Panel"));
|
|
28
18
|
const Tabs_1 = require("../Tabs");
|
|
19
|
+
const DataTableEditor_1 = require("./DataTableEditor");
|
|
20
|
+
const EditorContext_1 = require("./EditorContext");
|
|
21
|
+
const EditorInput_1 = tslib_1.__importDefault(require("./EditorInput"));
|
|
22
|
+
const EditorInputWithWhereClause_1 = tslib_1.__importDefault(require("./EditorInputWithWhereClause"));
|
|
23
|
+
const ExpressionFunctionDocumentation_1 = require("./ExpressionFunctionDocumentation");
|
|
24
|
+
const NamedQueryContext_1 = require("./NamedQueryContext");
|
|
25
|
+
const NamedQueryEditor_1 = require("./NamedQueryEditor");
|
|
29
26
|
const QueryBuilder_1 = require("./QueryBuilder");
|
|
27
|
+
exports.baseClassName = `ab-ExpressionEditor`;
|
|
30
28
|
function ExpressionEditor(props) {
|
|
31
29
|
var _a, _b, _c;
|
|
32
30
|
const { type, module } = props;
|
|
33
|
-
const [data, setData] = (0, react_1.useState)(props.initialData);
|
|
34
|
-
const [showColumnIds, setShowColumnIds] = (0, react_1.useState)(false);
|
|
35
|
-
const [inlineQuery, setInlineQuery] = (0, react_1.useState)(false);
|
|
36
|
-
const [showNamedQueries, setShowNamedQueries] = (0, react_1.useState)(false);
|
|
37
|
-
const baseClassName = `ab-ExpressionEditor`;
|
|
38
31
|
const [selectedFunction, setSelectedFunction] = (0, react_1.useState)(null);
|
|
39
32
|
const [expressionText, setExpressionText] = (0, react_1.useState)(props.value);
|
|
40
33
|
const { namedQuery, setNamedQuery } = (0, NamedQueryContext_1.useNamedQueryContext)();
|
|
@@ -43,80 +36,20 @@ function ExpressionEditor(props) {
|
|
|
43
36
|
const editorInput = type === 'observable' || type === 'aggregatedBoolean' ? (React.createElement(EditorInputWithWhereClause_1.default, { type: type, module: module, value: props.value, onChange: (value) => {
|
|
44
37
|
setExpressionText(value);
|
|
45
38
|
props.onChange(value);
|
|
46
|
-
}, testData:
|
|
39
|
+
}, testData: props.initialData, api: props.api })) : (
|
|
47
40
|
// 'boolean','scalar','aggregatedScalar'/'cumulativeAggregatedScalar'/'quantileAggregatedScalar'
|
|
48
41
|
(React.createElement(
|
|
49
42
|
EditorInput_1.default,
|
|
50
43
|
{ type: type, module: module, value: props.value, onChange: (value) => {
|
|
51
44
|
setExpressionText(value);
|
|
52
45
|
props.onChange(value);
|
|
53
|
-
}, testData:
|
|
46
|
+
}, testData: props.initialData, isFullExpression: props.isFullExpression, api: props.api }
|
|
54
47
|
)));
|
|
48
|
+
const adaptableFields = props.api.expressionApi.internalApi.getAvailableFields();
|
|
55
49
|
// currently only boolean and scalar expressions support nested calculated columns (calc cols which reference other calc cols)
|
|
56
50
|
const queryableColumns = type === 'scalar' || type === 'boolean' || type === 'aggregatedScalar'
|
|
57
51
|
? props.columns
|
|
58
52
|
: props.columns.filter((c) => !props.api.columnApi.isCalculatedColumn(c.columnId));
|
|
59
|
-
const getColValue = (column) => {
|
|
60
|
-
var _a;
|
|
61
|
-
return props.api.internalApi.getValueUsingField(data, (_a = column.field) !== null && _a !== void 0 ? _a : column.columnId);
|
|
62
|
-
};
|
|
63
|
-
const updateColValue = (rowData, column, newValue) => {
|
|
64
|
-
var _a;
|
|
65
|
-
const updatedRowData = props.api.internalApi.setValueUsingField(rowData, (_a = column.field) !== null && _a !== void 0 ? _a : column.columnId, newValue);
|
|
66
|
-
return Object.assign({}, updatedRowData);
|
|
67
|
-
};
|
|
68
|
-
const getColDateValue = (column) => {
|
|
69
|
-
const colValue = getColValue(column);
|
|
70
|
-
return colValue && (0, DateHelper_1.isValueValidDate)(colValue)
|
|
71
|
-
? new Date(colValue).toISOString().substr(0, 10)
|
|
72
|
-
: '';
|
|
73
|
-
};
|
|
74
|
-
const [searchInputValue, setSearchInputValue] = React.useState('');
|
|
75
|
-
const dataTableEditor = (React.createElement(React.Fragment, null,
|
|
76
|
-
React.createElement(rebass_1.Flex, { className: `${baseClassName}__columns-list`, flexDirection: "column", alignItems: "start", style: { marginTop: 2 } },
|
|
77
|
-
React.createElement(CheckBox_1.CheckBox, { checked: showColumnIds, onChange: (checked) => setShowColumnIds(checked), style: {
|
|
78
|
-
float: 'right',
|
|
79
|
-
margin: 0,
|
|
80
|
-
paddingTop: 'var(--ab-space-1)',
|
|
81
|
-
paddingBottom: 'var(--ab-space-1)',
|
|
82
|
-
} }, 'Show Column IDs'),
|
|
83
|
-
React.createElement(AdaptableFormControlTextClear_1.AdaptableFormControlTextClear, { value: searchInputValue, OnTextChange: setSearchInputValue, placeholder: "Filter columns...", style: { flex: 1, marginBottom: 3 } })),
|
|
84
|
-
React.createElement(FormLayout_1.default, { className: "ab-ExpressionEditor__columns", gridColumnGap: "var(--ab-space-1)", gridRowGap: "var(--ab-space-1)", sizes: ['auto', '100px'], style: { alignItems: 'stretch' } }, queryableColumns
|
|
85
|
-
.filter((column) => {
|
|
86
|
-
if (!searchInputValue) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
return (column.columnId.includes(searchInputValue) ||
|
|
90
|
-
column.friendlyName.includes(searchInputValue));
|
|
91
|
-
})
|
|
92
|
-
.map((column) => (React.createElement(FormLayout_1.FormRow, { key: column.columnId, label: React.createElement(EditorButton_1.default, { width: "100%", height: "100%", style: {
|
|
93
|
-
background: 'var(--ab-color-primary)',
|
|
94
|
-
cursor: 'grab',
|
|
95
|
-
marginRight: 'var(--ab-space-1)',
|
|
96
|
-
}, data: `[${column.columnId}]`, "data-name": "column", icon: "drag" },
|
|
97
|
-
React.createElement(rebass_1.Flex, { flexDirection: "column", alignItems: "start" }, showColumnIds ? `[${column.columnId}]` : column.friendlyName)) }, column.dataType === 'Number' ? (React.createElement(Input_1.default, { type: "number", "data-name": "column-input", "data-value": column.columnId, value: getColValue(column), onChange: (e) => setData(updateColValue(data, column, Number(e.target.value))), width: "100%", disabled: column.readOnly })) : column.dataType === 'String' ? (React.createElement(Input_1.default, { type: "text", "data-name": "column-input", "data-value": column.columnId, value: getColValue(column), onChange: (e) => setData(updateColValue(data, column, e.target.value)), width: "100%", disabled: column.readOnly })) : column.dataType === 'Date' ? (React.createElement(AdaptableInput_1.default, { type: "date", "data-name": "column-input", "data-value": column.columnId, value: getColDateValue(column), onChange: (e) => {
|
|
98
|
-
setData(updateColValue(data, column, new Date(e.target.value)));
|
|
99
|
-
}, style: { width: '100%' }, disabled: column.readOnly })) : column.dataType === 'Boolean' ? (React.createElement(CheckBox_1.CheckBox, { "data-name": "column-input", "data-value": column.columnId, checked: getColValue(column), onChange: (checked) => setData(updateColValue(data, column, checked)), disabled: column.readOnly })) : null))))));
|
|
100
|
-
const namedQueries = (React.createElement(rebass_1.Flex, { flexDirection: "column", alignItems: "start", style: { marginTop: 2 } },
|
|
101
|
-
React.createElement(CheckBox_1.CheckBox, { checked: showColumnIds, onChange: (checked) => setShowColumnIds(checked) }, "Show Column IDs"),
|
|
102
|
-
React.createElement(CheckBox_1.CheckBox, { checked: inlineQuery, onChange: (checked) => setInlineQuery(checked) }, "Inline Query"),
|
|
103
|
-
props.namedQueries.map((namedQuery) => (React.createElement(rebass_1.Flex, { key: namedQuery.Uuid, flexDirection: "column", alignItems: "start", style: {
|
|
104
|
-
padding: 3,
|
|
105
|
-
marginTop: 'var(--ab-space-2)',
|
|
106
|
-
marginBottom: 'var(--ab-space-2)',
|
|
107
|
-
width: '100%',
|
|
108
|
-
}, backgroundColor: "primarylight" },
|
|
109
|
-
' ',
|
|
110
|
-
React.createElement(EditorButton_1.default, { width: "100%", height: "100%", style: {
|
|
111
|
-
background: 'var(--ab-color-primary)',
|
|
112
|
-
cursor: 'grab',
|
|
113
|
-
}, data: inlineQuery ? namedQuery.BooleanExpression : `QUERY("${namedQuery.Name}")`, "data-name": "column", icon: "drag" },
|
|
114
|
-
React.createElement(rebass_1.Flex, { flexDirection: "column", alignItems: "start" }, namedQuery.Name)),
|
|
115
|
-
React.createElement(rebass_1.Flex, { alignItems: "start", style: {
|
|
116
|
-
padding: 5,
|
|
117
|
-
} }, showColumnIds
|
|
118
|
-
? namedQuery.BooleanExpression
|
|
119
|
-
: props.api.expressionApi.getAdaptableQueryExpressionWithColumnFriendlyNames(namedQuery)))))));
|
|
120
53
|
const showDocumentationLinks = props.api.internalApi.isDocumentationLinksDisplayed();
|
|
121
54
|
// @Bogdan i did this to be sure but i think we can get rid of this as the button does the same (and better IMO)
|
|
122
55
|
const showNamedQueryStuff = false;
|
|
@@ -144,7 +77,7 @@ function ExpressionEditor(props) {
|
|
|
144
77
|
BooleanExpression: expressionText,
|
|
145
78
|
});
|
|
146
79
|
} })) : null));
|
|
147
|
-
const editorElement = (React.createElement(rebass_1.Flex, { className: baseClassName, flex: 1, "data-name": "expression-editor-wrapper", pl: 2, style: props.style },
|
|
80
|
+
const editorElement = (React.createElement(rebass_1.Flex, { className: exports.baseClassName, flex: 1, "data-name": "expression-editor-wrapper", pl: 2, style: props.style },
|
|
148
81
|
React.createElement(rebass_1.Flex, { flex: 1, style: { minHeight: 0 }, flexDirection: "column", onFocus: (event) => {
|
|
149
82
|
if (event.target.tagName === 'TEXTAREA') {
|
|
150
83
|
textAreaRef.current = event.target;
|
|
@@ -158,19 +91,59 @@ function ExpressionEditor(props) {
|
|
|
158
91
|
StringExtensions_1.default.IsNullOrEmpty(expressionText === null || expressionText === void 0 ? void 0 : expressionText.trim()) && renderQueryHints(type),
|
|
159
92
|
showDocumentationLinks && (React.createElement(HelpBlock_1.default, { "data-name": "query-documentation", mt: 2, mb: 2, fontSize: 3 },
|
|
160
93
|
React.createElement(ButtonInfo_1.ButtonInfo, { mr: 2, onClick: () => window.open(queryDocumentationLink, '_blank') }),
|
|
161
|
-
"See ",
|
|
162
|
-
StringExtensions_1.default.CapitaliseFirstLetter(type),
|
|
163
|
-
" Query documentation for more details and examples")),
|
|
94
|
+
"See documentation for more details and examples")),
|
|
164
95
|
React.createElement(rebass_1.Box, { flex: 1 }),
|
|
165
96
|
showNamedQueryStuff && saveAsNamedQueryElement),
|
|
166
|
-
React.createElement(rebass_1.Box, { className: `${baseClassName}
|
|
167
|
-
|
|
168
|
-
React.createElement(
|
|
169
|
-
|
|
170
|
-
|
|
97
|
+
React.createElement(rebass_1.Box, { className: `${exports.baseClassName}__sidebar`, "data-name": "expression-sidebar", pb: 2, paddingLeft: 2, pr: 2 },
|
|
98
|
+
React.createElement(Panel_1.default, { bodyProps: { style: { height: '100%' } }, style: { height: '100%' } },
|
|
99
|
+
React.createElement(Tabs_1.Tabs, { style: { height: '100%' }, variant: "" },
|
|
100
|
+
React.createElement(Tabs_1.Tabs.Tab, { value: "column" }, "Columns"),
|
|
101
|
+
React.createElement(Tabs_1.Tabs.Tab, { value: "field" }, "Fields"),
|
|
102
|
+
React.createElement(Tabs_1.Tabs.Tab, { value: "named-query" }, "Named Queries"),
|
|
103
|
+
React.createElement(Tabs_1.Tabs.Content, { flex: 1, style: { height: '100%' } },
|
|
104
|
+
React.createElement(DataTableEditor_1.DataTableEditor, { type: "column", dataFormatter: (value) => `[${value}]`, fields: queryableColumns.map((column) => ({
|
|
105
|
+
label: column.friendlyName,
|
|
106
|
+
value: column.columnId,
|
|
107
|
+
dataType: column.dataType,
|
|
108
|
+
readOnly: column.readOnly,
|
|
109
|
+
})), data: props.initialData })),
|
|
110
|
+
React.createElement(Tabs_1.Tabs.Content, null, adaptableFields && adaptableFields.length > 0 ? (React.createElement(DataTableEditor_1.DataTableEditor, { type: "field", labels: {
|
|
111
|
+
showIds: 'Show Field path',
|
|
112
|
+
filterPlaceholder: 'Filter fields...',
|
|
113
|
+
}, dataFormatter: (value) => `FIELD("${value}")`, data: props.initialData, fields: adaptableFields === null || adaptableFields === void 0 ? void 0 : adaptableFields.map((field) => ({
|
|
114
|
+
label: field.label,
|
|
115
|
+
value: field.name,
|
|
116
|
+
dataType: field.dataType,
|
|
117
|
+
readOnly: true,
|
|
118
|
+
})) })) : (React.createElement(rebass_1.Text, { p: 2 }, "No Data Fields provided"))),
|
|
119
|
+
React.createElement(Tabs_1.Tabs.Content, null, ArrayExtensions_1.default.IsNullOrEmpty(props.namedQueries) ? (React.createElement("div", null,
|
|
120
|
+
React.createElement(rebass_1.Text, { p: 2 }, "No Named Queries defined"),
|
|
121
|
+
React.createElement(rebass_1.Text, { fontSize: 2, padding: 2, p: 2 },
|
|
122
|
+
"Named Queries are saved Expressions which can be referenced in other Expressions using the ",
|
|
123
|
+
React.createElement("i", null, "QUERY"),
|
|
124
|
+
" keyword",
|
|
125
|
+
' '))) : (React.createElement(NamedQueryEditor_1.NamedQueryEditor, { namedQueries: props.namedQueries }))))))))));
|
|
171
126
|
const queryBuilderElement = (React.createElement(QueryBuilder_1.QueryBuilder, { module: module, query: expressionText, onChange: (query) => {
|
|
172
127
|
setExpressionText(query);
|
|
173
128
|
props.onChange(query);
|
|
129
|
+
}, getFields: (type) => {
|
|
130
|
+
return props.fields
|
|
131
|
+
.filter((field) => {
|
|
132
|
+
if (!type) {
|
|
133
|
+
return (field.dataType === 'String' ||
|
|
134
|
+
field.dataType === 'Number' ||
|
|
135
|
+
field.dataType === 'Boolean' ||
|
|
136
|
+
field.dataType === 'Date');
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return field.dataType === type;
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
.map((field) => ({
|
|
143
|
+
value: field.name,
|
|
144
|
+
label: field.label,
|
|
145
|
+
type: field.dataType,
|
|
146
|
+
}));
|
|
174
147
|
}, getColumns: (type) => {
|
|
175
148
|
return props.columns
|
|
176
149
|
.filter((column) => {
|
|
@@ -202,7 +175,7 @@ function ExpressionEditor(props) {
|
|
|
202
175
|
} }, (() => {
|
|
203
176
|
switch (true) {
|
|
204
177
|
case showQueryBuilder && showExpressionEditor:
|
|
205
|
-
return (React.createElement(Tabs_1.Tabs, { mb: 2, p: 2, minHeight: 0, flex: 1 },
|
|
178
|
+
return (React.createElement(Tabs_1.Tabs, { "data-name": "editor-selector-tabs", mb: 2, p: 2, minHeight: 0, flex: 1 },
|
|
206
179
|
React.createElement(Tabs_1.Tabs.Tab, { value: "editor" }, "Expression Editor"),
|
|
207
180
|
React.createElement(Tabs_1.Tabs.Tab, { value: "ui" }, "Query Builder"),
|
|
208
181
|
React.createElement(Tabs_1.Tabs.Content, null, editorElement),
|