Skip to content
Snippets Groups Projects
Commit 0145144f authored by S.Listl's avatar S.Listl
Browse files

Potential bug fixed in ObjectTree

parent 0430814e
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,8 @@ import("Contact_lib");
* - get parameters
* - load data via _loadObjectRelationTree
* * _loadObjectRelationTree calls itself recursively
* - data is insertet into the tree which is bound to _loadObjectRelationTree
* -> each "push" to this in _loadObjectRelationTree updates automatically tree
* - data is insertet into the tree,
* -> this.push in _loadObjectRelationTree changes tree
* - the "tree" is returned
*/
......@@ -31,8 +31,6 @@ var UID = {
}
var tree = [];
//the function is recursive => bind the tree to the function
_loadObjectRelationTree = _loadObjectRelationTree.bind(tree);
// uidParam: if only one row should be loaded
var uidParam;
......@@ -80,7 +78,8 @@ else
// load the object relations for each given objectId / Type
for (let i = 0; i < originalObjectIds.length; i++)
{
_loadObjectRelationTree(originalObjectIds[i], originalObjectTypes[i], selectedRelationType);
//.call, because tree is used as 'this' to prevent accidentally overwriting tree
_loadObjectRelationTree.call(tree, originalObjectIds[i], originalObjectTypes[i], selectedRelationType);
}
}
if (uidParam) //workaround!
......@@ -130,10 +129,10 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
var childsTmpTree = [];
// add as group to parentTmpTree but not yet to the tree itself
// true to enable the insert button always --v
let uids = _insertEntry(parentTmpTree, [[currentObjectId, "", "", "", "", relationTypeData[7]]], pNodeId, pLayer, pObjectType, selectedRelationType, relationTypeData[12], true)
let uids = _insertEntry(parentTmpTree, [[currentObjectId, "", "", "", "", relationTypeData[7]]], pNodeId, pLayer, pObjectType, pObjectRelationTypeId, relationTypeData[12], true)
for (let i = 0; i < uids.length; i++)
{ // recursive call
_loadObjectRelationTree(childsTmpTree, uids[i][UID.objectId], uids[i][UID.otherObjectType], relationTypeData[0], uids[i], pLayer+1, relationTypeData);
_loadObjectRelationTree.call(childsTmpTree, uids[i][UID.objectId], uids[i][UID.otherObjectType], relationTypeData[0], uids[i], pLayer+1, relationTypeData);
}
// only add parent if childs exist
......@@ -159,7 +158,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
// add the relationtype as grouping
this.push([JSON.stringify(uid), null, translate.text(title), JSON.stringify(pNodeId), true, null, null, "", relationTypeId, icon]);
_loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, uid, pLayer+1, relationTypes[i]);
_loadObjectRelationTree.call(this, pObjectId, pObjectType, pObjectRelationTypeId, uid, pLayer+1, relationTypes[i]);
}
}, this);
}
......@@ -183,15 +182,12 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
var myData = _getEntryData(pNodeId[0], direction, relationType1, relationType2)
// if hierarchy and selected RelationType -> use the selected one
if (selectedRelationType)
relationTypeIdForNew = selectedRelationType
else
relationTypeIdForNew = thisRelationTypeId;
relationTypeIdForNew = pObjectRelationTypeId || thisRelationTypeId;
let uids = _insertEntry(this, myData, pNodeId, pLayer, destObjectType, relationTypeIdForNew, icon, hierarchy)
for (let i = 0; i < uids.length; i++)
{ // recursive call
_loadObjectRelationTree(uids[i][UID.objectId], uids[i][UID.otherObjectType], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData);
_loadObjectRelationTree.call(this, uids[i][UID.objectId], uids[i][UID.otherObjectType], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData);
}
}
else
......
import("system.vars");
import("Sql_lib");
var uid = JSON.parse(vars.getString("$local.uid"));
var isObjectRelationNode = typeof uid[2] == "string";
var objectRelationId = vars.get("$local.rowdata")["OBJECTRELATIONID.value"];
newWhereIfSet("AB_OBJECTRELATION.AB_OBJECTRELATIONID", objectRelationId).deleteData();
if (isObjectRelationNode)
{
var objectRelationId = uid[6];
newWhereIfSet("AB_OBJECTRELATION.AB_OBJECTRELATIONID", objectRelationId).deleteData();
}
import("system.vars");
import("system.neon");
import("system.db");
import("Sql_lib");
var rowdata = vars.get("$local.rowdata");
var uid = JSON.parse(rowdata["UID.value"]);
var isObjectRelationNode = typeof uid[2] == "string";
var objectRelationId = vars.get("$local.rowdata")["OBJECTRELATIONID.value"];
if (isObjectRelationNode)
{
var objectRelationId = uid[6];
newWhereIfSet("AB_OBJECTRELATION.AB_OBJECTRELATIONID", objectRelationId)
.updateFields({"INFO" : rowdata["INFO.value"]});
}
newWhereIfSet("AB_OBJECTRELATION.AB_OBJECTRELATIONID", objectRelationId)
.updateFields({"INFO" : rowdata["INFO.value"]});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment