@dhis2/analytics 21.1.1 → 21.2.3
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 +28 -0
- package/build/cjs/components/FileMenu/FileMenu.js +6 -16
- package/build/cjs/components/FileMenu/__tests__/FileMenu.spec.js +3 -3
- package/build/cjs/components/TranslationDialog/TranslationModal/LocalesSelect.js +69 -0
- package/build/cjs/components/TranslationDialog/TranslationModal/TranslationForm.js +152 -0
- package/build/cjs/components/TranslationDialog/TranslationModal/TranslationModal.js +76 -0
- package/build/cjs/components/TranslationDialog/TranslationModal/TranslationModalActions.js +39 -0
- package/build/cjs/components/TranslationDialog/TranslationModal/useTranslationsResults.js +46 -0
- package/build/cjs/components/TranslationDialog/index.js +13 -0
- package/build/cjs/locales/ar/translations.json +7 -0
- package/build/cjs/locales/ar_EG/translations.json +7 -0
- package/build/cjs/locales/ar_IQ/translations.json +7 -0
- package/build/cjs/locales/ckb/translations.json +7 -0
- package/build/cjs/locales/cs/translations.json +7 -0
- package/build/cjs/locales/da/translations.json +7 -0
- package/build/cjs/locales/en/translations.json +8 -0
- package/build/cjs/locales/es/translations.json +7 -0
- package/build/cjs/locales/fr/translations.json +7 -0
- package/build/cjs/locales/id/translations.json +7 -0
- package/build/cjs/locales/km/translations.json +7 -0
- package/build/cjs/locales/lo/translations.json +7 -0
- package/build/cjs/locales/my/translations.json +7 -0
- package/build/cjs/locales/nb/translations.json +7 -0
- package/build/cjs/locales/nl/translations.json +7 -0
- package/build/cjs/locales/prs/translations.json +7 -0
- package/build/cjs/locales/ps/translations.json +7 -0
- package/build/cjs/locales/pt/translations.json +7 -0
- package/build/cjs/locales/pt_BR/translations.json +7 -0
- package/build/cjs/locales/ru/translations.json +7 -0
- package/build/cjs/locales/sv/translations.json +7 -0
- package/build/cjs/locales/tet/translations.json +7 -0
- package/build/cjs/locales/tg/translations.json +7 -0
- package/build/cjs/locales/uk/translations.json +7 -0
- package/build/cjs/locales/ur/translations.json +7 -0
- package/build/cjs/locales/uz/translations.json +7 -0
- package/build/cjs/locales/uz_Latn/translations.json +7 -0
- package/build/cjs/locales/vi/translations.json +7 -0
- package/build/cjs/locales/zh/translations.json +7 -0
- package/build/cjs/locales/zh_CN/translations.json +7 -0
- package/build/es/components/FileMenu/FileMenu.js +4 -14
- package/build/es/components/FileMenu/__tests__/FileMenu.spec.js +1 -1
- package/build/es/components/TranslationDialog/TranslationModal/LocalesSelect.js +52 -0
- package/build/es/components/TranslationDialog/TranslationModal/TranslationForm.js +129 -0
- package/build/es/components/TranslationDialog/TranslationModal/TranslationModal.js +54 -0
- package/build/es/components/TranslationDialog/TranslationModal/TranslationModalActions.js +24 -0
- package/build/es/components/TranslationDialog/TranslationModal/useTranslationsResults.js +32 -0
- package/build/es/components/TranslationDialog/index.js +2 -0
- package/build/es/locales/ar/translations.json +7 -0
- package/build/es/locales/ar_EG/translations.json +7 -0
- package/build/es/locales/ar_IQ/translations.json +7 -0
- package/build/es/locales/ckb/translations.json +7 -0
- package/build/es/locales/cs/translations.json +7 -0
- package/build/es/locales/da/translations.json +7 -0
- package/build/es/locales/en/translations.json +8 -0
- package/build/es/locales/es/translations.json +7 -0
- package/build/es/locales/fr/translations.json +7 -0
- package/build/es/locales/id/translations.json +7 -0
- package/build/es/locales/km/translations.json +7 -0
- package/build/es/locales/lo/translations.json +7 -0
- package/build/es/locales/my/translations.json +7 -0
- package/build/es/locales/nb/translations.json +7 -0
- package/build/es/locales/nl/translations.json +7 -0
- package/build/es/locales/prs/translations.json +7 -0
- package/build/es/locales/ps/translations.json +7 -0
- package/build/es/locales/pt/translations.json +7 -0
- package/build/es/locales/pt_BR/translations.json +7 -0
- package/build/es/locales/ru/translations.json +7 -0
- package/build/es/locales/sv/translations.json +7 -0
- package/build/es/locales/tet/translations.json +7 -0
- package/build/es/locales/tg/translations.json +7 -0
- package/build/es/locales/uk/translations.json +7 -0
- package/build/es/locales/ur/translations.json +7 -0
- package/build/es/locales/uz/translations.json +7 -0
- package/build/es/locales/uz_Latn/translations.json +7 -0
- package/build/es/locales/vi/translations.json +7 -0
- package/build/es/locales/zh/translations.json +7 -0
- package/build/es/locales/zh_CN/translations.json +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [21.2.3](https://github.com/dhis2/analytics/compare/v21.2.2...v21.2.3) (2022-01-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fetch translations for field labels from api ([#1119](https://github.com/dhis2/analytics/issues/1119)) ([e2fcacc](https://github.com/dhis2/analytics/commit/e2fcaccbd058a8e85a99e032f6341e7f15a83b94))
|
|
7
|
+
|
|
8
|
+
## [21.2.2](https://github.com/dhis2/analytics/compare/v21.2.1...v21.2.2) (2021-12-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **translations:** sync translations from transifex (master) ([2657706](https://github.com/dhis2/analytics/commit/2657706a6033413cc0d405933b6d6ed180bd509c))
|
|
14
|
+
|
|
15
|
+
## [21.2.1](https://github.com/dhis2/analytics/compare/v21.2.0...v21.2.1) (2021-12-24)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **translations:** sync translations from transifex (master) ([83f9fe4](https://github.com/dhis2/analytics/commit/83f9fe42eb3e5efa115298a7561f5ddc5a627cc5))
|
|
21
|
+
|
|
22
|
+
# [21.2.0](https://github.com/dhis2/analytics/compare/v21.1.1...v21.2.0) (2021-12-23)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* use new translations dialog (TECH-873) ([#1105](https://github.com/dhis2/analytics/issues/1105)) ([1e1a984](https://github.com/dhis2/analytics/commit/1e1a98429663241487ad66c56d3aab3914b8cbc6))
|
|
28
|
+
|
|
1
29
|
## [21.1.1](https://github.com/dhis2/analytics/compare/v21.1.0...v21.1.1) (2021-12-22)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -7,8 +7,6 @@ exports.default = exports.FileMenu = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
9
|
|
|
10
|
-
var _d2UiTranslationDialog = _interopRequireDefault(require("@dhis2/d2-ui-translation-dialog"));
|
|
11
|
-
|
|
12
10
|
var _ui = require("@dhis2/ui");
|
|
13
11
|
|
|
14
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -19,6 +17,8 @@ var _index = _interopRequireDefault(require("../../locales/index.js"));
|
|
|
19
17
|
|
|
20
18
|
var _OpenFileDialog = require("../OpenFileDialog/OpenFileDialog.js");
|
|
21
19
|
|
|
20
|
+
var _index2 = require("../TranslationDialog/index.js");
|
|
21
|
+
|
|
22
22
|
var _DeleteDialog = require("./DeleteDialog.js");
|
|
23
23
|
|
|
24
24
|
var _FileMenuStyles = require("./FileMenu.styles.js");
|
|
@@ -95,21 +95,11 @@ const FileMenu = ({
|
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
case 'translate':
|
|
98
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
99
|
-
|
|
100
|
-
d2: d2,
|
|
101
|
-
objectToTranslate: { ...fileObject,
|
|
102
|
-
// mock modelDefinition to avoid an error
|
|
103
|
-
// in the TranslationDialog component
|
|
104
|
-
modelDefinition: {
|
|
105
|
-
name: fileType
|
|
106
|
-
}
|
|
107
|
-
},
|
|
98
|
+
return /*#__PURE__*/_react.default.createElement(_index2.TranslationDialog, {
|
|
99
|
+
objectToTranslate: fileObject,
|
|
108
100
|
fieldsToTranslate: ['name', 'description'],
|
|
109
|
-
|
|
110
|
-
onTranslationSaved: onTranslate
|
|
111
|
-
onTranslationError: onError,
|
|
112
|
-
insertTheme: true
|
|
101
|
+
onClose: onDialogClose,
|
|
102
|
+
onTranslationSaved: onTranslate
|
|
113
103
|
});
|
|
114
104
|
|
|
115
105
|
case 'sharing':
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _d2UiTranslationDialog = _interopRequireDefault(require("@dhis2/d2-ui-translation-dialog"));
|
|
4
|
-
|
|
5
3
|
var _ui = require("@dhis2/ui");
|
|
6
4
|
|
|
7
5
|
var _enzyme = require("enzyme");
|
|
@@ -10,6 +8,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
8
|
|
|
11
9
|
var _OpenFileDialog = require("../../OpenFileDialog/OpenFileDialog.js");
|
|
12
10
|
|
|
11
|
+
var _index = require("../../TranslationDialog/index.js");
|
|
12
|
+
|
|
13
13
|
var _DeleteDialog = require("../DeleteDialog.js");
|
|
14
14
|
|
|
15
15
|
var _FileMenu = require("../FileMenu.js");
|
|
@@ -152,7 +152,7 @@ describe('The FileMenu component ', () => {
|
|
|
152
152
|
const fileMenuComponent = getFileMenuComponent(props);
|
|
153
153
|
fileMenuComponent.find('button').simulate('click');
|
|
154
154
|
fileMenuComponent.findWhere(n => n.prop('label') === 'Translate…').simulate('click');
|
|
155
|
-
expect(fileMenuComponent.find(
|
|
155
|
+
expect(fileMenuComponent.find(_index.TranslationDialog)).toHaveLength(1);
|
|
156
156
|
});
|
|
157
157
|
it('renders the SharingDialog when the Share button is clicked', () => {
|
|
158
158
|
props.fileObject = {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LocalesSelect = void 0;
|
|
7
|
+
|
|
8
|
+
var _appRuntime = require("@dhis2/app-runtime");
|
|
9
|
+
|
|
10
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
11
|
+
|
|
12
|
+
var _ui = require("@dhis2/ui");
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
const query = {
|
|
21
|
+
locales: {
|
|
22
|
+
resource: 'locales/db'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const LocalesSelect = ({
|
|
27
|
+
onChange,
|
|
28
|
+
selected
|
|
29
|
+
}) => {
|
|
30
|
+
const {
|
|
31
|
+
data,
|
|
32
|
+
fetching
|
|
33
|
+
} = (0, _appRuntime.useDataQuery)(query);
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_ui.SingleSelect, {
|
|
35
|
+
prefix: selected ? _d2I18n.default.t('Translating to') : _d2I18n.default.t('Choose a locale'),
|
|
36
|
+
onChange: ({
|
|
37
|
+
selected
|
|
38
|
+
}) => onChange(selected),
|
|
39
|
+
loading: fetching,
|
|
40
|
+
selected: data ? selected : undefined,
|
|
41
|
+
dense: true
|
|
42
|
+
}, data && data.locales // XXX remove duplicates ?! fr_SN - French (Senegal)
|
|
43
|
+
.reduce((locales, {
|
|
44
|
+
locale,
|
|
45
|
+
name
|
|
46
|
+
}) => {
|
|
47
|
+
if (!locales.find(entry => entry.locale === locale)) {
|
|
48
|
+
locales.push({
|
|
49
|
+
locale,
|
|
50
|
+
name
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return locales;
|
|
55
|
+
}, []).map(({
|
|
56
|
+
locale,
|
|
57
|
+
name
|
|
58
|
+
}) => /*#__PURE__*/_react.default.createElement(_ui.SingleSelectOption, {
|
|
59
|
+
key: locale,
|
|
60
|
+
value: locale,
|
|
61
|
+
label: name
|
|
62
|
+
})));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.LocalesSelect = LocalesSelect;
|
|
66
|
+
LocalesSelect.propTypes = {
|
|
67
|
+
onChange: _propTypes.default.func.isRequired,
|
|
68
|
+
selected: _propTypes.default.string
|
|
69
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TranslationForm = void 0;
|
|
7
|
+
|
|
8
|
+
var _appRuntime = require("@dhis2/app-runtime");
|
|
9
|
+
|
|
10
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
11
|
+
|
|
12
|
+
var _ui = require("@dhis2/ui");
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _LocalesSelect = require("./LocalesSelect.js");
|
|
19
|
+
|
|
20
|
+
var _TranslationModalActions = require("./TranslationModalActions.js");
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
const SESSION_STORAGE_TRANSLATION_LOCALE_KEY = 'translation-dialog-selected-locale';
|
|
29
|
+
|
|
30
|
+
const TranslationForm = ({
|
|
31
|
+
fieldsToTranslate,
|
|
32
|
+
objectToTranslate,
|
|
33
|
+
translations,
|
|
34
|
+
resource,
|
|
35
|
+
onTranslationSaved,
|
|
36
|
+
onClose
|
|
37
|
+
}) => {
|
|
38
|
+
const [newTranslations, setNewTranslations] = (0, _react.useState)();
|
|
39
|
+
const [translationLocale, setTranslationLocale] = (0, _react.useState)();
|
|
40
|
+
const [fieldsTranslations, setFieldsTranslations] = (0, _react.useState)({});
|
|
41
|
+
const {
|
|
42
|
+
show: showError
|
|
43
|
+
} = (0, _appRuntime.useAlert)(error => error, {
|
|
44
|
+
critical: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const camelCaseToUnderscores = field => field.replace(/[a-z][A-Z]/g, match => [match.charAt(0), match.charAt(1)].join('_')).toLowerCase();
|
|
48
|
+
|
|
49
|
+
const getTranslationIndexForField = field => newTranslations.findIndex(element => element.locale === translationLocale && element.property.toLowerCase() === camelCaseToUnderscores(field));
|
|
50
|
+
|
|
51
|
+
const getTranslationForField = field => {
|
|
52
|
+
var _newTranslations$tran;
|
|
53
|
+
|
|
54
|
+
const translationIndex = getTranslationIndexForField(field);
|
|
55
|
+
return translationIndex !== -1 ? ((_newTranslations$tran = newTranslations[translationIndex]) === null || _newTranslations$tran === void 0 ? void 0 : _newTranslations$tran.value) || '' : '';
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const setTranslationForField = (field, translation) => {
|
|
59
|
+
const newTranslation = {
|
|
60
|
+
locale: translationLocale,
|
|
61
|
+
property: camelCaseToUnderscores(field).toUpperCase(),
|
|
62
|
+
value: translation
|
|
63
|
+
};
|
|
64
|
+
const translationIndex = getTranslationIndexForField(field);
|
|
65
|
+
setNewTranslations(translationIndex === -1 ? [...newTranslations, newTranslation] : newTranslations.map((translation, index) => index === translationIndex ? newTranslation : translation));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const [fetchFieldsTranslations] = (0, _appRuntime.useDataMutation)({
|
|
69
|
+
resource: 'i18n',
|
|
70
|
+
type: 'create',
|
|
71
|
+
data: fieldsToTranslate.map(camelCaseToUnderscores)
|
|
72
|
+
}, {
|
|
73
|
+
onComplete: res => setFieldsTranslations(res),
|
|
74
|
+
onError: error => showError(error)
|
|
75
|
+
});
|
|
76
|
+
const translationsMutationRef = (0, _react.useRef)({
|
|
77
|
+
resource: "".concat(resource, "/translations"),
|
|
78
|
+
type: 'update',
|
|
79
|
+
data: ({
|
|
80
|
+
translations
|
|
81
|
+
}) => ({
|
|
82
|
+
translations
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
const [saveTranslations, {
|
|
86
|
+
loading: saveInProgress
|
|
87
|
+
}] = (0, _appRuntime.useDataMutation)(translationsMutationRef.current, {
|
|
88
|
+
onComplete: () => {
|
|
89
|
+
onTranslationSaved();
|
|
90
|
+
onClose();
|
|
91
|
+
},
|
|
92
|
+
onError: error => showError(error)
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const onLocaleChange = locale => {
|
|
96
|
+
setTranslationLocale(locale);
|
|
97
|
+
window.sessionStorage.setItem(SESSION_STORAGE_TRANSLATION_LOCALE_KEY, locale);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const save = () => saveTranslations({
|
|
101
|
+
translations: newTranslations
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
(0, _react.useEffect)(() => setTranslationLocale(window.sessionStorage.getItem(SESSION_STORAGE_TRANSLATION_LOCALE_KEY)), []);
|
|
105
|
+
(0, _react.useEffect)(() => {
|
|
106
|
+
const fetchTranslations = () => fetchFieldsTranslations(fieldsToTranslate);
|
|
107
|
+
|
|
108
|
+
fetchTranslations();
|
|
109
|
+
}, [fieldsToTranslate]);
|
|
110
|
+
(0, _react.useEffect)(() => setNewTranslations(translations), [translations]);
|
|
111
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ui.ModalContent, null, /*#__PURE__*/_react.default.createElement(_ui.DataTable, {
|
|
112
|
+
layout: "fixed"
|
|
113
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.DataTableHead, null, /*#__PURE__*/_react.default.createElement(_ui.DataTableRow, null, /*#__PURE__*/_react.default.createElement(_ui.DataTableColumnHeader, {
|
|
114
|
+
fixed: true,
|
|
115
|
+
top: "0"
|
|
116
|
+
}, _d2I18n.default.t('Base locale reference')), /*#__PURE__*/_react.default.createElement(_ui.DataTableColumnHeader, {
|
|
117
|
+
fixed: true,
|
|
118
|
+
top: "0"
|
|
119
|
+
}, /*#__PURE__*/_react.default.createElement(_LocalesSelect.LocalesSelect, {
|
|
120
|
+
selected: translationLocale,
|
|
121
|
+
onChange: onLocaleChange
|
|
122
|
+
})))), /*#__PURE__*/_react.default.createElement(_ui.DataTableBody, null, fieldsToTranslate.map((field, index) => /*#__PURE__*/_react.default.createElement(_ui.DataTableRow, {
|
|
123
|
+
key: field
|
|
124
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, null, /*#__PURE__*/_react.default.createElement(_ui.InputField, {
|
|
125
|
+
label: fieldsTranslations[field],
|
|
126
|
+
value: objectToTranslate[field],
|
|
127
|
+
readOnly: true
|
|
128
|
+
})), translationLocale && /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, null, /*#__PURE__*/_react.default.createElement(_ui.InputField, {
|
|
129
|
+
label: fieldsTranslations[field],
|
|
130
|
+
value: getTranslationForField(field),
|
|
131
|
+
onChange: ({
|
|
132
|
+
value
|
|
133
|
+
}) => setTranslationForField(field, value)
|
|
134
|
+
})), !translationLocale && index === 0 && /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, {
|
|
135
|
+
rowSpan: String(fieldsToTranslate.length)
|
|
136
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.CenteredContent, null, _d2I18n.default.t('Choose a locale to translate from the menu above')))))))), /*#__PURE__*/_react.default.createElement(_TranslationModalActions.TranslationModalActions, {
|
|
137
|
+
onClose: onClose,
|
|
138
|
+
onSave: save,
|
|
139
|
+
saveInProgress: saveInProgress,
|
|
140
|
+
saveButtonDisabled: !translationLocale
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
exports.TranslationForm = TranslationForm;
|
|
145
|
+
TranslationForm.propTypes = {
|
|
146
|
+
fieldsToTranslate: _propTypes.default.array.isRequired,
|
|
147
|
+
objectToTranslate: _propTypes.default.object.isRequired,
|
|
148
|
+
resource: _propTypes.default.string.isRequired,
|
|
149
|
+
translations: _propTypes.default.array.isRequired,
|
|
150
|
+
onClose: _propTypes.default.func.isRequired,
|
|
151
|
+
onTranslationSaved: _propTypes.default.func.isRequired
|
|
152
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TranslationModal = void 0;
|
|
7
|
+
|
|
8
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
9
|
+
|
|
10
|
+
var _ui = require("@dhis2/ui");
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _TranslationForm = require("./TranslationForm.js");
|
|
17
|
+
|
|
18
|
+
var _TranslationModalActions = require("./TranslationModalActions.js");
|
|
19
|
+
|
|
20
|
+
var _useTranslationsResults = require("./useTranslationsResults.js");
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
const TranslationModal = ({
|
|
29
|
+
objectToTranslate,
|
|
30
|
+
fieldsToTranslate,
|
|
31
|
+
onClose,
|
|
32
|
+
onTranslationSaved
|
|
33
|
+
}) => {
|
|
34
|
+
const [translations, setTranslations] = (0, _react.useState)([]);
|
|
35
|
+
const endpointPath = new URL(objectToTranslate.href).pathname;
|
|
36
|
+
const endpointPathMatch = endpointPath.match(/api\/\d+\/(?<resource>.+)/);
|
|
37
|
+
const resource = endpointPathMatch !== null && endpointPathMatch !== void 0 && endpointPathMatch.groups ? endpointPathMatch.groups.resource : null;
|
|
38
|
+
const {
|
|
39
|
+
translationsData,
|
|
40
|
+
fetching
|
|
41
|
+
} = (0, _useTranslationsResults.useTranslationsResults)({
|
|
42
|
+
resource
|
|
43
|
+
});
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
if (translationsData) {
|
|
46
|
+
setTranslations(translationsData);
|
|
47
|
+
}
|
|
48
|
+
}, [translationsData]);
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Modal, {
|
|
50
|
+
large: true,
|
|
51
|
+
position: "middle",
|
|
52
|
+
onClose: onClose
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.ModalTitle, null, _d2I18n.default.t('Translate: {{objectName}}', {
|
|
54
|
+
objectName: objectToTranslate.name || 'TEXT',
|
|
55
|
+
// XXX
|
|
56
|
+
nsSeparator: '^^'
|
|
57
|
+
})), fetching ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ui.ModalContent, null, /*#__PURE__*/_react.default.createElement(_ui.CenteredContent, null, /*#__PURE__*/_react.default.createElement(_ui.CircularLoader, null))), /*#__PURE__*/_react.default.createElement(_TranslationModalActions.TranslationModalActions, {
|
|
58
|
+
onClose: onClose,
|
|
59
|
+
saveButtonDisabled: true
|
|
60
|
+
})) : /*#__PURE__*/_react.default.createElement(_TranslationForm.TranslationForm, {
|
|
61
|
+
fieldsToTranslate: fieldsToTranslate,
|
|
62
|
+
objectToTranslate: objectToTranslate,
|
|
63
|
+
translations: translations,
|
|
64
|
+
onTranslationSaved: onTranslationSaved,
|
|
65
|
+
resource: resource,
|
|
66
|
+
onClose: onClose
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.TranslationModal = TranslationModal;
|
|
71
|
+
TranslationModal.propTypes = {
|
|
72
|
+
fieldsToTranslate: _propTypes.default.array.isRequired,
|
|
73
|
+
objectToTranslate: _propTypes.default.object.isRequired,
|
|
74
|
+
onClose: _propTypes.default.func.isRequired,
|
|
75
|
+
onTranslationSaved: _propTypes.default.func.isRequired
|
|
76
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TranslationModalActions = void 0;
|
|
7
|
+
|
|
8
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
9
|
+
|
|
10
|
+
var _ui = require("@dhis2/ui");
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
const TranslationModalActions = ({
|
|
19
|
+
onClose,
|
|
20
|
+
onSave,
|
|
21
|
+
saveInProgress,
|
|
22
|
+
saveButtonDisabled
|
|
23
|
+
}) => /*#__PURE__*/_react.default.createElement(_ui.ModalActions, null, /*#__PURE__*/_react.default.createElement(_ui.ButtonStrip, null, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
24
|
+
secondary: true,
|
|
25
|
+
onClick: onClose
|
|
26
|
+
}, _d2I18n.default.t('Cancel')), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
27
|
+
primary: true,
|
|
28
|
+
onClick: onSave,
|
|
29
|
+
loading: saveInProgress,
|
|
30
|
+
disabled: saveButtonDisabled
|
|
31
|
+
}, _d2I18n.default.t('Save translations'))));
|
|
32
|
+
|
|
33
|
+
exports.TranslationModalActions = TranslationModalActions;
|
|
34
|
+
TranslationModalActions.propTypes = {
|
|
35
|
+
onClose: _propTypes.default.func.isRequired,
|
|
36
|
+
saveButtonDisabled: _propTypes.default.bool,
|
|
37
|
+
saveInProgress: _propTypes.default.bool,
|
|
38
|
+
onSave: _propTypes.default.func
|
|
39
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTranslationsResults = void 0;
|
|
7
|
+
|
|
8
|
+
var _appRuntime = require("@dhis2/app-runtime");
|
|
9
|
+
|
|
10
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
11
|
+
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const useTranslationsResults = ({
|
|
17
|
+
resource
|
|
18
|
+
}) => {
|
|
19
|
+
const translationsQueryRef = (0, _react.useRef)({
|
|
20
|
+
translations: {
|
|
21
|
+
resource: "".concat(resource, "/translations")
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const {
|
|
25
|
+
data,
|
|
26
|
+
fetching,
|
|
27
|
+
refetch
|
|
28
|
+
} = (0, _appRuntime.useDataQuery)(translationsQueryRef.current, {
|
|
29
|
+
onError: error => showError(error)
|
|
30
|
+
});
|
|
31
|
+
const {
|
|
32
|
+
show: showError
|
|
33
|
+
} = (0, _appRuntime.useAlert)(error => error.message || _d2I18n.default.t('Could not load translations'), {
|
|
34
|
+
critical: true,
|
|
35
|
+
actions: [{
|
|
36
|
+
label: _d2I18n.default.t('Retry'),
|
|
37
|
+
onClick: refetch
|
|
38
|
+
}]
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
translationsData: fetching ? undefined : data.translations.translations,
|
|
42
|
+
fetching
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.useTranslationsResults = useTranslationsResults;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "TranslationDialog", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _TranslationModal.TranslationModal;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _TranslationModal = require("./TranslationModal/TranslationModal.js");
|
|
@@ -238,6 +238,13 @@
|
|
|
238
238
|
"Six-months": "ستة-أشهر",
|
|
239
239
|
"Financial Years": "السنوات المالية",
|
|
240
240
|
"Years": "السنوات",
|
|
241
|
+
"Translating to": "",
|
|
242
|
+
"Choose a locale": "",
|
|
243
|
+
"Base locale reference": "",
|
|
244
|
+
"Choose a locale to translate from the menu above": "",
|
|
245
|
+
"Translate: {{objectName}}": "",
|
|
246
|
+
"Save translations": "",
|
|
247
|
+
"Retry": "",
|
|
241
248
|
"Series": "سلسلة",
|
|
242
249
|
"Category": "الفئة",
|
|
243
250
|
"Filter": "عامل التصفية",
|
|
@@ -238,6 +238,13 @@
|
|
|
238
238
|
"Six-months": "",
|
|
239
239
|
"Financial Years": "",
|
|
240
240
|
"Years": "",
|
|
241
|
+
"Translating to": "",
|
|
242
|
+
"Choose a locale": "",
|
|
243
|
+
"Base locale reference": "",
|
|
244
|
+
"Choose a locale to translate from the menu above": "",
|
|
245
|
+
"Translate: {{objectName}}": "",
|
|
246
|
+
"Save translations": "",
|
|
247
|
+
"Retry": "",
|
|
241
248
|
"Series": "",
|
|
242
249
|
"Category": "",
|
|
243
250
|
"Filter": "",
|
|
@@ -238,6 +238,13 @@
|
|
|
238
238
|
"Six-months": "ستة أشهر",
|
|
239
239
|
"Financial Years": "",
|
|
240
240
|
"Years": "السنوات",
|
|
241
|
+
"Translating to": "",
|
|
242
|
+
"Choose a locale": "",
|
|
243
|
+
"Base locale reference": "",
|
|
244
|
+
"Choose a locale to translate from the menu above": "",
|
|
245
|
+
"Translate: {{objectName}}": "",
|
|
246
|
+
"Save translations": "",
|
|
247
|
+
"Retry": "",
|
|
241
248
|
"Series": "",
|
|
242
249
|
"Category": "",
|
|
243
250
|
"Filter": "",
|
|
@@ -222,6 +222,13 @@
|
|
|
222
222
|
"Six-months": "",
|
|
223
223
|
"Financial Years": "",
|
|
224
224
|
"Years": "ساڵەکان",
|
|
225
|
+
"Translating to": "",
|
|
226
|
+
"Choose a locale": "",
|
|
227
|
+
"Base locale reference": "",
|
|
228
|
+
"Choose a locale to translate from the menu above": "",
|
|
229
|
+
"Translate: {{objectName}}": "",
|
|
230
|
+
"Save translations": "",
|
|
231
|
+
"Retry": "",
|
|
225
232
|
"Series": "",
|
|
226
233
|
"Category": "",
|
|
227
234
|
"Filter": "",
|
|
@@ -230,6 +230,13 @@
|
|
|
230
230
|
"Six-months": "Půlrok",
|
|
231
231
|
"Financial Years": "Finanční roky",
|
|
232
232
|
"Years": "Let",
|
|
233
|
+
"Translating to": "",
|
|
234
|
+
"Choose a locale": "",
|
|
235
|
+
"Base locale reference": "",
|
|
236
|
+
"Choose a locale to translate from the menu above": "",
|
|
237
|
+
"Translate: {{objectName}}": "",
|
|
238
|
+
"Save translations": "",
|
|
239
|
+
"Retry": "",
|
|
233
240
|
"Series": "Série",
|
|
234
241
|
"Category": "Kategorie",
|
|
235
242
|
"Filter": "Filtr",
|
|
@@ -222,6 +222,13 @@
|
|
|
222
222
|
"Six-months": "",
|
|
223
223
|
"Financial Years": "",
|
|
224
224
|
"Years": "",
|
|
225
|
+
"Translating to": "",
|
|
226
|
+
"Choose a locale": "",
|
|
227
|
+
"Base locale reference": "",
|
|
228
|
+
"Choose a locale to translate from the menu above": "",
|
|
229
|
+
"Translate: {{objectName}}": "",
|
|
230
|
+
"Save translations": "",
|
|
231
|
+
"Retry": "",
|
|
225
232
|
"Series": "",
|
|
226
233
|
"Category": "Category",
|
|
227
234
|
"Filter": "Filter",
|
|
@@ -222,6 +222,14 @@
|
|
|
222
222
|
"Six-months": "Six-months",
|
|
223
223
|
"Financial Years": "Financial Years",
|
|
224
224
|
"Years": "Years",
|
|
225
|
+
"Translating to": "Translating to",
|
|
226
|
+
"Choose a locale": "Choose a locale",
|
|
227
|
+
"Base locale reference": "Base locale reference",
|
|
228
|
+
"Choose a locale to translate from the menu above": "Choose a locale to translate from the menu above",
|
|
229
|
+
"Translate: {{objectName}}": "Translate: {{objectName}}",
|
|
230
|
+
"Save translations": "Save translations",
|
|
231
|
+
"Could not load translations": "Could not load translations",
|
|
232
|
+
"Retry": "Retry",
|
|
225
233
|
"Series": "Series",
|
|
226
234
|
"Category": "Category",
|
|
227
235
|
"Filter": "Filter",
|
|
@@ -222,6 +222,13 @@
|
|
|
222
222
|
"Six-months": "Semestres",
|
|
223
223
|
"Financial Years": "",
|
|
224
224
|
"Years": "Años",
|
|
225
|
+
"Translating to": "",
|
|
226
|
+
"Choose a locale": "",
|
|
227
|
+
"Base locale reference": "",
|
|
228
|
+
"Choose a locale to translate from the menu above": "",
|
|
229
|
+
"Translate: {{objectName}}": "",
|
|
230
|
+
"Save translations": "",
|
|
231
|
+
"Retry": "",
|
|
225
232
|
"Series": "",
|
|
226
233
|
"Category": "Categoría",
|
|
227
234
|
"Filter": "filtro",
|
|
@@ -222,6 +222,13 @@
|
|
|
222
222
|
"Six-months": "Semestres",
|
|
223
223
|
"Financial Years": "Années fiscales",
|
|
224
224
|
"Years": "Années",
|
|
225
|
+
"Translating to": "",
|
|
226
|
+
"Choose a locale": "",
|
|
227
|
+
"Base locale reference": "",
|
|
228
|
+
"Choose a locale to translate from the menu above": "",
|
|
229
|
+
"Translate: {{objectName}}": "",
|
|
230
|
+
"Save translations": "",
|
|
231
|
+
"Retry": "",
|
|
225
232
|
"Series": "Séries",
|
|
226
233
|
"Category": "Catégorie",
|
|
227
234
|
"Filter": "Filtrer",
|
|
@@ -218,6 +218,13 @@
|
|
|
218
218
|
"Six-months": "Semester",
|
|
219
219
|
"Financial Years": "Keuangan tahunan",
|
|
220
220
|
"Years": "Tahun",
|
|
221
|
+
"Translating to": "",
|
|
222
|
+
"Choose a locale": "",
|
|
223
|
+
"Base locale reference": "",
|
|
224
|
+
"Choose a locale to translate from the menu above": "",
|
|
225
|
+
"Translate: {{objectName}}": "",
|
|
226
|
+
"Save translations": "",
|
|
227
|
+
"Retry": "",
|
|
221
228
|
"Series": "Seri",
|
|
222
229
|
"Category": "Kategori",
|
|
223
230
|
"Filter": "Saring",
|
|
@@ -218,6 +218,13 @@
|
|
|
218
218
|
"Six-months": "",
|
|
219
219
|
"Financial Years": "",
|
|
220
220
|
"Years": "ឆ្នាំ",
|
|
221
|
+
"Translating to": "",
|
|
222
|
+
"Choose a locale": "",
|
|
223
|
+
"Base locale reference": "",
|
|
224
|
+
"Choose a locale to translate from the menu above": "",
|
|
225
|
+
"Translate: {{objectName}}": "",
|
|
226
|
+
"Save translations": "",
|
|
227
|
+
"Retry": "",
|
|
221
228
|
"Series": "",
|
|
222
229
|
"Category": "",
|
|
223
230
|
"Filter": "",
|