Skip to content

Commit

Permalink
Fix search component
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Nov 12, 2024
1 parent 24f6831 commit 3966d34
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions rdmo/projects/assets/js/interview/components/main/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ const Search = ({ attribute, values, setValues, collection = false }) => {
// the list of values from the server needs to be reduced to show only one entry
// for each set_prefix/set_index combination
callback(response.reduce((collections, value) => {
const { project_label, snapshot_label, value_label, set_prefix, set_index } = value

// look if a value for the same set_prefix/set_index already exists in values_list
// look if a value for the same project/snapshot/set_prefix/set_index already exists in values_list
const collection = isNil(collections) ? null : collections.find(v => (
(v.set_prefix == set_prefix) && (v.set_index == set_index)
(v.project == value.project) &&
(v.snapshot == value.snapshot) &&
(v.set_prefix == value.set_prefix) &&
(v.set_index == value.set_index)
))
if (isNil(collection)) {
// append the value
return [...collections, {
project_label, snapshot_label, value_label, set_prefix, set_index, values: [value]
}]
return [...collections, { ...value, values: [value] }]
} else {
// update the value_title and the values array of the existing value
collection.value_label += '; ' + value.value_label
Expand Down

0 comments on commit 3966d34

Please sign in to comment.