fix analysis tree reconstruct
parent
c739fa5cf8
commit
400b8d23c5
|
@ -42,6 +42,7 @@ import { storedProp, StoredBooleanProp } from 'common/storage';
|
|||
import { StudyCtrl } from './study/interfaces';
|
||||
import { StudyPracticeCtrl } from './study/practice/interfaces';
|
||||
import { valid as crazyValid } from './crazy/crazyCtrl';
|
||||
import {treeReconstruct} from './util';
|
||||
|
||||
export default class AnalyseCtrl {
|
||||
|
||||
|
@ -184,7 +185,7 @@ export default class AnalyseCtrl {
|
|||
this.ongoing = !this.synthetic && game.playable(data);
|
||||
|
||||
const prevTree = merge && this.tree.root;
|
||||
this.tree = makeTree(treeOps.reconstruct(this.data.treeParts));
|
||||
this.tree = makeTree(treeReconstruct(this.data.treeParts));
|
||||
if (prevTree) this.tree.merge(prevTree);
|
||||
|
||||
this.actionMenu = new ActionMenuCtrl();
|
||||
|
|
|
@ -191,3 +191,17 @@ export function option(value: string, current: string | undefined, name: string)
|
|||
export function scrollTo(el: HTMLElement | undefined, target: HTMLElement | null) {
|
||||
if (el && target) el.scrollTop = target.offsetTop - el.offsetHeight / 2 + target.offsetHeight / 2;
|
||||
}
|
||||
|
||||
export function treeReconstruct(parts: any): Tree.Node {
|
||||
const root = parts[0], nb = parts.length;
|
||||
let node = root, i: number;
|
||||
root.id = '';
|
||||
for (i = 1; i < nb; i++) {
|
||||
const n = parts[i];
|
||||
if (node.children) node.children.unshift(n);
|
||||
else node.children = [n];
|
||||
node = n;
|
||||
}
|
||||
node.children = node.children || [];
|
||||
return root;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue