Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issues from fews 31954 #1049

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions src/components/download/DataDownloadDisplayComponent.vue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some tests for this function.

Original file line number Diff line number Diff line change
Expand Up @@ -482,26 +482,25 @@ async function getLocations(): Promise<Location[]> {
}

function getAttributeValues(locations: Location[]): string[][] {
const attributeValuesMap: string[][] = []
const configuredAttributeIds =
props.topologyNode.dataDownloadDisplay?.attributes.map((item) => item.id)
configuredAttributeIds?.forEach((item) => attributeValuesMap.push([]))
if (configuredAttributeIds === undefined) return attributeValuesMap
for (const newLocation of locations) {
let attributes = newLocation.attributes
if (attributes == undefined) continue
for (let i = 0; i < attributes.length; i++) {
const attribute = attributes[i]
if (attribute.id === undefined) continue
if (attribute.value === undefined) continue
const arrayForAttribute =
attributeValuesMap[configuredAttributeIds.indexOf(attribute.id)]
if (!arrayForAttribute.includes(attribute.value)) {
arrayForAttribute.push(attribute.value)
const attributes = props.topologyNode.dataDownloadDisplay?.attributes
if (!attributes) return []

const attributeValuesMap: string[][] = attributes.map(() => [])

locations.forEach((location) => {
location.attributes?.forEach((attribute) => {
const index = attributes.findIndex((attr) => attr.id === attribute.id)
if (
index !== -1 &&
attribute.value &&
!attributeValuesMap[index].includes(attribute.value)
) {
attributeValuesMap[index].push(attribute.value)
}
}
}
attributeValuesMap.forEach((value, key) => value.sort())
})
})

attributeValuesMap.forEach((values) => values.sort())
return attributeValuesMap
}

Expand Down