@truedat/df 4.51.1 → 4.51.3
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/CHANGELOG.md +7 -0
- package/package.json +5 -5
- package/src/components/FieldViewerValue.js +1 -1
- package/src/components/__tests__/__snapshots__/SelectableDynamicForm.spec.js.snap +1 -0
- package/src/components/widgets/StringField.js +10 -5
- package/src/templates/components/TemplateRoutes.js +1 -11
- package/src/templates/utils/applyDefaults.js +7 -7
- package/src/templates/utils/applyTemplate.js +5 -5
- package/src/templates/utils/filterDomains.js +7 -7
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/df",
|
|
3
|
-
"version": "4.51.
|
|
3
|
+
"version": "4.51.3",
|
|
4
4
|
"description": "Truedat Web Data Quality Module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.16.4",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "4.
|
|
37
|
+
"@truedat/test": "4.51.3",
|
|
38
38
|
"babel-jest": "^28.1.0",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
]
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@truedat/auth": "4.51.
|
|
91
|
-
"@truedat/core": "4.51.
|
|
90
|
+
"@truedat/auth": "4.51.3",
|
|
91
|
+
"@truedat/core": "4.51.3",
|
|
92
92
|
"path-to-regexp": "^1.7.0",
|
|
93
93
|
"prop-types": "^15.8.1",
|
|
94
94
|
"react-color": "^2.17.3",
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"react-dom": ">= 16.8.6 < 17",
|
|
107
107
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "69d6cf8f7379eb2ef5744a4fdd357a7dd662b115"
|
|
110
110
|
}
|
|
@@ -4,8 +4,8 @@ import { Form } from "semantic-ui-react";
|
|
|
4
4
|
import { useIntl } from "react-intl";
|
|
5
5
|
|
|
6
6
|
export const StringField = ({
|
|
7
|
-
field: { name, cardinality, value },
|
|
8
|
-
onChange
|
|
7
|
+
field: { name, cardinality, placeholder, value },
|
|
8
|
+
onChange,
|
|
9
9
|
}) => {
|
|
10
10
|
const { formatMessage } = useIntl();
|
|
11
11
|
return cardinality == "+" || cardinality == "*" ? (
|
|
@@ -18,7 +18,7 @@ export const StringField = ({
|
|
|
18
18
|
options={["", ...(value || [])].map((o, i) => ({
|
|
19
19
|
key: i,
|
|
20
20
|
value: o,
|
|
21
|
-
text: o
|
|
21
|
+
text: o,
|
|
22
22
|
}))}
|
|
23
23
|
placeholder={formatMessage({ id: "fields.dropdown.placeholder" })}
|
|
24
24
|
search
|
|
@@ -26,13 +26,18 @@ export const StringField = ({
|
|
|
26
26
|
value={value || []}
|
|
27
27
|
/>
|
|
28
28
|
) : (
|
|
29
|
-
<Form.Input
|
|
29
|
+
<Form.Input
|
|
30
|
+
value={value || ""}
|
|
31
|
+
name={name}
|
|
32
|
+
onChange={onChange}
|
|
33
|
+
placeholder={placeholder}
|
|
34
|
+
/>
|
|
30
35
|
);
|
|
31
36
|
};
|
|
32
37
|
|
|
33
38
|
StringField.propTypes = {
|
|
34
39
|
field: PropTypes.object,
|
|
35
|
-
onChange: PropTypes.func
|
|
40
|
+
onChange: PropTypes.func,
|
|
36
41
|
};
|
|
37
42
|
|
|
38
43
|
export default StringField;
|
|
@@ -14,10 +14,6 @@ import Template from "./Template";
|
|
|
14
14
|
import TemplatesLoader from "./TemplatesLoader";
|
|
15
15
|
import TemplateLoader from "./TemplateLoader";
|
|
16
16
|
|
|
17
|
-
const DomainsLoader = React.lazy(() =>
|
|
18
|
-
import("@truedat/bg/taxonomy/components/DomainsLoader")
|
|
19
|
-
);
|
|
20
|
-
|
|
21
17
|
export const TemplateRoutes = () => {
|
|
22
18
|
const authorized = useAuthorized();
|
|
23
19
|
return (
|
|
@@ -32,19 +28,13 @@ export const TemplateRoutes = () => {
|
|
|
32
28
|
<Switch>
|
|
33
29
|
<Route
|
|
34
30
|
path={TEMPLATES_NEW}
|
|
35
|
-
render={() =>
|
|
36
|
-
<>
|
|
37
|
-
<DomainsLoader />
|
|
38
|
-
<NewTemplate />
|
|
39
|
-
</>
|
|
40
|
-
)}
|
|
31
|
+
render={() => <NewTemplate />}
|
|
41
32
|
exact
|
|
42
33
|
/>
|
|
43
34
|
<Route
|
|
44
35
|
path={TEMPLATE}
|
|
45
36
|
render={() => (
|
|
46
37
|
<>
|
|
47
|
-
<DomainsLoader />
|
|
48
38
|
<TemplateLoader />
|
|
49
39
|
<Template />
|
|
50
40
|
</>
|
|
@@ -15,8 +15,8 @@ const meetsSwitchCondition = (defaults, content, onSwitch, value) => {
|
|
|
15
15
|
return !_.isNil(onSwitch) && _.isObject(value) && _.has(field)(value);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const meetsDomain = (values,
|
|
19
|
-
_.includes(_.toString(
|
|
18
|
+
const meetsDomain = (values, domainId) =>
|
|
19
|
+
_.includes(_.toString(domainId))(_.keys(values));
|
|
20
20
|
|
|
21
21
|
const standardDefault = (on, toBe, onSwitch, onDomain) =>
|
|
22
22
|
_.every(_.isNil)([on, toBe, onSwitch, onDomain]);
|
|
@@ -24,7 +24,7 @@ const standardDefault = (on, toBe, onSwitch, onDomain) =>
|
|
|
24
24
|
const getDefaultValue = (defaults, content, on) =>
|
|
25
25
|
_.defaultTo(_.prop(on)(defaults))(_.prop(on)(content));
|
|
26
26
|
|
|
27
|
-
export const applyDefaults = (templateContent) => (content,
|
|
27
|
+
export const applyDefaults = (templateContent) => (content, domainId) =>
|
|
28
28
|
_.flow(
|
|
29
29
|
getTemplateDefaults,
|
|
30
30
|
_.omitBy((d) => _.includes(_.prop("name")(d))(_.keys(content))),
|
|
@@ -44,8 +44,8 @@ export const applyDefaults = (templateContent) => (content, domain) =>
|
|
|
44
44
|
const field = getDefaultValue(acc, content, onSwitch);
|
|
45
45
|
const defaultValue = _.prop(field)(value);
|
|
46
46
|
return _.assoc(name, defaultValue)(acc);
|
|
47
|
-
} else if (meetsDomain(onDomain,
|
|
48
|
-
const defaultValue = _.prop(
|
|
47
|
+
} else if (meetsDomain(onDomain, domainId)) {
|
|
48
|
+
const defaultValue = _.prop(domainId)(value);
|
|
49
49
|
return _.assoc(name, defaultValue)(acc);
|
|
50
50
|
} else {
|
|
51
51
|
return _.assoc(name, value)(acc);
|
|
@@ -54,8 +54,8 @@ export const applyDefaults = (templateContent) => (content, domain) =>
|
|
|
54
54
|
const field = getDefaultValue(acc, content, onSwitch);
|
|
55
55
|
const defaultValue = _.prop(field)(value);
|
|
56
56
|
return _.assoc(name, defaultValue)(acc);
|
|
57
|
-
} else if (meetsDomain(onDomain,
|
|
58
|
-
const defaultValue = _.prop(
|
|
57
|
+
} else if (meetsDomain(onDomain, domainId)) {
|
|
58
|
+
const defaultValue = _.prop(domainId)(value);
|
|
59
59
|
return _.assoc(name, defaultValue)(acc);
|
|
60
60
|
}
|
|
61
61
|
return acc;
|
|
@@ -9,28 +9,28 @@ import { filterValues } from "./filterValues";
|
|
|
9
9
|
|
|
10
10
|
export const applyTemplate =
|
|
11
11
|
(template) =>
|
|
12
|
-
(content,
|
|
12
|
+
(content, domainId = null) => {
|
|
13
13
|
const templateContent = flattenFields(template);
|
|
14
14
|
return _.flow(
|
|
15
15
|
filterFields(templateContent),
|
|
16
16
|
filterValues(templateContent),
|
|
17
17
|
filterDepends(templateContent),
|
|
18
18
|
filterSwitches(templateContent),
|
|
19
|
-
(content) => filterDomains(templateContent)(content,
|
|
20
|
-
(content) => applyDefaults(templateContent)(content,
|
|
19
|
+
(content) => filterDomains(templateContent)(content, domainId),
|
|
20
|
+
(content) => applyDefaults(templateContent)(content, domainId)
|
|
21
21
|
)(content);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const applyTemplateWithoutDefaults =
|
|
25
25
|
(template) =>
|
|
26
|
-
(content,
|
|
26
|
+
(content, domainId = null) => {
|
|
27
27
|
const templateContent = flattenFields(template);
|
|
28
28
|
return _.flow(
|
|
29
29
|
filterFields(templateContent),
|
|
30
30
|
filterValues(templateContent),
|
|
31
31
|
filterDepends(templateContent),
|
|
32
32
|
filterSwitches(templateContent),
|
|
33
|
-
(content) => filterDomains(templateContent)(content,
|
|
33
|
+
(content) => filterDomains(templateContent)(content, domainId)
|
|
34
34
|
)(content);
|
|
35
35
|
};
|
|
36
36
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
|
|
3
|
-
const validDomainValue = (field, content,
|
|
3
|
+
const validDomainValue = (field, content, domainId) => {
|
|
4
4
|
const name = _.prop("name")(field);
|
|
5
5
|
const value = _.prop(name)(content);
|
|
6
|
-
const values = _.prop(
|
|
6
|
+
const values = _.prop(domainId)(field?.values?.domain);
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
9
|
(_.isArray(value) && !_.isEmpty(_.intersection(values)(value))) ||
|
|
@@ -12,8 +12,8 @@ const validDomainValue = (field, content, domain) => {
|
|
|
12
12
|
);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const validDomainFields = (templateContent, content,
|
|
16
|
-
if (_.isNil(
|
|
15
|
+
const validDomainFields = (templateContent, content, domainId) => {
|
|
16
|
+
if (_.isNil(domainId)) {
|
|
17
17
|
return _.flow(
|
|
18
18
|
_.reject(_.has("values.domain")),
|
|
19
19
|
_.map("name")
|
|
@@ -23,13 +23,13 @@ const validDomainFields = (templateContent, content, domain) => {
|
|
|
23
23
|
_.reject(
|
|
24
24
|
(field) =>
|
|
25
25
|
_.has("values.domain")(field) &&
|
|
26
|
-
!validDomainValue(field, content,
|
|
26
|
+
!validDomainValue(field, content, domainId)
|
|
27
27
|
),
|
|
28
28
|
_.map("name")
|
|
29
29
|
)(templateContent);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export const filterDomains = (templateContent) => (content,
|
|
33
|
-
const vv = validDomainFields(templateContent, content,
|
|
32
|
+
export const filterDomains = (templateContent) => (content, domainId) => {
|
|
33
|
+
const vv = validDomainFields(templateContent, content, domainId);
|
|
34
34
|
return _.pick(vv)(content);
|
|
35
35
|
};
|