@truedat/bg 6.6.4 → 6.6.6
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 +6 -6
- package/src/concepts/components/ConceptCompleteness.js +6 -4
- package/src/concepts/components/ConceptEdit.js +37 -42
- package/src/concepts/components/__tests__/ConceptCompleteness.spec.js +25 -10
- package/src/concepts/components/__tests__/__snapshots__/ConceptCompleteness.spec.js.snap +46 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/bg",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.6",
|
|
4
4
|
"description": "Truedat Web Business Glossary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.16.5",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "6.6.
|
|
37
|
+
"@truedat/test": "6.6.6",
|
|
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",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
]
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@truedat/core": "6.6.
|
|
90
|
-
"@truedat/df": "6.6.
|
|
91
|
-
"@truedat/lm": "6.6.
|
|
89
|
+
"@truedat/core": "6.6.6",
|
|
90
|
+
"@truedat/df": "6.6.6",
|
|
91
|
+
"@truedat/lm": "6.6.6",
|
|
92
92
|
"decode-uri-component": "^0.2.2",
|
|
93
93
|
"file-saver": "^2.0.5",
|
|
94
94
|
"moment": "^2.29.4",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"react-dom": ">= 16.8.6 < 17",
|
|
112
112
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "87a359e52cc9df990110f9dcbb39a2f3d6b6eb80"
|
|
115
115
|
}
|
|
@@ -40,10 +40,12 @@ export const Completeness = ({
|
|
|
40
40
|
id="concepts.props.completeness"
|
|
41
41
|
defaultMessage="Completeness"
|
|
42
42
|
/>{" "}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
{langLocalName ? (
|
|
44
|
+
<FormattedMessage
|
|
45
|
+
id={`i18n.messages.locale.${lang}`}
|
|
46
|
+
defaultMessage={langLocalName}
|
|
47
|
+
/>
|
|
48
|
+
) : null}
|
|
47
49
|
</Header>
|
|
48
50
|
<>{}</>
|
|
49
51
|
<Progress
|
|
@@ -10,68 +10,34 @@ import {
|
|
|
10
10
|
formatLocales,
|
|
11
11
|
} from "@truedat/core/services/i18nContent";
|
|
12
12
|
import { useTemplate } from "@truedat/core/hooks";
|
|
13
|
-
|
|
14
13
|
import { conceptAction } from "../routines";
|
|
15
|
-
|
|
16
14
|
import ConceptForms from "./ConceptForms";
|
|
17
15
|
const actionKey = "update";
|
|
18
16
|
|
|
19
17
|
export const ConceptEdit = ({
|
|
20
18
|
concept,
|
|
19
|
+
content,
|
|
21
20
|
loading,
|
|
21
|
+
locales,
|
|
22
|
+
localesLoading,
|
|
22
23
|
template,
|
|
23
24
|
action,
|
|
24
25
|
conceptAction,
|
|
25
26
|
processedContent,
|
|
26
27
|
}) => {
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
const [i18nConcept, setI18nConcept] = useState(
|
|
30
|
-
|
|
31
|
-
if (_.isNil(propContent)) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (_.isEmpty(i18nConcept)) {
|
|
36
|
-
const i18n_content = concept.i18n_content || {};
|
|
37
|
-
|
|
38
|
-
const { translatable: translatableFields } =
|
|
39
|
-
splitTranslatableFields(template);
|
|
40
|
-
|
|
41
|
-
const i18nConceptInit = _.flow(
|
|
42
|
-
_.filter(({ is_enabled }) => is_enabled),
|
|
43
|
-
_.map(({ id, lang, is_default, is_required }) => {
|
|
44
|
-
const contentLang = _.get(lang)(i18n_content);
|
|
45
|
-
|
|
46
|
-
const langContent = is_default
|
|
47
|
-
? propContent
|
|
48
|
-
: { ...translatableFields, ...contentLang?.content };
|
|
49
|
-
const langName = is_default ? propName : contentLang?.name || "";
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
id,
|
|
53
|
-
lang,
|
|
54
|
-
is_default,
|
|
55
|
-
is_required,
|
|
56
|
-
name: langName,
|
|
57
|
-
content: langContent,
|
|
58
|
-
};
|
|
59
|
-
}),
|
|
60
|
-
_.keyBy("lang")
|
|
61
|
-
)(locales);
|
|
62
|
-
|
|
63
|
-
setI18nConcept(i18nConceptInit);
|
|
64
|
-
}
|
|
28
|
+
const { domain } = concept;
|
|
29
|
+
|
|
30
|
+
const [i18nConcept, setI18nConcept] = useState(content);
|
|
65
31
|
|
|
66
32
|
const templateFields = splitTranslatableFields(template);
|
|
67
33
|
|
|
68
34
|
const translatableKeys = _.keys(templateFields.translatable);
|
|
69
35
|
const noTranslatableKeys = _.keys(templateFields.noTranslatable);
|
|
70
36
|
const langs = formatLocales(locales);
|
|
71
|
-
const defaultContent = _.flow(_.find("is_default"))(i18nConcept);
|
|
72
37
|
|
|
73
38
|
const handleSubmit = (e) => {
|
|
74
39
|
e.preventDefault();
|
|
40
|
+
const defaultContent = _.flow(_.find("is_default"))(i18nConcept);
|
|
75
41
|
|
|
76
42
|
const i18nSendConcept = _.flow(
|
|
77
43
|
_.omit(defaultContent.lang),
|
|
@@ -129,8 +95,9 @@ ConceptEdit.propTypes = {
|
|
|
129
95
|
export const ConceptEditLoader = (props) => {
|
|
130
96
|
const templateName = _.prop("templateName")(props);
|
|
131
97
|
const concept = _.prop("concept")(props);
|
|
132
|
-
const { domain } = concept;
|
|
98
|
+
const { content: propContent, name: propName, domain } = concept;
|
|
133
99
|
|
|
100
|
+
const { locales, loading: localesLoading } = useLocales(false);
|
|
134
101
|
const { data, loading: templateLoading } = useTemplate({
|
|
135
102
|
name: templateName,
|
|
136
103
|
domainIds: [domain.id],
|
|
@@ -139,11 +106,39 @@ export const ConceptEditLoader = (props) => {
|
|
|
139
106
|
const template = _.prop("template")(data);
|
|
140
107
|
const processedContent = applyTemplate(template);
|
|
141
108
|
|
|
109
|
+
const i18nContent = _.flow(
|
|
110
|
+
_.filter(({ is_enabled }) => is_enabled),
|
|
111
|
+
_.map(({ id, lang, is_default, is_required }) => {
|
|
112
|
+
const contentLang = _.get(lang)(concept.i18n_content || {});
|
|
113
|
+
|
|
114
|
+
const langContent = is_default
|
|
115
|
+
? propContent
|
|
116
|
+
: {
|
|
117
|
+
...splitTranslatableFields(template).translatable,
|
|
118
|
+
...contentLang?.content,
|
|
119
|
+
};
|
|
120
|
+
const langName = is_default ? propName : contentLang?.name || "";
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
id,
|
|
124
|
+
lang,
|
|
125
|
+
is_default,
|
|
126
|
+
is_required,
|
|
127
|
+
name: langName,
|
|
128
|
+
content: langContent,
|
|
129
|
+
};
|
|
130
|
+
}),
|
|
131
|
+
_.keyBy("lang")
|
|
132
|
+
)(locales);
|
|
133
|
+
|
|
142
134
|
return (
|
|
143
135
|
<ConceptEdit
|
|
144
136
|
templateLoading={templateLoading}
|
|
137
|
+
localesLoading={localesLoading}
|
|
145
138
|
processedContent={processedContent}
|
|
139
|
+
content={i18nContent}
|
|
146
140
|
template={template}
|
|
141
|
+
locales={locales}
|
|
147
142
|
{...props}
|
|
148
143
|
/>
|
|
149
144
|
);
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
3
|
import { ConceptCompleteness } from "../ConceptCompleteness";
|
|
4
4
|
|
|
5
|
+
jest.mock("@truedat/core/hooks", () => ({
|
|
6
|
+
useLocales: jest.fn(() => ({
|
|
7
|
+
loading: false,
|
|
8
|
+
locales: [
|
|
9
|
+
{
|
|
10
|
+
lang: "en",
|
|
11
|
+
id: 1,
|
|
12
|
+
is_default: true,
|
|
13
|
+
is_required: true,
|
|
14
|
+
is_enabled: true,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
})),
|
|
18
|
+
}));
|
|
19
|
+
|
|
5
20
|
describe("<ConceptCompleteness />", () => {
|
|
6
21
|
const props = {
|
|
7
22
|
concept: {
|
|
@@ -12,19 +27,19 @@ describe("<ConceptCompleteness />", () => {
|
|
|
12
27
|
fields: [
|
|
13
28
|
{ cardinality: "?", name: "field1" },
|
|
14
29
|
{ cardinality: "1", name: "field2" },
|
|
15
|
-
{ cardinality: "1", name: "field3" }
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
]
|
|
30
|
+
{ cardinality: "1", name: "field3" },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
19
34
|
},
|
|
20
35
|
content: {
|
|
21
|
-
field3: "value"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
36
|
+
field3: "value",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
24
39
|
};
|
|
25
40
|
|
|
26
41
|
it("matches the latest snapshot", () => {
|
|
27
|
-
const
|
|
28
|
-
expect(
|
|
42
|
+
const { container } = render(<ConceptCompleteness {...props} />);
|
|
43
|
+
expect(container).toMatchSnapshot();
|
|
29
44
|
});
|
|
30
45
|
});
|
|
@@ -1,7 +1,50 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`<ConceptCompleteness /> matches the latest snapshot 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="ui segment completeness"
|
|
7
|
+
>
|
|
8
|
+
<h3
|
|
9
|
+
class="ui dividing header"
|
|
10
|
+
>
|
|
11
|
+
Completeness
|
|
12
|
+
|
|
13
|
+
</h3>
|
|
14
|
+
<div
|
|
15
|
+
class="ui warning progress"
|
|
16
|
+
data-percent="50"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
class="bar"
|
|
20
|
+
style="width: 50%;"
|
|
21
|
+
>
|
|
22
|
+
<div
|
|
23
|
+
class="progress"
|
|
24
|
+
>
|
|
25
|
+
50%
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<h4
|
|
30
|
+
class="ui dividing header"
|
|
31
|
+
>
|
|
32
|
+
Missing required fields
|
|
33
|
+
</h4>
|
|
34
|
+
<div
|
|
35
|
+
class="ui list"
|
|
36
|
+
role="list"
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
class="item"
|
|
40
|
+
role="listitem"
|
|
41
|
+
>
|
|
42
|
+
<i
|
|
43
|
+
aria-hidden="true"
|
|
44
|
+
class="grey right angle fitted icon"
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
7
50
|
`;
|