@truedat/bg 8.6.6 → 8.7.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/bg",
3
- "version": "8.6.6",
3
+ "version": "8.7.0",
4
4
  "description": "Truedat Web Business Glossary",
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -54,7 +54,7 @@
54
54
  "@testing-library/jest-dom": "^6.6.3",
55
55
  "@testing-library/react": "^16.3.0",
56
56
  "@testing-library/user-event": "^14.6.1",
57
- "@truedat/test": "8.6.6",
57
+ "@truedat/test": "8.7.0",
58
58
  "identity-obj-proxy": "^3.0.0",
59
59
  "jest": "^29.7.0",
60
60
  "redux-saga-test-plan": "^4.0.6"
@@ -79,7 +79,7 @@
79
79
  "react-intl": "^7.1.11",
80
80
  "react-moment": "^1.1.3",
81
81
  "react-redux": "^9.2.0",
82
- "react-router": "^7.6.0",
82
+ "react-router": "^7.15.0",
83
83
  "redux": "^5.0.1",
84
84
  "redux-saga": "^1.3.0",
85
85
  "redux-saga-routines": "^3.2.3",
@@ -87,5 +87,5 @@
87
87
  "semantic-ui-react": "^3.0.0-beta.2",
88
88
  "swr": "^2.3.3"
89
89
  },
90
- "gitHead": "8a7cc3d7598dde1a52abbb9933118f4a90155d42"
90
+ "gitHead": "375298315086154cea326bfaebc504d6e45873ed"
91
91
  }
@@ -5,6 +5,7 @@ import PropTypes from "prop-types";
5
5
  import { connect } from "react-redux";
6
6
  import { useLanguage } from "@truedat/core/i18n";
7
7
  import { splitTranslatableFields } from "@truedat/core/services/i18nContent";
8
+ import { applyTemplate } from "@truedat/df/utils";
8
9
  import { conceptAction } from "../routines";
9
10
  import { useConceptVersionsActions } from "../hooks/useConcepts";
10
11
  import ConceptForm from "./ConceptForm";
@@ -20,16 +21,24 @@ const ConceptCreate = ({ conceptActionLoading, conceptAction }) => {
20
21
  const [template, setTemplate] = useState();
21
22
 
22
23
  useEffect(() => {
23
- const templateFields = splitTranslatableFields(template);
24
- const updateI18nConcept = _.flow(
25
- _.map((langContent) => ({
24
+ if (!template) return;
25
+
26
+ const translatableKeys = _.keys(
27
+ splitTranslatableFields(template).translatable,
28
+ );
29
+
30
+ const updateI18nConcept = _.mapValues((langContent) => {
31
+ const filled = applyTemplate(template)(
32
+ langContent.content || {},
33
+ domainId,
34
+ );
35
+ return {
26
36
  ...langContent,
27
37
  content: langContent.is_default
28
- ? { ...langContent.content }
29
- : { ..._.omitBy(_.isEmpty)(templateFields.translatable) },
30
- })),
31
- _.keyBy("lang"),
32
- )(i18nConcept);
38
+ ? filled
39
+ : _.pick(translatableKeys, filled),
40
+ };
41
+ })(i18nConcept);
33
42
 
34
43
  if (!_.isEqual(i18nConcept, updateI18nConcept)) {
35
44
  setI18nConcept(updateI18nConcept);
@@ -98,6 +98,10 @@ export const ConceptEditLoader = (props) => {
98
98
  const template = _.prop("template")(data);
99
99
  const processedContent = applyTemplate(template);
100
100
 
101
+ const translatableKeys = _.keys(
102
+ splitTranslatableFields(template).translatable,
103
+ );
104
+
101
105
  const i18nContent = _.flow(
102
106
  _.filter(({ is_enabled }) => is_enabled),
103
107
  _.map(({ id, lang, is_default, is_required }) => {
@@ -105,10 +109,10 @@ export const ConceptEditLoader = (props) => {
105
109
 
106
110
  const langContent = is_default
107
111
  ? propContent
108
- : {
109
- ...splitTranslatableFields(template).translatable,
110
- ...contentLang?.content,
111
- };
112
+ : _.pick(
113
+ translatableKeys,
114
+ processedContent(contentLang?.content || {}, domain?.id),
115
+ );
112
116
  const langName = is_default ? propName : contentLang?.name || "";
113
117
 
114
118
  return {
@@ -70,10 +70,10 @@ const ConceptForm = ({
70
70
  const handleI18nNameChange = (lang, name) =>
71
71
  setI18nConcept(_.set(`${lang}.name`, name, i18nConcept));
72
72
  const handleI18nConceptContentChange = (lang, { content }) => {
73
- setI18nConcept({
74
- ...i18nConcept,
75
- [lang]: { ...i18nConcept[lang], content: { ...content } },
76
- });
73
+ setI18nConcept((prev) => ({
74
+ ...prev,
75
+ [lang]: { ...prev[lang], content: { ...content } },
76
+ }));
77
77
  };
78
78
  const checkCanTranslate = () => {
79
79
  if (!disable_td_ai && templateId && domainId) {