-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add data-export and improve the module structure for vaccinatio…
…n reports
- Loading branch information
Showing
20 changed files
with
317 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
iris-client-fe/src/components/data-export/data-export-label.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<script lang="ts"> | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { Component, Vue } from "vue-property-decorator"; | ||
import { getExportLabel } from "@/utils/data-export/common"; | ||
import { PropType } from "vue"; | ||
const DataExportLabelProps = Vue.extend({ | ||
inheritAttrs: false, | ||
props: { | ||
selected: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
total: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
label: { | ||
type: Array as PropType<string[] | null>, | ||
default: null, | ||
}, | ||
}, | ||
render() { | ||
const defaultSlot = this.$scopedSlots.default; | ||
if (!defaultSlot) return; | ||
return defaultSlot({ | ||
exportLabel: getExportLabel(this.selected, this.total, this.label), | ||
}) as any; | ||
}, | ||
}); | ||
@Component({ | ||
name: "data-export-label", | ||
}) | ||
export default class DataExportLabel extends DataExportLabelProps {} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
92 changes: 92 additions & 0 deletions
92
...on-report/views/details/modules/data-export/components/vaccination-report-data-export.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<template> | ||
<data-export-label | ||
:selected="selection.length" | ||
:total="total" | ||
:label="['Mitarbeiterdaten']" | ||
#default="{ exportLabel }" | ||
> | ||
<data-export-dialog | ||
:title="exportLabel" | ||
:disabled="selection.length <= 0" | ||
:items="exportFormatList" | ||
@export-csv-standard="exportStandard('csv')" | ||
@export-xlsx-standard="exportStandard('xlsx')" | ||
> | ||
<template #activator.prepend> | ||
<v-btn | ||
color="primary" | ||
:disabled="selection.length <= 0" | ||
data-test="export.default" | ||
@click="exportStandard('csv')" | ||
> | ||
{{ exportLabel }} | ||
</v-btn> | ||
</template> | ||
</data-export-dialog> | ||
</data-export-label> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Vue } from "vue-property-decorator"; | ||
import { PropType } from "vue"; | ||
import { VaccinationReportDetails } from "@/api"; | ||
import InfoGrid from "@/components/info-grid.vue"; | ||
import DataExportLabel from "@/components/data-export/data-export-label.vue"; | ||
import DataExportDialog, { | ||
DataExportFormat, | ||
} from "@/components/data-export/data-export-dialog.vue"; | ||
import { ExportFileType } from "@/utils/data-export/data-export"; | ||
import { getFormattedDate } from "@/utils/date"; | ||
import { VREmployeeTableRow } from "@/modules/vaccination-report/views/details/vaccination-report-details.view.vue"; | ||
import exportStandard from "@/modules/vaccination-report/views/details/modules/data-export/services/exportStandard"; | ||
const VaccinationReportDataExportProps = Vue.extend({ | ||
inheritAttrs: false, | ||
props: { | ||
report: { | ||
type: Object as PropType<VaccinationReportDetails | null>, | ||
default: null, | ||
}, | ||
selection: { | ||
type: Array as PropType<VREmployeeTableRow[]>, | ||
default: () => [], | ||
}, | ||
total: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
}, | ||
}); | ||
@Component({ | ||
components: { | ||
DataExportDialog, | ||
DataExportLabel, | ||
InfoGrid, | ||
}, | ||
}) | ||
export default class VaccinationReportDataExport extends VaccinationReportDataExportProps { | ||
exportFormatList: DataExportFormat[] = [ | ||
{ | ||
label: "Standard", | ||
csv: { | ||
action: "export-csv-standard", | ||
test: "export.csv.standard", | ||
}, | ||
xlsx: { | ||
action: "export-xlsx-standard", | ||
test: "export.xlsx.standard", | ||
}, | ||
}, | ||
]; | ||
exportStandard(type: ExportFileType): void { | ||
const fileName = [ | ||
this.report?.facility?.name || "Export", | ||
getFormattedDate(new Date(), "YYYY-MM-DD_HHmm"), | ||
].join("_"); | ||
const exporter = | ||
type === "xlsx" ? exportStandard.exportXlsx : exportStandard.exportCsv; | ||
exporter(this.selection, fileName); | ||
} | ||
} | ||
</script> |
48 changes: 48 additions & 0 deletions
48
...c/modules/vaccination-report/views/details/modules/data-export/services/exportStandard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import dataExport, { Row } from "@/utils/data-export/data-export"; | ||
import { composeAddressHeader } from "@/utils/data-export/common"; | ||
|
||
const getHeaders = () => { | ||
return [ | ||
{ | ||
text: "Vorname", | ||
value: "firstName", | ||
}, | ||
{ | ||
text: "Nachname", | ||
value: "lastName", | ||
}, | ||
composeAddressHeader(), | ||
{ | ||
text: "Erreger", | ||
value: "vaccination", | ||
}, | ||
{ | ||
text: "Impfstatus", | ||
value: "vaccinationStatus", | ||
}, | ||
]; | ||
}; | ||
|
||
const exportCsv = ( | ||
rows: Row[], | ||
fileName: string, | ||
quoted?: boolean | ||
): Promise<unknown> => { | ||
const headers = getHeaders(); | ||
return dataExport.exportCsv(headers, rows, { | ||
fileName, | ||
quoted: quoted !== false, | ||
}); | ||
}; | ||
|
||
const exportXlsx = (rows: Row[], fileName: string) => { | ||
const headers = getHeaders(); | ||
return dataExport.exportXlsx(headers, rows, { fileName }); | ||
}; | ||
|
||
const exportStandard = { | ||
exportCsv, | ||
exportXlsx, | ||
}; | ||
|
||
export default exportStandard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.