@dhis2/analytics 21.0.12 → 21.2.1
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 +149 -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/index.js +8 -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/cjs/modules/pivotTable/PivotTableEngine.js +4 -3
- 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 +126 -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/index.js +3 -1
- 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/build/es/modules/pivotTable/PivotTableEngine.js +4 -3
- package/package.json +1 -1
|
@@ -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": "",
|
|
@@ -218,6 +218,13 @@
|
|
|
218
218
|
"Six-months": "6 ເດືອນ",
|
|
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": "Filter",
|
|
@@ -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": "category",
|
|
223
230
|
"Filter": "ရှာဖွေထုတ်သည်",
|
|
@@ -222,6 +222,13 @@
|
|
|
222
222
|
"Six-months": "Halvår",
|
|
223
223
|
"Financial Years": "Regnskapsår",
|
|
224
224
|
"Years": "År",
|
|
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": "Serie",
|
|
226
233
|
"Category": "Kategori",
|
|
227
234
|
"Filter": "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": "",
|
|
@@ -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": "فلتر",
|
|
@@ -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": "فیلټر",
|
|
@@ -222,6 +222,13 @@
|
|
|
222
222
|
"Six-months": "Seis meses",
|
|
223
223
|
"Financial Years": "Ano financeiro ",
|
|
224
224
|
"Years": "Anos",
|
|
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érie",
|
|
226
233
|
"Category": "Categoria",
|
|
227
234
|
"Filter": "Filtro",
|
|
@@ -222,6 +222,13 @@
|
|
|
222
222
|
"Six-months": "",
|
|
223
223
|
"Financial Years": "",
|
|
224
224
|
"Years": "Anos",
|
|
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érie",
|
|
226
233
|
"Category": "Categoria",
|
|
227
234
|
"Filter": "Filtro",
|
|
@@ -230,6 +230,13 @@
|
|
|
230
230
|
"Six-months": "Полугодие",
|
|
231
231
|
"Financial Years": "Финансовые годы",
|
|
232
232
|
"Years": "Годы",
|
|
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": "Ряды",
|
|
234
241
|
"Category": "Категория",
|
|
235
242
|
"Filter": "Фильтр",
|
|
@@ -222,6 +222,13 @@
|
|
|
222
222
|
"Six-months": "",
|
|
223
223
|
"Financial Years": "",
|
|
224
224
|
"Years": "År",
|
|
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": "Filtrera",
|
|
@@ -218,6 +218,13 @@
|
|
|
218
218
|
"Six-months": "Fulan-nén",
|
|
219
219
|
"Financial Years": "",
|
|
220
220
|
"Years": "Tinan",
|
|
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": "Séries",
|
|
222
229
|
"Category": "Kategoria",
|
|
223
230
|
"Filter": "Filtru",
|
|
@@ -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": "Півріччя",
|
|
231
231
|
"Financial Years": "",
|
|
232
232
|
"Years": "Роки",
|
|
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": "",
|
|
234
241
|
"Category": "Категорія",
|
|
235
242
|
"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": "فلٹر",
|
|
@@ -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": "Фильтр",
|
|
@@ -218,6 +218,13 @@
|
|
|
218
218
|
"Six-months": "Yarim yillik",
|
|
219
219
|
"Financial Years": "Moliyaviy yillar",
|
|
220
220
|
"Years": "Yillar",
|
|
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": "Ketma-ketliklar",
|
|
222
229
|
"Category": "Kategoriya",
|
|
223
230
|
"Filter": "Filtr",
|
|
@@ -218,6 +218,13 @@
|
|
|
218
218
|
"Six-months": "Sáu-tháng",
|
|
219
219
|
"Financial Years": "Năm tài chính",
|
|
220
220
|
"Years": "Năm",
|
|
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": "Chuỗi Dữ Liệu",
|
|
222
229
|
"Category": "Phân loại",
|
|
223
230
|
"Filter": "Lọc",
|
|
@@ -218,6 +218,13 @@
|
|
|
218
218
|
"Six-months": "Six-months",
|
|
219
219
|
"Financial Years": "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": "过滤器",
|
|
@@ -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": "过滤器",
|
|
@@ -226,6 +226,7 @@ class PivotTableEngine {
|
|
|
226
226
|
return sets;
|
|
227
227
|
}, {});
|
|
228
228
|
this.rawData = data;
|
|
229
|
+
this.dimensionLookup = buildDimensionLookup(this.visualization, this.rawData.metaData, this.rawData.headers);
|
|
229
230
|
this.options = { ...defaultOptions,
|
|
230
231
|
showColumnTotals: visualization.colTotals,
|
|
231
232
|
showRowTotals: visualization.rowTotals,
|
|
@@ -235,10 +236,10 @@ class PivotTableEngine {
|
|
|
235
236
|
hideEmptyRows: visualization.hideEmptyRows,
|
|
236
237
|
title: visualization.hideTitle ? undefined : visualization.title,
|
|
237
238
|
subtitle: visualization.hideSubtitle ? undefined : visualization.subtitle,
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
// turn on fixed headers only when there are dimensions
|
|
240
|
+
fixColumnHeaders: this.dimensionLookup.columns.length ? visualization.fixColumnHeaders : false,
|
|
241
|
+
fixRowHeaders: this.dimensionLookup.rows.length ? visualization.fixRowHeaders : false
|
|
240
242
|
};
|
|
241
|
-
this.dimensionLookup = buildDimensionLookup(this.visualization, this.rawData.metaData, this.rawData.headers);
|
|
242
243
|
this.adaptiveClippingController = new _AdaptiveClippingController.AdaptiveClippingController(this);
|
|
243
244
|
const doColumnSubtotals = this.options.showColumnSubtotals && this.dimensionLookup.rows.length > 1;
|
|
244
245
|
const singularRow = this.dimensionLookup.rows.length === 1 && this.dimensionLookup.rows[0].count === 1;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
import TranslationDialog from '@dhis2/d2-ui-translation-dialog';
|
|
3
2
|
import { IconAdd24, IconLaunch24, IconSave24, IconEdit24, IconTranslate24, IconShare24, IconLink24, IconDelete24, SharingDialog, colors, FlyoutMenu, Layer, MenuItem, MenuDivider, Popper } from '@dhis2/ui';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
import React, { createRef, useState } from 'react';
|
|
6
5
|
import i18n from '../../locales/index.js';
|
|
7
6
|
import { OpenFileDialog } from '../OpenFileDialog/OpenFileDialog.js';
|
|
7
|
+
import { TranslationDialog } from '../TranslationDialog/index.js';
|
|
8
8
|
import { DeleteDialog } from './DeleteDialog.js';
|
|
9
9
|
import { fileMenuStyles } from './FileMenu.styles.js';
|
|
10
10
|
import { GetLinkDialog } from './GetLinkDialog.js';
|
|
@@ -70,20 +70,10 @@ export const FileMenu = ({
|
|
|
70
70
|
|
|
71
71
|
case 'translate':
|
|
72
72
|
return /*#__PURE__*/React.createElement(TranslationDialog, {
|
|
73
|
-
|
|
74
|
-
d2: d2,
|
|
75
|
-
objectToTranslate: { ...fileObject,
|
|
76
|
-
// mock modelDefinition to avoid an error
|
|
77
|
-
// in the TranslationDialog component
|
|
78
|
-
modelDefinition: {
|
|
79
|
-
name: fileType
|
|
80
|
-
}
|
|
81
|
-
},
|
|
73
|
+
objectToTranslate: fileObject,
|
|
82
74
|
fieldsToTranslate: ['name', 'description'],
|
|
83
|
-
|
|
84
|
-
onTranslationSaved: onTranslate
|
|
85
|
-
onTranslationError: onError,
|
|
86
|
-
insertTheme: true
|
|
75
|
+
onClose: onDialogClose,
|
|
76
|
+
onTranslationSaved: onTranslate
|
|
87
77
|
});
|
|
88
78
|
|
|
89
79
|
case 'sharing':
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import TranslationDialog from '@dhis2/d2-ui-translation-dialog';
|
|
2
1
|
import { SharingDialog } from '@dhis2/ui';
|
|
3
2
|
import { shallow } from 'enzyme';
|
|
4
3
|
import React from 'react';
|
|
5
4
|
import { OpenFileDialog } from '../../OpenFileDialog/OpenFileDialog.js';
|
|
5
|
+
import { TranslationDialog } from '../../TranslationDialog/index.js';
|
|
6
6
|
import { DeleteDialog } from '../DeleteDialog.js';
|
|
7
7
|
import { FileMenu } from '../FileMenu.js';
|
|
8
8
|
import { GetLinkDialog } from '../GetLinkDialog.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useDataQuery } from '@dhis2/app-runtime';
|
|
2
|
+
import i18n from '@dhis2/d2-i18n';
|
|
3
|
+
import { SingleSelect, SingleSelectOption } from '@dhis2/ui';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
const query = {
|
|
7
|
+
locales: {
|
|
8
|
+
resource: 'locales/db'
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export const LocalesSelect = ({
|
|
12
|
+
onChange,
|
|
13
|
+
selected
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
data,
|
|
17
|
+
fetching
|
|
18
|
+
} = useDataQuery(query);
|
|
19
|
+
return /*#__PURE__*/React.createElement(SingleSelect, {
|
|
20
|
+
prefix: selected ? i18n.t('Translating to') : i18n.t('Choose a locale'),
|
|
21
|
+
onChange: ({
|
|
22
|
+
selected
|
|
23
|
+
}) => onChange(selected),
|
|
24
|
+
loading: fetching,
|
|
25
|
+
selected: data ? selected : undefined,
|
|
26
|
+
dense: true
|
|
27
|
+
}, data && data.locales // XXX remove duplicates ?! fr_SN - French (Senegal)
|
|
28
|
+
.reduce((locales, {
|
|
29
|
+
locale,
|
|
30
|
+
name
|
|
31
|
+
}) => {
|
|
32
|
+
if (!locales.find(entry => entry.locale === locale)) {
|
|
33
|
+
locales.push({
|
|
34
|
+
locale,
|
|
35
|
+
name
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return locales;
|
|
40
|
+
}, []).map(({
|
|
41
|
+
locale,
|
|
42
|
+
name
|
|
43
|
+
}) => /*#__PURE__*/React.createElement(SingleSelectOption, {
|
|
44
|
+
key: locale,
|
|
45
|
+
value: locale,
|
|
46
|
+
label: name
|
|
47
|
+
})));
|
|
48
|
+
};
|
|
49
|
+
LocalesSelect.propTypes = {
|
|
50
|
+
onChange: PropTypes.func.isRequired,
|
|
51
|
+
selected: PropTypes.string
|
|
52
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useAlert, useDataMutation } from '@dhis2/app-runtime';
|
|
2
|
+
import i18n from '@dhis2/d2-i18n';
|
|
3
|
+
import { CenteredContent, DataTable, DataTableBody, DataTableCell, DataTableColumnHeader, DataTableHead, DataTableRow, InputField, ModalContent } from '@dhis2/ui';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { LocalesSelect } from './LocalesSelect.js';
|
|
7
|
+
import { TranslationModalActions } from './TranslationModalActions.js';
|
|
8
|
+
const SESSION_STORAGE_TRANSLATION_LOCALE_KEY = 'translation-dialog-selected-locale';
|
|
9
|
+
export const TranslationForm = ({
|
|
10
|
+
fieldsToTranslate,
|
|
11
|
+
objectToTranslate,
|
|
12
|
+
translations,
|
|
13
|
+
resource,
|
|
14
|
+
onTranslationSaved,
|
|
15
|
+
onClose
|
|
16
|
+
}) => {
|
|
17
|
+
const [newTranslations, setNewTranslations] = useState();
|
|
18
|
+
const [translationLocale, setTranslationLocale] = useState();
|
|
19
|
+
const {
|
|
20
|
+
show: showError
|
|
21
|
+
} = useAlert(error => error, {
|
|
22
|
+
critical: true
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const formatFieldLabel = field => {
|
|
26
|
+
field.replace(/[a-z][A-Z]/g, match => [match.charAt(0), match.charAt(1)].join(' ')).toLowerCase();
|
|
27
|
+
return field.charAt(0).toUpperCase() + field.slice(1);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const camelCaseToUnderscores = field => field.replace(/[a-z][A-Z]/g, match => [match.charAt(0), match.charAt(1)].join('_')).toLowerCase();
|
|
31
|
+
|
|
32
|
+
const getTranslationIndexForField = field => newTranslations.findIndex(element => element.locale === translationLocale && element.property.toLowerCase() === camelCaseToUnderscores(field));
|
|
33
|
+
|
|
34
|
+
const getTranslationForField = field => {
|
|
35
|
+
var _newTranslations$tran;
|
|
36
|
+
|
|
37
|
+
const translationIndex = getTranslationIndexForField(field);
|
|
38
|
+
return translationIndex !== -1 ? ((_newTranslations$tran = newTranslations[translationIndex]) === null || _newTranslations$tran === void 0 ? void 0 : _newTranslations$tran.value) || '' : '';
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const setTranslationForField = (field, translation) => {
|
|
42
|
+
const newTranslation = {
|
|
43
|
+
locale: translationLocale,
|
|
44
|
+
property: camelCaseToUnderscores(field).toUpperCase(),
|
|
45
|
+
value: translation
|
|
46
|
+
};
|
|
47
|
+
const translationIndex = getTranslationIndexForField(field);
|
|
48
|
+
setNewTranslations(translationIndex === -1 ? [...newTranslations, newTranslation] : newTranslations.map((translation, index) => index === translationIndex ? newTranslation : translation));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const translationsMutationRef = useRef({
|
|
52
|
+
resource: "".concat(resource, "/translations"),
|
|
53
|
+
type: 'update',
|
|
54
|
+
data: ({
|
|
55
|
+
translations
|
|
56
|
+
}) => ({
|
|
57
|
+
translations
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
const [saveTranslations, {
|
|
61
|
+
loading: saveInProgress
|
|
62
|
+
}] = useDataMutation(translationsMutationRef.current, {
|
|
63
|
+
onComplete: () => {
|
|
64
|
+
onTranslationSaved();
|
|
65
|
+
onClose();
|
|
66
|
+
},
|
|
67
|
+
onError: error => {
|
|
68
|
+
showError(error);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const onLocaleChange = locale => {
|
|
73
|
+
setTranslationLocale(locale);
|
|
74
|
+
window.sessionStorage.setItem(SESSION_STORAGE_TRANSLATION_LOCALE_KEY, locale);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const save = () => saveTranslations({
|
|
78
|
+
translations: newTranslations
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
useEffect(() => setTranslationLocale(window.sessionStorage.getItem(SESSION_STORAGE_TRANSLATION_LOCALE_KEY)), []);
|
|
82
|
+
useEffect(() => setNewTranslations(translations), [translations]);
|
|
83
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalContent, null, /*#__PURE__*/React.createElement(DataTable, {
|
|
84
|
+
layout: "fixed"
|
|
85
|
+
}, /*#__PURE__*/React.createElement(DataTableHead, null, /*#__PURE__*/React.createElement(DataTableRow, null, /*#__PURE__*/React.createElement(DataTableColumnHeader, {
|
|
86
|
+
fixed: true,
|
|
87
|
+
top: "0"
|
|
88
|
+
}, i18n.t('Base locale reference')), /*#__PURE__*/React.createElement(DataTableColumnHeader, {
|
|
89
|
+
fixed: true,
|
|
90
|
+
top: "0"
|
|
91
|
+
}, /*#__PURE__*/React.createElement(LocalesSelect, {
|
|
92
|
+
selected: translationLocale,
|
|
93
|
+
onChange: onLocaleChange
|
|
94
|
+
})))), /*#__PURE__*/React.createElement(DataTableBody, null, fieldsToTranslate.map((field, index) => /*#__PURE__*/React.createElement(DataTableRow, {
|
|
95
|
+
key: field
|
|
96
|
+
}, /*#__PURE__*/React.createElement(DataTableCell, null, /*#__PURE__*/React.createElement("div", {
|
|
97
|
+
className: ""
|
|
98
|
+
}, /*#__PURE__*/React.createElement(InputField, {
|
|
99
|
+
label: formatFieldLabel(field),
|
|
100
|
+
value: objectToTranslate[field],
|
|
101
|
+
readOnly: true
|
|
102
|
+
}))), translationLocale && /*#__PURE__*/React.createElement(DataTableCell, null, /*#__PURE__*/React.createElement("div", {
|
|
103
|
+
className: ""
|
|
104
|
+
}, /*#__PURE__*/React.createElement(InputField, {
|
|
105
|
+
label: formatFieldLabel(field),
|
|
106
|
+
value: getTranslationForField(field),
|
|
107
|
+
onChange: ({
|
|
108
|
+
value
|
|
109
|
+
}) => setTranslationForField(field, value)
|
|
110
|
+
}))), !translationLocale && index === 0 && /*#__PURE__*/React.createElement(DataTableCell, {
|
|
111
|
+
rowSpan: String(fieldsToTranslate.length)
|
|
112
|
+
}, /*#__PURE__*/React.createElement(CenteredContent, null, i18n.t('Choose a locale to translate from the menu above')))))))), /*#__PURE__*/React.createElement(TranslationModalActions, {
|
|
113
|
+
onClose: onClose,
|
|
114
|
+
onSave: save,
|
|
115
|
+
saveInProgress: saveInProgress,
|
|
116
|
+
saveButtonDisabled: !translationLocale
|
|
117
|
+
}));
|
|
118
|
+
};
|
|
119
|
+
TranslationForm.propTypes = {
|
|
120
|
+
fieldsToTranslate: PropTypes.array.isRequired,
|
|
121
|
+
objectToTranslate: PropTypes.object.isRequired,
|
|
122
|
+
resource: PropTypes.string.isRequired,
|
|
123
|
+
translations: PropTypes.array.isRequired,
|
|
124
|
+
onClose: PropTypes.func.isRequired,
|
|
125
|
+
onTranslationSaved: PropTypes.func.isRequired
|
|
126
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import i18n from '@dhis2/d2-i18n';
|
|
2
|
+
import { CenteredContent, CircularLoader, Modal, ModalContent, ModalTitle } from '@dhis2/ui';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import { TranslationForm } from './TranslationForm.js';
|
|
6
|
+
import { TranslationModalActions } from './TranslationModalActions.js';
|
|
7
|
+
import { useTranslationsResults } from './useTranslationsResults.js';
|
|
8
|
+
export const TranslationModal = ({
|
|
9
|
+
objectToTranslate,
|
|
10
|
+
fieldsToTranslate,
|
|
11
|
+
onClose,
|
|
12
|
+
onTranslationSaved
|
|
13
|
+
}) => {
|
|
14
|
+
const [translations, setTranslations] = useState([]);
|
|
15
|
+
const endpointPath = new URL(objectToTranslate.href).pathname;
|
|
16
|
+
const endpointPathMatch = endpointPath.match(/api\/\d+\/(?<resource>.+)/);
|
|
17
|
+
const resource = endpointPathMatch !== null && endpointPathMatch !== void 0 && endpointPathMatch.groups ? endpointPathMatch.groups.resource : null;
|
|
18
|
+
const {
|
|
19
|
+
translationsData,
|
|
20
|
+
fetching
|
|
21
|
+
} = useTranslationsResults({
|
|
22
|
+
resource
|
|
23
|
+
});
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (translationsData) {
|
|
26
|
+
setTranslations(translationsData);
|
|
27
|
+
}
|
|
28
|
+
}, [translationsData]);
|
|
29
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
30
|
+
large: true,
|
|
31
|
+
position: "middle",
|
|
32
|
+
onClose: onClose
|
|
33
|
+
}, /*#__PURE__*/React.createElement(ModalTitle, null, i18n.t('Translate: {{objectName}}', {
|
|
34
|
+
objectName: objectToTranslate.name || 'TEXT',
|
|
35
|
+
// XXX
|
|
36
|
+
nsSeparator: '^^'
|
|
37
|
+
})), fetching ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalContent, null, /*#__PURE__*/React.createElement(CenteredContent, null, /*#__PURE__*/React.createElement(CircularLoader, null))), /*#__PURE__*/React.createElement(TranslationModalActions, {
|
|
38
|
+
onClose: onClose,
|
|
39
|
+
saveButtonDisabled: true
|
|
40
|
+
})) : /*#__PURE__*/React.createElement(TranslationForm, {
|
|
41
|
+
fieldsToTranslate: fieldsToTranslate,
|
|
42
|
+
objectToTranslate: objectToTranslate,
|
|
43
|
+
translations: translations,
|
|
44
|
+
onTranslationSaved: onTranslationSaved,
|
|
45
|
+
resource: resource,
|
|
46
|
+
onClose: onClose
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
TranslationModal.propTypes = {
|
|
50
|
+
fieldsToTranslate: PropTypes.array.isRequired,
|
|
51
|
+
objectToTranslate: PropTypes.object.isRequired,
|
|
52
|
+
onClose: PropTypes.func.isRequired,
|
|
53
|
+
onTranslationSaved: PropTypes.func.isRequired
|
|
54
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import i18n from '@dhis2/d2-i18n';
|
|
2
|
+
import { Button, ButtonStrip, ModalActions } from '@dhis2/ui';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export const TranslationModalActions = ({
|
|
6
|
+
onClose,
|
|
7
|
+
onSave,
|
|
8
|
+
saveInProgress,
|
|
9
|
+
saveButtonDisabled
|
|
10
|
+
}) => /*#__PURE__*/React.createElement(ModalActions, null, /*#__PURE__*/React.createElement(ButtonStrip, null, /*#__PURE__*/React.createElement(Button, {
|
|
11
|
+
secondary: true,
|
|
12
|
+
onClick: onClose
|
|
13
|
+
}, i18n.t('Cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
14
|
+
primary: true,
|
|
15
|
+
onClick: onSave,
|
|
16
|
+
loading: saveInProgress,
|
|
17
|
+
disabled: saveButtonDisabled
|
|
18
|
+
}, i18n.t('Save translations'))));
|
|
19
|
+
TranslationModalActions.propTypes = {
|
|
20
|
+
onClose: PropTypes.func.isRequired,
|
|
21
|
+
saveButtonDisabled: PropTypes.bool,
|
|
22
|
+
saveInProgress: PropTypes.bool,
|
|
23
|
+
onSave: PropTypes.func
|
|
24
|
+
};
|