diff --git a/i18n/en.pot b/i18n/en.pot index 946cdb86..4d4d3975 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2022-09-23T11:44:46.069Z\n" -"PO-Revision-Date: 2022-09-23T11:44:46.069Z\n" +"POT-Creation-Date: 2022-09-08T10:43:07.553Z\n" +"PO-Revision-Date: 2022-09-08T10:43:07.553Z\n" msgid "Data values - Create/update" msgstr "" @@ -999,7 +999,7 @@ msgstr "" msgid "data values" msgstr "" -msgid "Select import Organisation Unit" +msgid "Override import Organisation Unit" msgstr "" msgid "No capture org unit match element org units" diff --git a/i18n/es.po b/i18n/es.po index 2da56210..e8b0ef2c 100644 --- a/i18n/es.po +++ b/i18n/es.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Bulk Load\n" -"POT-Creation-Date: 2022-09-23T11:44:46.069Z\n" +"POT-Creation-Date: 2022-09-08T10:43:07.553Z\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1043,7 +1043,7 @@ msgstr "Actualizar" msgid "data values" msgstr "valores de datos" -msgid "Select import Organisation Unit" +msgid "Override import Organisation Unit" msgstr "Seleccione una unidad organizativa en la que importar los datos" msgid "No capture org unit match element org units" diff --git a/i18n/fr.po b/i18n/fr.po index 31afafea..c25da6cc 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Bulk Load App\n" -"POT-Creation-Date: 2022-09-23T11:44:46.069Z\n" +"POT-Creation-Date: 2022-09-08T10:43:07.553Z\n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1066,7 +1066,7 @@ msgstr "Mettre à jour" msgid "data values" msgstr "valeurs de données" -msgid "Select import Organisation Unit" +msgid "Override import Organisation Unit" msgstr "Sélectionnez l'unité d'organisation d'importation" msgid "No capture org unit match element org units" diff --git a/i18n/pt.po b/i18n/pt.po index 96dd3323..3a8b646f 100644 --- a/i18n/pt.po +++ b/i18n/pt.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Bulk Load\n" -"POT-Creation-Date: 2022-09-23T11:44:46.069Z\n" +"POT-Creation-Date: 2022-09-08T10:43:07.553Z\n" "Language: pt\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1100,7 +1100,7 @@ msgstr "Atualizar" msgid "data values" msgstr "valores de dados" -msgid "Select import Organisation Unit" +msgid "Override import Organisation Unit" msgstr "Selecione a unidade organizacional para importar os dados" msgid "No capture org unit match element org units" diff --git a/i18n/ru.po b/i18n/ru.po index 712854fe..3a16b162 100644 --- a/i18n/ru.po +++ b/i18n/ru.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Bulk Load\n" -"POT-Creation-Date: 2022-09-23T11:44:46.069Z\n" +"POT-Creation-Date: 2022-09-08T10:43:07.553Z\n" "Language: ru\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1104,7 +1104,7 @@ msgstr "Обновление" msgid "data values" msgstr "значения данных" -msgid "Select import Organisation Unit" +msgid "Override import Organisation Unit" msgstr "Выберите импортируемое организационное подразделение" msgid "No capture org unit match element org units" diff --git a/src/webapp/components/template-selector/TemplateSelector.tsx b/src/webapp/components/template-selector/TemplateSelector.tsx index 12706c05..48c968bb 100644 --- a/src/webapp/components/template-selector/TemplateSelector.tsx +++ b/src/webapp/components/template-selector/TemplateSelector.tsx @@ -29,14 +29,26 @@ export interface TemplateSelectorState extends DownloadTemplateProps { templateType?: TemplateType; } +export interface DataModelProps { + value: string; + label: string; +} + export interface TemplateSelectorProps { settings: Settings; themes: Theme[]; onChange(state: TemplateSelectorState | null): void; + onChangeModel(state: DataModelProps[]): void; customTemplates: CustomTemplate[]; } -export const TemplateSelector = ({ settings, themes, onChange, customTemplates }: TemplateSelectorProps) => { +export const TemplateSelector = ({ + settings, + themes, + onChange, + onChangeModel, + customTemplates, +}: TemplateSelectorProps) => { const classes = useStyles(); const { api, compositionRoot } = useAppContext(); @@ -99,6 +111,10 @@ export const TemplateSelector = ({ settings, themes, onChange, customTemplates } }); }, [models, compositionRoot, customTemplates, settings]); + useEffect(() => { + onChangeModel(templates); + }, [onChangeModel, templates]); + useEffect(() => { const { type, id } = state; if (type && id) { @@ -135,12 +151,9 @@ export const TemplateSelector = ({ settings, themes, onChange, customTemplates } const options = modelToSelectOption(dataSource[value] ?? []); setSelectedModel(value); - setState(state => ({ ...state, type: undefined, id: undefined, populate: false })); clearPopulateDates(); setTemplates(options); - setSelectedOrgUnits([]); - setOrgUnitTreeFilter([]); - setUserHasReadAccess(false); + onChangeModel(templates); }; const onTemplateChange = ({ value }: SelectOption) => { diff --git a/src/webapp/pages/download-template/DownloadTemplatePage.tsx b/src/webapp/pages/download-template/DownloadTemplatePage.tsx index e8e7ef99..46375651 100644 --- a/src/webapp/pages/download-template/DownloadTemplatePage.tsx +++ b/src/webapp/pages/download-template/DownloadTemplatePage.tsx @@ -2,7 +2,11 @@ import { useLoading, useSnackbar } from "@eyeseetea/d2-ui-components"; import { Button, makeStyles } from "@material-ui/core"; import React, { useState } from "react"; import i18n from "../../../locales"; -import { TemplateSelector, TemplateSelectorState } from "../../components/template-selector/TemplateSelector"; +import { + DataModelProps, + TemplateSelector, + TemplateSelectorState, +} from "../../components/template-selector/TemplateSelector"; import { useAppContext } from "../../contexts/app-context"; import { RouteComponentProps } from "../Router"; @@ -13,9 +17,10 @@ export default function DownloadTemplatePage({ settings, themes, customTemplates const { api, compositionRoot } = useAppContext(); const [template, setTemplate] = useState(null); + const [availableModels, setAvailableModels] = useState([]); const handleTemplateDownloadClick = async () => { - if (!template) { + if (!template || availableModels.filter(availableModel => template?.id === availableModel.value).length === 0) { snackbar.info(i18n.t("You need to select at least one element to export")); return; } @@ -69,6 +74,7 @@ export default function DownloadTemplatePage({ settings, themes, customTemplates return ( } - label={i18n.t("Select import Organisation Unit")} + label={i18n.t("Override import Organisation Unit")} /> )}