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

AttributeRelation bugfix

parent c7752f2c
No related branches found
No related tags found
No related merge requests found
import("Util_lib");
import("system.vars");
import("system.result");
import("system.db");
......@@ -81,7 +82,7 @@ var attributeValues = db.table(attributeSql).map(function (row)
if (getTree)
_fetchAttributes(attributeValues.map(function (row) {return row[1]}));
allAttributes = TreeUtils.sortArrayForTree(allAttributes).concat(attributeValues);
allAttributes = TreeUtils.sortArrayForTree(allAttributes, 0, 1).concat(attributeValues);
result.object(allAttributes);
......@@ -106,33 +107,4 @@ function _fetchAttributes (pAttributeIds)
}, attributeObj);
if (nextIds.length)
_fetchAttributes(nextIds);
}
function _sortArrayForTree (pArray)
{
if (pArray.length <= 1)
return pArray;
var rows = {};
var allIds = {};
var idIndex = 0;
var parentIdIndex = 1;
pArray.forEach(function (row) {allIds[row[idIndex]] = true;});
var index = 0;
do {
var oldIndex = index;
pArray.forEach(function (row)
{
if (!(row[idIndex] in this) && (row[parentIdIndex] in this || !allIds[row[parentIdIndex]]))
this[row[idIndex]] = {
data : row,
index : index++
};
}, rows);
} while (oldIndex != index);
var sortedArray = new Array(index);
for (let i in rows)
sortedArray[rows[i].index] = rows[i].data;
return sortedArray;
}
\ No newline at end of file
......@@ -3480,6 +3480,9 @@
<entry>
<key>Competitors</key>
</entry>
<entry>
<key>Notifications</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
<sqlModels>
......
......@@ -3515,6 +3515,9 @@
<entry>
<key>Competitors</key>
</entry>
<entry>
<key>Notifications</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
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