fixed bug to get parent indexes.
This commit is contained in:
parent
8f37b9c537
commit
ae5cd9eced
@ -148,20 +148,20 @@ class IndexUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getParents(type: BrainAtlasType, parentId: number, func: SearchCallbackFunc): void {
|
getParents(type: BrainAtlasType, parentId: number, func: SearchCallbackFunc): void {
|
||||||
|
this.registerIndexLoadCallback(type, (indexes) => {
|
||||||
const parents: Index[] = [];
|
const parents: Index[] = [];
|
||||||
const loop = (parentId: number, func: SearchCallbackFunc) => {
|
const loop = (parentId: number) => {
|
||||||
if (parentId === INDEX_ID_ROOT) {
|
if (parentId !== INDEX_ID_ROOT) {
|
||||||
func(parents);
|
const parent = indexes.findOne({ id: parentId });
|
||||||
} else {
|
if (parent !== null) {
|
||||||
this.get(type, parentId, (parent) => {
|
loop(parent.parentId);
|
||||||
if (parent != null) {
|
|
||||||
loop(parent.parentId, func);
|
|
||||||
parents.push(parent);
|
parents.push(parent);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
loop(parentId, func);
|
loop(parentId);
|
||||||
|
func(parents);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user