@dhis2/analytics 23.6.3 → 23.6.4
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/build/cjs/components/TranslationDialog/TranslationModal/LocalesSelect.js +1 -1
- package/build/cjs/components/TranslationDialog/TranslationModal/TranslationForm.js +5 -4
- package/build/es/components/TranslationDialog/TranslationModal/LocalesSelect.js +1 -1
- package/build/es/components/TranslationDialog/TranslationModal/TranslationForm.js +6 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [23.6.4](https://github.com/dhis2/analytics/compare/v23.6.3...v23.6.4) (2022-03-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **TranslationDialog:** remove warnings ([#1174](https://github.com/dhis2/analytics/issues/1174)) ([c7e778d](https://github.com/dhis2/analytics/commit/c7e778da4b9aa6f950b874bd6f61a4018a5c8f3f))
|
|
7
|
+
|
|
1
8
|
## [23.6.3](https://github.com/dhis2/analytics/compare/v23.6.2...v23.6.3) (2022-03-16)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -37,7 +37,7 @@ const LocalesSelect = ({
|
|
|
37
37
|
selected
|
|
38
38
|
}) => onChange(selected),
|
|
39
39
|
loading: fetching,
|
|
40
|
-
selected: data ? selected :
|
|
40
|
+
selected: data && selected ? selected : '',
|
|
41
41
|
dense: true
|
|
42
42
|
}, data && data.locales // XXX remove duplicates ?! fr_SN - French (Senegal)
|
|
43
43
|
.reduce((locales, {
|
|
@@ -27,6 +27,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
27
|
|
|
28
28
|
const SESSION_STORAGE_TRANSLATION_LOCALE_KEY = 'translation-dialog-selected-locale';
|
|
29
29
|
|
|
30
|
+
const camelCaseToUnderscores = field => field.replace(/[a-z][A-Z]/g, match => [match.charAt(0), match.charAt(1)].join('_')).toLowerCase();
|
|
31
|
+
|
|
30
32
|
const TranslationForm = ({
|
|
31
33
|
fieldsToTranslate,
|
|
32
34
|
objectToTranslate,
|
|
@@ -44,8 +46,6 @@ const TranslationForm = ({
|
|
|
44
46
|
critical: true
|
|
45
47
|
});
|
|
46
48
|
|
|
47
|
-
const camelCaseToUnderscores = field => field.replace(/[a-z][A-Z]/g, match => [match.charAt(0), match.charAt(1)].join('_')).toLowerCase();
|
|
48
|
-
|
|
49
49
|
const getTranslationIndexForField = field => newTranslations.findIndex(element => element.locale === translationLocale && element.property.toLowerCase() === camelCaseToUnderscores(field));
|
|
50
50
|
|
|
51
51
|
const getTranslationForField = field => {
|
|
@@ -65,11 +65,12 @@ const TranslationForm = ({
|
|
|
65
65
|
setNewTranslations(translationIndex === -1 ? [...newTranslations, newTranslation] : newTranslations.map((translation, index) => index === translationIndex ? newTranslation : translation));
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const
|
|
68
|
+
const i18nMutationRef = (0, _react.useRef)({
|
|
69
69
|
resource: 'i18n',
|
|
70
70
|
type: 'create',
|
|
71
71
|
data: fieldsToTranslate.map(camelCaseToUnderscores)
|
|
72
|
-
}
|
|
72
|
+
});
|
|
73
|
+
const [fetchFieldsTranslations] = (0, _appRuntime.useDataMutation)(i18nMutationRef.current, {
|
|
73
74
|
onComplete: res => setFieldsTranslations(res),
|
|
74
75
|
onError: error => showError(error)
|
|
75
76
|
});
|
|
@@ -22,7 +22,7 @@ export const LocalesSelect = ({
|
|
|
22
22
|
selected
|
|
23
23
|
}) => onChange(selected),
|
|
24
24
|
loading: fetching,
|
|
25
|
-
selected: data ? selected :
|
|
25
|
+
selected: data && selected ? selected : '',
|
|
26
26
|
dense: true
|
|
27
27
|
}, data && data.locales // XXX remove duplicates ?! fr_SN - French (Senegal)
|
|
28
28
|
.reduce((locales, {
|
|
@@ -6,6 +6,9 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
6
6
|
import { LocalesSelect } from './LocalesSelect.js';
|
|
7
7
|
import { TranslationModalActions } from './TranslationModalActions.js';
|
|
8
8
|
const SESSION_STORAGE_TRANSLATION_LOCALE_KEY = 'translation-dialog-selected-locale';
|
|
9
|
+
|
|
10
|
+
const camelCaseToUnderscores = field => field.replace(/[a-z][A-Z]/g, match => [match.charAt(0), match.charAt(1)].join('_')).toLowerCase();
|
|
11
|
+
|
|
9
12
|
export const TranslationForm = ({
|
|
10
13
|
fieldsToTranslate,
|
|
11
14
|
objectToTranslate,
|
|
@@ -23,8 +26,6 @@ export const TranslationForm = ({
|
|
|
23
26
|
critical: true
|
|
24
27
|
});
|
|
25
28
|
|
|
26
|
-
const camelCaseToUnderscores = field => field.replace(/[a-z][A-Z]/g, match => [match.charAt(0), match.charAt(1)].join('_')).toLowerCase();
|
|
27
|
-
|
|
28
29
|
const getTranslationIndexForField = field => newTranslations.findIndex(element => element.locale === translationLocale && element.property.toLowerCase() === camelCaseToUnderscores(field));
|
|
29
30
|
|
|
30
31
|
const getTranslationForField = field => {
|
|
@@ -44,11 +45,12 @@ export const TranslationForm = ({
|
|
|
44
45
|
setNewTranslations(translationIndex === -1 ? [...newTranslations, newTranslation] : newTranslations.map((translation, index) => index === translationIndex ? newTranslation : translation));
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
const
|
|
48
|
+
const i18nMutationRef = useRef({
|
|
48
49
|
resource: 'i18n',
|
|
49
50
|
type: 'create',
|
|
50
51
|
data: fieldsToTranslate.map(camelCaseToUnderscores)
|
|
51
|
-
}
|
|
52
|
+
});
|
|
53
|
+
const [fetchFieldsTranslations] = useDataMutation(i18nMutationRef.current, {
|
|
52
54
|
onComplete: res => setFieldsTranslations(res),
|
|
53
55
|
onError: error => showError(error)
|
|
54
56
|
});
|