Skip to content

Commit

Permalink
Merge pull request #276 from EyeSeeTea/change-wording-for-select-impo…
Browse files Browse the repository at this point in the history
…rt-ou

fix data model filter removing ou selection and populate with data checkbox
  • Loading branch information
ifoche authored Oct 12, 2022
2 parents e6d7414 + 694c9c0 commit 50b6d3a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 19 deletions.
6 changes: 3 additions & 3 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions i18n/es.po
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions i18n/fr.po
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions i18n/pt.po
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions i18n/ru.po
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down
23 changes: 18 additions & 5 deletions src/webapp/components/template-selector/TemplateSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) => {
Expand Down
10 changes: 8 additions & 2 deletions src/webapp/pages/download-template/DownloadTemplatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -13,9 +17,10 @@ export default function DownloadTemplatePage({ settings, themes, customTemplates
const { api, compositionRoot } = useAppContext();

const [template, setTemplate] = useState<TemplateSelectorState | null>(null);
const [availableModels, setAvailableModels] = useState<DataModelProps[]>([]);

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;
}
Expand Down Expand Up @@ -69,6 +74,7 @@ export default function DownloadTemplatePage({ settings, themes, customTemplates
return (
<React.Fragment>
<TemplateSelector
onChangeModel={setAvailableModels}
settings={settings}
themes={themes}
onChange={setTemplate}
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/pages/import-template/ImportTemplatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export default function ImportTemplatePage({ settings }: RouteComponentProps) {
<FormControlLabel
style={{ marginTop: "1em" }}
control={<Checkbox checked={overwriteOrgUnits} onChange={onOverwriteOrgUnitsChange} />}
label={i18n.t("Select import Organisation Unit")}
label={i18n.t("Override import Organisation Unit")}
/>
</div>
)}
Expand Down

0 comments on commit 50b6d3a

Please sign in to comment.