fix tree trunaction
This commit is contained in:
parent
980fc22a1a
commit
31d11f3bed
1 changed files with 14 additions and 4 deletions
18
js/app.js
18
js/app.js
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
function genPos(id, fetchData) {
|
function genPos(id, fetchData, k) {
|
||||||
let queue = [id];
|
let queue = [id];
|
||||||
|
|
||||||
let queueHead;
|
let queueHead;
|
||||||
|
@ -15,7 +15,7 @@ function genPos(id, fetchData) {
|
||||||
"date": fetchData[id].datetime_shared,
|
"date": fetchData[id].datetime_shared,
|
||||||
"user": fetchData[id].username,
|
"user": fetchData[id].username,
|
||||||
"visible": status,
|
"visible": status,
|
||||||
"x": '0',
|
"x": k + '',
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"offbranch": 0,
|
"offbranch": 0,
|
||||||
"end": fetchData[id].children.length
|
"end": fetchData[id].children.length
|
||||||
|
@ -94,9 +94,19 @@ function sortPos(a, b) {
|
||||||
|
|
||||||
|
|
||||||
async function main(fetchData) {
|
async function main(fetchData) {
|
||||||
let rootId = fetchData['root_id'];
|
//let rootId = fetchData['root_id'];
|
||||||
|
|
||||||
|
let pos = [];
|
||||||
|
|
||||||
|
let filteredFetch = Object.keys(fetchData).filter(x => {
|
||||||
|
let a = fetchData[fetchData[x].parent_id];
|
||||||
|
if (a && a.children.length < 1) a.children = [x]
|
||||||
|
return x != 'root_id' && !a
|
||||||
|
}).sort((a,b) => a - b);
|
||||||
|
for (let rootId in filteredFetch) {
|
||||||
|
pos = [...pos,...genPos(filteredFetch[rootId], fetchData, rootId)];
|
||||||
|
}
|
||||||
|
|
||||||
let pos = genPos(rootId, fetchData);
|
|
||||||
|
|
||||||
let posX = [];
|
let posX = [];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue