From 18154da4c55a5d921efccdb072ea9b6a310765a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilia=20M=C3=A4kel=C3=A4?= Date: Tue, 5 Sep 2023 15:46:00 +0300 Subject: [PATCH] Add PDF capability to area search export --- .../AreaSearchApplicationListPage.js | 2 + .../components/AreaSearchExportModal.js | 81 +++++++++++++++++-- .../components/_area-search-export-modal.scss | 6 ++ src/main.scss | 5 +- 4 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 src/areaSearch/components/_area-search-export-modal.scss diff --git a/src/areaSearch/components/AreaSearchApplicationListPage.js b/src/areaSearch/components/AreaSearchApplicationListPage.js index 7786800da..426a6ddd3 100644 --- a/src/areaSearch/components/AreaSearchApplicationListPage.js +++ b/src/areaSearch/components/AreaSearchApplicationListPage.js @@ -815,6 +815,8 @@ export default (flowRight( initialValues: { mode: null, selectedSearches: {}, + includeInformationChecks: false, + includeAttachments: false, }, }) )(AreaSearchApplicationListPage): React$ComponentType); diff --git a/src/areaSearch/components/AreaSearchExportModal.js b/src/areaSearch/components/AreaSearchExportModal.js index 82913be0c..12bddd47a 100644 --- a/src/areaSearch/components/AreaSearchExportModal.js +++ b/src/areaSearch/components/AreaSearchExportModal.js @@ -25,6 +25,8 @@ type Props = { change: Function, selectedMode: ?string, selectedSearches: {[key: string]: boolean}, + includeInformationChecks: boolean, + includeAttachments: boolean, }; export const ExportModes = { @@ -39,11 +41,20 @@ class AreaSearchExportModal extends Component { if (isOpen && !prevProps.isOpen) { change('mode', null); + change('includePreparerInformation', false); + change('includeAttachments', false); } } render(): React$Node { - const {isOpen, onClose, selectedMode, selectedSearches} = this.props; + const { + isOpen, + onClose, + selectedMode, + selectedSearches, + includeInformationChecks, + includeAttachments, + } = this.props; const selectedSearchIds = Object.keys(selectedSearches).reduce((acc, key) => { if (selectedSearches[key]) { @@ -58,11 +69,24 @@ class AreaSearchExportModal extends Component { switch (selectedMode) { case ExportModes.APPLICATIONS_PDF: guideText = 'Tulostus sisältää valitut hakemukset .pdf-muodossa.'; - downloadUrl = createUrl(`area_search/get_answers_pdf/?ids=${selectedSearchIds.join(',')}`); + + const params: {[key: string]: string} = { + ids: selectedSearchIds.join(','), + }; + if (includeInformationChecks) { + params.show_information_check = '1'; + } + if (includeAttachments) { + params.show_attachments = '1'; + } + + downloadUrl = createUrl('area_search_pdf/', params); break; case ExportModes.APPLICATIONS_XLS: guideText = 'Tulostus sisältää valitut hakemukset .xls-muodossa.'; - downloadUrl = createUrl(`area_search/get_answers_xlsx/?ids=${selectedSearchIds.join(',')}`); + downloadUrl = createUrl('area_search/get_answers_xlsx/', { + ids: selectedSearchIds.join(','), + }); break; } @@ -71,7 +95,7 @@ class AreaSearchExportModal extends Component { isOpen={isOpen} onClose={onClose} title="Tulosta tiedostoon" - className="PlotSearchExportModal" + className="AreaSearchExportModal" > { }} disableDirty /> - {guideText} + {guideText} + {selectedMode === ExportModes.APPLICATIONS_PDF && <> + + + }