WIP: Aureplop/kpsul js refactor #501
1 changed files with 9 additions and 4 deletions
|
@ -720,18 +720,21 @@ class ModelForest {
|
||||||
var that = this;
|
var that = this;
|
||||||
function recurse(node) {
|
function recurse(node) {
|
||||||
if (node.constructor.verbose_name === modelname) {
|
if (node.constructor.verbose_name === modelname) {
|
||||||
callback(node);
|
if callback(node);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var children = that.get_children(node);
|
var children = that.get_children(node);
|
||||||
if (children) {
|
if (children) {
|
||||||
for (let child of children)
|
for (let child of children)
|
||||||
recurse(child);
|
if (recurse(child))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let root of this.roots)
|
for (let root of this.roots)
|
||||||
recurse(root);
|
if (recurse(root))
|
||||||
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -743,8 +746,10 @@ class ModelForest {
|
||||||
var result = null;
|
var result = null;
|
||||||
|
|
||||||
function callback(node) {
|
function callback(node) {
|
||||||
if (node.id == id)
|
if (node.id == id) {
|
||||||
result = node ;
|
result = node ;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.traverse(modelname, callback);
|
this.traverse(modelname, callback);
|
||||||
|
|
Loading…
Reference in a new issue