Skip to content

Commit

Permalink
[Enhancement kbss-cvut#581] Use separate template file for term trans…
Browse files Browse the repository at this point in the history
…lations import.

Improve user information for translation import.
  • Loading branch information
ledsoft committed Dec 2, 2024
1 parent bba7c1f commit f8d89c2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/action/AsyncImportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,16 @@ const processError =
);
};

export function downloadExcelTemplate() {
export function downloadExcelTemplate(translationsOnly: boolean = false) {
return (dispatch: ThunkDispatch) => {
const action = { type: ActionType.LOAD_EXCEL_TEMPLATE };
dispatch(asyncActionRequest(action, true));
return Ajax.getRaw(
`${Constants.API_PREFIX}/vocabularies/import/template`,
responseType("arraybuffer")
responseType("arraybuffer").param(
"translationsOnly",
translationsOnly.toString()
)
)
.then((response) => {
Utils.fileDownload(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import UploadFile from "../../resource/file/UploadFile";
import { Button, ButtonToolbar, Col, Form, Row } from "reactstrap";
import { Alert, Button, ButtonToolbar, Col, Form, Row } from "reactstrap";
import { useI18n } from "../../hook/useI18n";
import { FormattedMessage } from "react-intl";

Expand Down Expand Up @@ -34,6 +34,9 @@ export const ImportTranslationsDialog: React.FC<{
}}
/>
</div>
<Alert color="info">
<FormattedMessage id="vocabulary.summary.import.translations.help" />
</Alert>
<UploadFile setFile={setFile} />
<Row>
<Col xs={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export const LoadVocabularyFromFile: React.FC<LoadVocabularyFromFileProps> = ({
const downloadTemplate = () => {
dispatch(downloadExcelTemplate());
};
const downloadTranslationsTemplate = () => {
dispatch(downloadExcelTemplate(true));
};
const vocabularyNotEmpty =
(useSelector((state: TermItState) => state.vocabulary.termCount) || 0) > 0;

Expand Down Expand Up @@ -101,7 +104,7 @@ export const LoadVocabularyFromFile: React.FC<LoadVocabularyFromFileProps> = ({
<ImportTranslationsDialog
onSubmit={onImportTranslations}
onCancel={onClose}
onDownloadTemplate={downloadTemplate}
onDownloadTemplate={downloadTranslationsTemplate}
/>
),
}}
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ const cs = {
"Slovník není prázdný, stávající data budou přepsána importovanými.",
"vocabulary.summary.import.translations.label":
"Nahrajte soubor ve formátu MS Excel odpovídající <a>této šabloně</a>, ze kterého mají být naimportovány překlady existujících pojmů ve slovníku.",
"vocabulary.summary.import.translations.help":
"Stávající data nebudou přepsána.",
"vocabulary.import.type.skos": "SKOS",
"vocabulary.import.type.excel": "MS Excel",
"vocabulary.import.action": "Importovat",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ const en = {
"Vocabulary is not empty, existing data will be overwritten by the imported.",
"vocabulary.summary.import.translations.label":
"Upload an MS Excel file corresponding to <a>this template</a> from which translations of existing terms in this vocabulary will be imported.",
"vocabulary.summary.import.translations.help":
"Existing data will not be changed.",
"vocabulary.import.type.skos": "SKOS",
"vocabulary.import.type.excel": "MS Excel",
"vocabulary.import.action": "Import",
Expand Down

0 comments on commit f8d89c2

Please sign in to comment.