Skip to content
Snippets Groups Projects
Commit 609566cf authored by Xiao Gui's avatar Xiao Gui
Browse files

bugfix: show only latest version of region...

... in "show in other tmpls"
parent 40e90fd9
No related branches found
No related tags found
No related merge requests found
......@@ -90,19 +90,31 @@ export class RegionBase {
const filteredRsInOtherTmpls = []
for (const bundledObj of regionsInOtherTemplates) {
const { template, parcellation, region } = bundledObj
const idx = filteredRsInOtherTmpls.findIndex(({ template: _template, region: _region }) => {
/**
* trying to find duplicate region
* with same templateId, and same hemisphere
*/
const sameEntityIdx = filteredRsInOtherTmpls.findIndex(({ template: _template, region: _region }) => {
return _template['@id'] === template['@id']
&& getRegionHemisphere(_region) !== getRegionHemisphere(region)
&& getRegionHemisphere(_region) === getRegionHemisphere(region)
})
if ( idx < 0 ) {
/**
* if doesn't exist, just push to output
*/
if ( sameEntityIdx < 0 ) {
filteredRsInOtherTmpls.push(bundledObj)
} else {
const { parcellation: currentParc } = filteredRsInOtherTmpls[idx]
/**
* if exists, only append the latest version
*/
const { parcellation: currentParc } = filteredRsInOtherTmpls[sameEntityIdx]
/**
* if the new element is newer than existing item
*/
if (isNewerThan(parcellations, parcellation, currentParc)) {
filteredRsInOtherTmpls.splice(idx, 1)
filteredRsInOtherTmpls.splice(sameEntityIdx, 1)
filteredRsInOtherTmpls.push(bundledObj)
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment