Skip to content

Commit

Permalink
Merge pull request #232 from CSCfi/CSCFC4EMSCR-602
Browse files Browse the repository at this point in the history
CSCFC4EMSCR-602 When filtering from mappings, results get duplicated.
  • Loading branch information
masillan authored Nov 12, 2024
2 parents 20830aa + dccae7b commit 61d7167
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions mscr-ui/src/modules/crosswalk-editor/mappings-accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -421,19 +421,27 @@ function filterMappings(nodeMappingsInput: NodeMapping[], value: string, showAtt
let results: NodeMapping[] = [];
const searchString = value.toLowerCase();
nodeMappingsInput.forEach(item => {
if (item?.notes && item.notes.toLowerCase().includes(searchString)) {
let itemFound = false
if (item?.notes && item.notes.toLowerCase().includes(searchString) && !itemFound) {
results.push(item);
itemFound = true;
}
if (!itemFound) {
item.source.forEach(src => {
if (src.label.toLowerCase().includes(searchString) && !itemFound) {
results.push(item);
itemFound = true;
}
});
}
if (!itemFound) {
item.target.forEach(src => {
if (src.label.toLowerCase().includes(searchString) && !itemFound) {
results.push(item);
itemFound = true;
}
});
}
item.source.forEach(src => {
if (src.label.toLowerCase().includes(searchString)) {
results.push(item);
}
});
item.target.forEach(src => {
if (src.label.toLowerCase().includes(searchString)) {
results.push(item);
}
});
}
);
return results;
Expand Down

0 comments on commit 61d7167

Please sign in to comment.