diff --git a/src/components/download/DataDownloadDisplayComponent.vue b/src/components/download/DataDownloadDisplayComponent.vue index 9a0ec225..3f5203e2 100644 --- a/src/components/download/DataDownloadDisplayComponent.vue +++ b/src/components/download/DataDownloadDisplayComponent.vue @@ -132,7 +132,7 @@ () -const showFileDownloadDialog = ref(false) +const downloadDialogStore = useDownloadDialogStore() const settings = useUserSettingsStore() const options = computed(() => { return { @@ -381,21 +382,27 @@ function downloadData() { errors.value = validateUserInput(startTimeRequest, endTimeRequest) if (errors.value.length !== 0) return - const parameterIds = selectedParameterQualifiers.value.map( - (parameterQualifier) => parameterQualifier.parameterId, - ) - const qualifiersIds = selectedParameterQualifiers.value - .filter((parameterQualifier) => parameterQualifier.qualifiers !== undefined) + const selectedParameterIds = selectedParameterQualifiers.value + .map((parameterQualifier) => parameterQualifier.parameterId) + .filter((parameterId) => parameterId !== undefined) + + const selectedQualifierIds = selectedParameterQualifiers.value .map((parameterQualifier) => parameterQualifier.qualifiers) .flatMap((item) => item) + .filter((qualifier) => qualifier !== undefined) + + const selectedLocationIds = selectedLocations.value.map( + (location) => location.locationId, + ) + + const joinUniqueStrings = (stringArray: string[]) => + stringArray.length > 0 ? uniqWith(stringArray).join(',') : undefined timeSeriesFilter.value = { filterId: filterId, - locationIds: selectedLocations.value - .map((location) => location.locationId) - .join(','), - parameterIds: uniqWith(parameterIds).join(','), - qualifierIds: uniqWith(qualifiersIds).join(','), + locationIds: joinUniqueStrings(selectedLocationIds), + parameterIds: joinUniqueStrings(selectedParameterIds), + qualifierIds: joinUniqueStrings(selectedQualifierIds), onlyHeaders: onlyDownloadMetaData.value, } const queryParameters = filterToParams(timeSeriesFilter.value) @@ -407,7 +414,7 @@ function downloadData() { downloadStartTime.value = startTimeRequest.toJSDate() downloadEndTime.value = endTimeRequest.toJSDate() - showFileDownloadDialog.value = true + downloadDialogStore.showDialog = true } function getLocationName(location: Location): string {