Skip to content

Commit

Permalink
data import templates: allow downloading only after cycle selection (#…
Browse files Browse the repository at this point in the history
…3072)

* data import templates: allow downloading only after cycle selection

* change exported file name

---------

Co-authored-by: Stefano Ricci <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 13, 2023
1 parent a35d13f commit 72b59ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions server/modules/dataImport/service/dataImportTemplateService.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ const exportDataImportTemplate = async ({ surveyId, cycle, entityDefUuid, res })
}

const exportAllDataImportTemplates = async ({ surveyId, cycle, res }) => {
const survey = await SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId, cycle })

const archiver = new ZipArchiver(res)

setContentTypeFile({
res,
fileName: `data_import_templates.zip`,
fileName: `data_import_templates_${Survey.getName(survey)}.zip`,
contentType: contentTypes.zip,
})

const archiver = new ZipArchiver(res)

const survey = await SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId, cycle })

const multipleEntityDefUuids = []

Survey.traverseMultipleEntityDefs((nodeDef) => {
Expand Down
12 changes: 7 additions & 5 deletions webapp/views/App/views/Data/DataImport/DataImportCsvView.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ export const DataImportCsvView = () => {
)}
</div>
<div className="buttons-container">
<ButtonDownload
className="download-templates-btn"
href={API.getDataImportFromCsvTemplatesUrl({ surveyId, cycle })}
label="dataImportView.downloadAllTemplates"
/>
{!Objects.isEmpty(cycle) && (
<ButtonDownload
className="download-templates-btn"
href={API.getDataImportFromCsvTemplatesUrl({ surveyId, cycle })}
label="dataImportView.downloadAllTemplates"
/>
)}
{selectedEntityDefUuid && (
<>
<ButtonDownload
Expand Down

0 comments on commit 72b59ab

Please sign in to comment.