@truedat/core 6.1.5 → 6.2.0
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/RichTextEditor.js +4 -1
- package/src/components/TreeSelector.js +6 -0
- package/src/components/__tests__/__snapshots__/DomainSelector.spec.js.snap +1 -0
- package/src/components/__tests__/__snapshots__/HierarchySelector.spec.js.snap +1 -0
- package/src/components/__tests__/__snapshots__/TreeSelector.spec.js.snap +1 -0
- package/src/i18n/components/Languages.js +20 -7
- package/src/search/SearchContext.js +0 -1
- package/src/services/i18nContent.js +58 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@testing-library/jest-dom": "^5.16.5",
|
|
36
36
|
"@testing-library/react": "^12.0.0",
|
|
37
37
|
"@testing-library/user-event": "^13.2.1",
|
|
38
|
-
"@truedat/test": "6.
|
|
38
|
+
"@truedat/test": "6.2.0",
|
|
39
39
|
"babel-jest": "^28.1.0",
|
|
40
40
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
41
41
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"react-dom": ">= 16.8.6 < 17",
|
|
118
118
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "5c10ee429997ab081477edf0679547eb4bc11f9b"
|
|
121
121
|
}
|
|
@@ -145,7 +145,10 @@ export const RichTextEditor = ({
|
|
|
145
145
|
const [editor, setEditor] = useState();
|
|
146
146
|
|
|
147
147
|
useEffect(() => {
|
|
148
|
-
if (
|
|
148
|
+
if (
|
|
149
|
+
(!_.isEmpty(propValue) && !_.equals(propValue)(jsonValue)) ||
|
|
150
|
+
(readOnly && !_.equals(value)(Value.fromJSON(propValue)))
|
|
151
|
+
) {
|
|
149
152
|
setValue(Value.fromJSON(propValue));
|
|
150
153
|
}
|
|
151
154
|
}, [propValue]);
|
|
@@ -86,6 +86,11 @@ export const TreeSelector = ({
|
|
|
86
86
|
const [open, setOpen] = useState([]);
|
|
87
87
|
const [displayed, setDisplayed] = useState([]);
|
|
88
88
|
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (initialValue !== value)
|
|
91
|
+
setValue(_.defaultTo(multiple ? [] : null)(initialValue));
|
|
92
|
+
}, [initialValue]);
|
|
93
|
+
|
|
89
94
|
useEffect(() => {
|
|
90
95
|
const ids = childIds(open)(options);
|
|
91
96
|
setDisplayed((displayed) => _.union(displayed)(ids));
|
|
@@ -179,6 +184,7 @@ export const TreeSelector = ({
|
|
|
179
184
|
trigger={trigger}
|
|
180
185
|
upward={false}
|
|
181
186
|
value={value}
|
|
187
|
+
disabled={disabled}
|
|
182
188
|
>
|
|
183
189
|
<Dropdown.Menu>
|
|
184
190
|
<Input
|
|
@@ -59,18 +59,31 @@ const LanguajeRow = ({
|
|
|
59
59
|
</TableCell>
|
|
60
60
|
{!anyDefault ? (
|
|
61
61
|
<TableCell textAlign="center">
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
<ConfirmModal
|
|
63
|
+
trigger={
|
|
64
|
+
<Input
|
|
65
|
+
id={`radio-${lang}`}
|
|
66
|
+
type="radio"
|
|
67
|
+
name="is_default"
|
|
68
|
+
checked={is_default}
|
|
69
|
+
/>
|
|
70
|
+
}
|
|
71
|
+
header={formatMessage({
|
|
72
|
+
id: "i18n.messages.locale.setDefault.confirmation.header",
|
|
73
|
+
})}
|
|
74
|
+
content={formatMessage(
|
|
75
|
+
{
|
|
76
|
+
id: "i18n.messages.locale.setDefault.confirmation.content",
|
|
77
|
+
},
|
|
78
|
+
{ lang: local_name }
|
|
79
|
+
)}
|
|
80
|
+
onConfirm={() => handleChange({ id, locale: { is_default: true } })}
|
|
68
81
|
/>
|
|
69
82
|
</TableCell>
|
|
70
83
|
) : null}
|
|
71
84
|
|
|
72
85
|
<TableCell>
|
|
73
|
-
{!is_default
|
|
86
|
+
{!is_default ? (
|
|
74
87
|
<ConfirmModal
|
|
75
88
|
icon="trash"
|
|
76
89
|
trigger={
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
|
|
3
|
+
const translatableFieldTypes = ["enriched_text", "string"];
|
|
4
|
+
|
|
5
|
+
export const splitTranslatableFields = (template) =>
|
|
6
|
+
_.flow(
|
|
7
|
+
_.get("content"),
|
|
8
|
+
_.flatMap((group) =>
|
|
9
|
+
_.reduce(
|
|
10
|
+
(acc, { name, widget }) => {
|
|
11
|
+
const translatableKey = _.includes(widget)(translatableFieldTypes)
|
|
12
|
+
? "translatable"
|
|
13
|
+
: "noTranslatable";
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
...acc,
|
|
17
|
+
[translatableKey]: {
|
|
18
|
+
...acc[translatableKey],
|
|
19
|
+
[name]: _.cond([
|
|
20
|
+
[(w) => w == "enriched_text", _.constant({})],
|
|
21
|
+
[(w) => w == "string", _.constant("")],
|
|
22
|
+
[_.stubTrue, _.constant(null)],
|
|
23
|
+
])(widget),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
{ translatable: {}, noTranslatable: {} }
|
|
28
|
+
)(group.fields)
|
|
29
|
+
),
|
|
30
|
+
_.reduce(
|
|
31
|
+
(acc, { translatable, noTranslatable }) => {
|
|
32
|
+
return {
|
|
33
|
+
translatable: { ...acc.translatable, ...translatable },
|
|
34
|
+
noTranslatable: { ...acc.noTranslatable, ...noTranslatable },
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
{ translatable: {}, noTranslatable: {} }
|
|
38
|
+
)
|
|
39
|
+
)(template);
|
|
40
|
+
|
|
41
|
+
export const formatLocales = (locales) =>
|
|
42
|
+
_.flow(_.orderBy(["lang"], ["asc"]), (localeList) => ({
|
|
43
|
+
default: _.filter({
|
|
44
|
+
is_enabled: true,
|
|
45
|
+
is_required: true,
|
|
46
|
+
is_default: true,
|
|
47
|
+
})(localeList),
|
|
48
|
+
required: _.filter({
|
|
49
|
+
is_enabled: true,
|
|
50
|
+
is_required: true,
|
|
51
|
+
is_default: false,
|
|
52
|
+
})(localeList),
|
|
53
|
+
enabled: _.filter({
|
|
54
|
+
is_enabled: true,
|
|
55
|
+
is_required: false,
|
|
56
|
+
is_default: false,
|
|
57
|
+
})(localeList),
|
|
58
|
+
}))(locales);
|