@truedat/qx 8.10.2 → 8.10.4
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/package.json +3 -3
- package/src/components/QxRoutes.js +8 -7
- package/src/components/__tests__/QxRoutes.spec.js +2 -1
- package/src/components/__tests__/__fixtures__/helper.js +13 -0
- package/src/components/__tests__/__snapshots__/QxRoutes.spec.js.snap +1 -1
- package/src/components/common/ClauseViewer.js +52 -8
- package/src/components/common/DescriptionInput.js +9 -34
- package/src/components/common/TypeSelector.js +20 -10
- package/src/components/common/__tests__/ClauseViewer.spec.js +150 -0
- package/src/components/common/__tests__/DescriptionInput.spec.js +2 -5
- package/src/components/common/__tests__/__snapshots__/DescriptionInput.spec.js.snap +7 -10
- package/src/components/common/expressions/Clauses.js +22 -17
- package/src/components/common/expressions/Condition.js +201 -102
- package/src/components/common/expressions/Expression.js +17 -23
- package/src/components/common/expressions/FunctionSelector.js +3 -3
- package/src/components/common/expressions/ShapeSelector.js +1 -1
- package/src/components/common/expressions/__tests__/Clauses.spec.js +1 -1
- package/src/components/common/expressions/__tests__/Condition.spec.js +83 -26
- package/src/components/common/expressions/__tests__/ParamSelector.spec.js +1 -1
- package/src/components/common/expressions/__tests__/__snapshots__/Clauses.spec.js.snap +18 -22
- package/src/components/common/expressions/__tests__/__snapshots__/Condition.spec.js.snap +215 -216
- package/src/components/common/expressions/__tests__/__snapshots__/ConstantSelector.spec.js.snap +6 -10
- package/src/components/common/expressions/__tests__/__snapshots__/Expression.spec.js.snap +630 -654
- package/src/components/common/expressions/__tests__/__snapshots__/FunctionArgs.spec.js.snap +193 -201
- package/src/components/common/expressions/__tests__/__snapshots__/FunctionSelector.spec.js.snap +450 -466
- package/src/components/common/expressions/__tests__/__snapshots__/ShapeSelector.spec.js.snap +34 -34
- package/src/components/common/expressions/constantInputs/AnySelector.js +1 -0
- package/src/components/common/expressions/constantInputs/__tests__/__snapshots__/AnySelector.spec.js.snap +15 -15
- package/src/components/dataViews/__tests__/__snapshots__/AdvancedDataViewEditor.spec.js.snap +378 -406
- package/src/components/dataViews/__tests__/__snapshots__/DataViewSummary.spec.js.snap +6 -6
- package/src/components/dataViews/__tests__/__snapshots__/Queryable.spec.js.snap +489 -577
- package/src/components/dataViews/__tests__/__snapshots__/Queryables.spec.js.snap +400 -476
- package/src/components/dataViews/advancedForm/Queryable.js +56 -64
- package/src/components/dataViews/advancedForm/Queryables.js +11 -2
- package/src/components/dataViews/queryableProperties/Join.js +16 -6
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Join.spec.js.snap +0 -28
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Select.spec.js.snap +270 -282
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/SelectField.spec.js.snap +172 -180
- package/src/components/dataViews/simpleForm/DatasetForm.js +4 -0
- package/src/components/dataViews/simpleForm/FormQueryable.js +49 -53
- package/src/components/dataViews/summary/Where.js +3 -2
- package/src/components/functions/FunctionEdit.js +92 -0
- package/src/components/functions/FunctionEditor.js +32 -10
- package/src/components/functions/FunctionParams.js +54 -61
- package/src/components/functions/FunctionsList.js +213 -0
- package/src/components/functions/__tests__/FunctionEdit.spec.js +168 -0
- package/src/components/functions/__tests__/FunctionParams.spec.js +1 -8
- package/src/components/functions/__tests__/FunctionsList.spec.js +62 -0
- package/src/components/functions/__tests__/__snapshots__/FunctionEditor.spec.js.snap +553 -469
- package/src/components/functions/__tests__/__snapshots__/FunctionParams.spec.js.snap +139 -161
- package/src/components/functions/__tests__/__snapshots__/FunctionsList.spec.js.snap +588 -0
- package/src/components/qualityControls/__tests__/NewQualityControl.spec.js +4 -0
- package/src/components/qualityControls/__tests__/QualityControlEditor.spec.js +8 -1
- package/src/components/qualityControls/__tests__/__snapshots__/EditQualityControl.spec.js.snap +109 -118
- package/src/components/qualityControls/__tests__/__snapshots__/NewDraftQualityControl.spec.js.snap +109 -118
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlEditor.spec.js.snap +471 -468
- package/src/hooks/useFunctions.js +6 -0
- package/src/styles/Expression.less +39 -6
- package/src/components/functions/Functions.js +0 -143
- package/src/components/functions/__tests__/Functions.spec.js +0 -56
- package/src/components/functions/__tests__/__snapshots__/Functions.spec.js.snap +0 -85
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import {
|
|
2
|
+
import { use } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { useIntl } from "react-intl";
|
|
5
5
|
import { Controller, useFormContext } from "react-hook-form";
|
|
6
|
-
import { Button,
|
|
6
|
+
import { Button, Form, Label } from "semantic-ui-react";
|
|
7
7
|
import QxContext from "@truedat/qx/components/QxContext";
|
|
8
8
|
import { From, GroupBy, Join, Select, Where } from "../queryableProperties";
|
|
9
9
|
import { getColorById, reduceQueryableFields } from "../queryableFunctions";
|
|
@@ -20,7 +20,6 @@ export default function Queryable({ index, onDelete }) {
|
|
|
20
20
|
const { formatMessage } = useIntl();
|
|
21
21
|
const { control, watch } = useFormContext();
|
|
22
22
|
const context = use(QxContext);
|
|
23
|
-
const [isShownDelete, setIsShownDelete] = useState();
|
|
24
23
|
const { type } = watch(`queryables[${index}]`);
|
|
25
24
|
|
|
26
25
|
const queryables = watch("queryables");
|
|
@@ -66,68 +65,61 @@ export default function Queryable({ index, onDelete }) {
|
|
|
66
65
|
: null;
|
|
67
66
|
|
|
68
67
|
return (
|
|
69
|
-
<div
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})}
|
|
109
|
-
error={error?.message}
|
|
110
|
-
onBlur={onBlur}
|
|
111
|
-
onChange={(_e, { value }) => onChange(value)}
|
|
112
|
-
value={value}
|
|
113
|
-
/>
|
|
114
|
-
)}
|
|
68
|
+
<div>
|
|
69
|
+
<div>
|
|
70
|
+
<div className="queryable-label">
|
|
71
|
+
<Label ribbon color={getColorById(queryable.id)}>
|
|
72
|
+
{formatMessage({ id: `dataViews.form.queryable.${type}` })}
|
|
73
|
+
</Label>
|
|
74
|
+
{index != 0 ? (
|
|
75
|
+
<Button
|
|
76
|
+
onClick={onDelete}
|
|
77
|
+
icon="trash alternate outline"
|
|
78
|
+
basic
|
|
79
|
+
color="red"
|
|
80
|
+
aria-label="delete"
|
|
81
|
+
/>
|
|
82
|
+
) : null}
|
|
83
|
+
</div>
|
|
84
|
+
<div className="vertical-space">
|
|
85
|
+
<Controller
|
|
86
|
+
control={control}
|
|
87
|
+
name={`queryables[${index}].alias`}
|
|
88
|
+
rules={{
|
|
89
|
+
validate: () => validateAlias || validateResource,
|
|
90
|
+
}}
|
|
91
|
+
render={({
|
|
92
|
+
field: { onBlur, onChange, value },
|
|
93
|
+
fieldState: { error },
|
|
94
|
+
}) => (
|
|
95
|
+
<Form.Input
|
|
96
|
+
label={formatMessage({
|
|
97
|
+
id: "dataViews.form.queryable.alias",
|
|
98
|
+
})}
|
|
99
|
+
autoComplete="off"
|
|
100
|
+
placeholder={formatMessage({
|
|
101
|
+
id: "dataViews.form.queryable.alias",
|
|
102
|
+
})}
|
|
103
|
+
error={error?.message}
|
|
104
|
+
onBlur={onBlur}
|
|
105
|
+
onChange={(_e, { value }) => onChange(value)}
|
|
106
|
+
value={value}
|
|
115
107
|
/>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
</
|
|
129
|
-
</
|
|
130
|
-
</
|
|
108
|
+
)}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
<div className="vertical-space">
|
|
112
|
+
<QxContext
|
|
113
|
+
value={{
|
|
114
|
+
...context,
|
|
115
|
+
field: `queryables[${index}].properties`,
|
|
116
|
+
fields,
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
{queryableComponents[type]}
|
|
120
|
+
</QxContext>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
131
123
|
</div>
|
|
132
124
|
);
|
|
133
125
|
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import { useIntl } from "react-intl";
|
|
3
|
-
import { useFieldArray } from "react-hook-form";
|
|
3
|
+
import { useFieldArray, useFormContext } from "react-hook-form";
|
|
4
4
|
import { Button, Divider, List } from "semantic-ui-react";
|
|
5
5
|
import Queryable from "./Queryable";
|
|
6
6
|
|
|
7
7
|
export default function Queryables() {
|
|
8
8
|
const { formatMessage } = useIntl();
|
|
9
|
+
const { watch } = useFormContext();
|
|
9
10
|
const { fields, append, remove } = useFieldArray({
|
|
10
11
|
name: "queryables",
|
|
11
12
|
keyName: "key",
|
|
12
13
|
});
|
|
14
|
+
const queryables = watch("queryables");
|
|
15
|
+
const hasUnresourcedJoin = _.some(
|
|
16
|
+
(q) => q.type === "join" && !q.properties?.resource?.id,
|
|
17
|
+
)(queryables);
|
|
13
18
|
|
|
14
19
|
const newClause = () => [
|
|
15
20
|
{ expressions: [{ shape: "function", value: { isCondition: true } }] },
|
|
@@ -41,7 +46,11 @@ export default function Queryables() {
|
|
|
41
46
|
<List.Item>
|
|
42
47
|
<Divider horizontal>
|
|
43
48
|
{queryableTypes.map((type, idx) => (
|
|
44
|
-
<Button
|
|
49
|
+
<Button
|
|
50
|
+
key={idx}
|
|
51
|
+
onClick={() => append(newQueryable(type))}
|
|
52
|
+
disabled={type === "join" && hasUnresourcedJoin}
|
|
53
|
+
>
|
|
45
54
|
{formatMessage({ id: `dataViews.form.queryable.${type}` })}
|
|
46
55
|
</Button>
|
|
47
56
|
))}
|
|
@@ -12,8 +12,10 @@ import "@truedat/qx/styles/Expression.less";
|
|
|
12
12
|
export default function Join() {
|
|
13
13
|
const { formatMessage } = useIntl();
|
|
14
14
|
const context = use(QxContext);
|
|
15
|
-
const { control } = useFormContext();
|
|
15
|
+
const { control, watch } = useFormContext();
|
|
16
16
|
const { field } = context;
|
|
17
|
+
const resource = watch(`${field}.resource`);
|
|
18
|
+
const hasResource = !!resource?.id;
|
|
17
19
|
|
|
18
20
|
const joinTypes = ["inner", "left", "right", "full_outer"];
|
|
19
21
|
|
|
@@ -50,11 +52,19 @@ export default function Join() {
|
|
|
50
52
|
)}
|
|
51
53
|
/>
|
|
52
54
|
</div>
|
|
53
|
-
|
|
54
|
-
<
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
{hasResource && (
|
|
56
|
+
<div className="vertical-space">
|
|
57
|
+
<QxContext
|
|
58
|
+
value={{
|
|
59
|
+
...context,
|
|
60
|
+
field: `${field}.clauses`,
|
|
61
|
+
conditionClasses: ["comparison"],
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<Clauses />
|
|
65
|
+
</QxContext>
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
58
68
|
</>
|
|
59
69
|
);
|
|
60
70
|
}
|
package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Join.spec.js.snap
CHANGED
|
@@ -206,33 +206,5 @@ exports[`<Join /> matches the latest snapshot 1`] = `
|
|
|
206
206
|
</div>
|
|
207
207
|
</div>
|
|
208
208
|
</div>
|
|
209
|
-
<div
|
|
210
|
-
class="vertical-space"
|
|
211
|
-
>
|
|
212
|
-
<div
|
|
213
|
-
class="field"
|
|
214
|
-
>
|
|
215
|
-
<label>
|
|
216
|
-
expression.form.clause
|
|
217
|
-
</label>
|
|
218
|
-
<div
|
|
219
|
-
class="ui horizontal divider"
|
|
220
|
-
>
|
|
221
|
-
<div
|
|
222
|
-
class="ui medium basic buttons"
|
|
223
|
-
>
|
|
224
|
-
<button
|
|
225
|
-
class="ui button"
|
|
226
|
-
>
|
|
227
|
-
<i
|
|
228
|
-
aria-hidden="true"
|
|
229
|
-
class="plus icon"
|
|
230
|
-
/>
|
|
231
|
-
expression.clause.action.addGroup
|
|
232
|
-
</button>
|
|
233
|
-
</div>
|
|
234
|
-
</div>
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
209
|
</div>
|
|
238
210
|
`;
|