@dhis2/analytics 24.3.10 → 24.3.11

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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [24.3.11](https://github.com/dhis2/analytics/compare/v24.3.10...v24.3.11) (2022-12-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * do not pass translation object when value is empty ([#1401](https://github.com/dhis2/analytics/issues/1401)) ([03c6a2e](https://github.com/dhis2/analytics/commit/03c6a2ee98b437fed2a44233e4a750d17bd3c5af))
7
+
1
8
  ## [24.3.10](https://github.com/dhis2/analytics/compare/v24.3.9...v24.3.10) (2022-12-02)
2
9
 
3
10
 
@@ -63,7 +63,25 @@ const TranslationForm = _ref => {
63
63
  value: translation
64
64
  };
65
65
  const translationIndex = getTranslationIndexForField(field);
66
- setNewTranslations(translationIndex === -1 ? [...newTranslations, newTranslation] : newTranslations.map((translation, index) => index === translationIndex ? newTranslation : translation));
66
+
67
+ if (translationIndex === -1) {
68
+ // non existing translation, adding new
69
+ setNewTranslations([...newTranslations, newTranslation]);
70
+ } else {
71
+ // cleared existing translation, remove it from the list
72
+ if (!translation) {
73
+ setNewTranslations(newTranslations.reduce((tmp, translation, index) => {
74
+ if (index !== translationIndex) {
75
+ tmp.push(translation);
76
+ }
77
+
78
+ return tmp;
79
+ }, []));
80
+ } // replace existing translation with new one
81
+ else {
82
+ setNewTranslations(newTranslations.map((translation, index) => index === translationIndex ? newTranslation : translation));
83
+ }
84
+ }
67
85
  };
68
86
 
69
87
  const i18nMutationRef = (0, _react.useRef)({
@@ -43,7 +43,25 @@ export const TranslationForm = _ref => {
43
43
  value: translation
44
44
  };
45
45
  const translationIndex = getTranslationIndexForField(field);
46
- setNewTranslations(translationIndex === -1 ? [...newTranslations, newTranslation] : newTranslations.map((translation, index) => index === translationIndex ? newTranslation : translation));
46
+
47
+ if (translationIndex === -1) {
48
+ // non existing translation, adding new
49
+ setNewTranslations([...newTranslations, newTranslation]);
50
+ } else {
51
+ // cleared existing translation, remove it from the list
52
+ if (!translation) {
53
+ setNewTranslations(newTranslations.reduce((tmp, translation, index) => {
54
+ if (index !== translationIndex) {
55
+ tmp.push(translation);
56
+ }
57
+
58
+ return tmp;
59
+ }, []));
60
+ } // replace existing translation with new one
61
+ else {
62
+ setNewTranslations(newTranslations.map((translation, index) => index === translationIndex ? newTranslation : translation));
63
+ }
64
+ }
47
65
  };
48
66
 
49
67
  const i18nMutationRef = useRef({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2/analytics",
3
- "version": "24.3.10",
3
+ "version": "24.3.11",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/es/index.js",
6
6
  "exports": {