Bug Fixed, Counting Children
This commit is contained in:
1 parent
2875aab0e7
commit
ef85e0ca66
1 file changed
+57
-11
@@ -231,11 +231,51 @@ function newNodeChildren () {
|
||||
return countChildrenJavascriptCode(parentNode, childNode)
|
||||
}
|
||||
default: {
|
||||
console.log('WARNING this parentNode type is not listed at NodeChildren: ' + parentNode.type)
|
||||
return countChildrenUiObject(parentNode, childNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function countChildrenUiObject (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
let nodeDefinition = APP_SCHEMA_MAP.get(parentNode.type)
|
||||
if (nodeDefinition !== undefined) {
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
for (i = 0; i < nodeDefinition.properties.length; i++) {
|
||||
let property = nodeDefinition.properties[i]
|
||||
if (parentNode[property.name] !== undefined) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
parent[property.name] = object
|
||||
response.childrenCount++
|
||||
if (parentNode[property.name].id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = parentNode[property.name]
|
||||
for (let j = 0; j < nodePropertyArray.length; j++) {
|
||||
let child = nodePropertyArray[j]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenDefinition (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
@@ -545,9 +585,9 @@ function newNodeChildren () {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.code !== undefined) {
|
||||
if (parentNode.javascriptCode !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.code.id === childNode.id) {
|
||||
if (parentNode.javascriptCode.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
@@ -559,9 +599,9 @@ function newNodeChildren () {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.code !== undefined) {
|
||||
if (parentNode.javascriptCode !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.code.id === childNode.id) {
|
||||
if (parentNode.javascriptCode.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
@@ -691,9 +731,15 @@ function newNodeChildren () {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.code !== undefined) {
|
||||
if (parentNode.javascriptCode !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.code.id === childNode.id) {
|
||||
if (parentNode.javascriptCode.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.shapes !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.shapes.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
@@ -714,9 +760,9 @@ function newNodeChildren () {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.code !== undefined) {
|
||||
if (parentNode.javascriptCode !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.code.id === childNode.id) {
|
||||
if (parentNode.javascriptCode.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
@@ -1474,9 +1520,9 @@ function newNodeChildren () {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.code !== undefined) {
|
||||
if (parentNode.javascriptCode !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.code.id === childNode.id) {
|
||||
if (parentNode.javascriptCode.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user