diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/TreeView.tsx | 2 | ||||
-rw-r--r-- | src/client/views/nodes/trails/PresBox.tsx | 27 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx index 304d68a20..f9497eb4a 100644 --- a/src/client/views/collections/TreeView.tsx +++ b/src/client/views/collections/TreeView.tsx @@ -1013,7 +1013,7 @@ export class TreeView extends React.Component<TreeViewProps> { containerCollection={containerCollection} prevSibling={docs[i]} // TODO: [AL] add these - hierarchyIndex={[...hierarchyIndex!, i]} + hierarchyIndex={[...hierarchyIndex!, i + 1]} AddToMap={AddToMap} RemFromMap={RemFromMap} treeView={treeView} diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx index 60d54c433..cfc7b0416 100644 --- a/src/client/views/nodes/trails/PresBox.tsx +++ b/src/client/views/nodes/trails/PresBox.tsx @@ -103,7 +103,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { // @computed get childDocs() { return DocListCast(this.rootDoc.presentationaLinearizedDocuments); } //_treeViewMap:Map<number[], Doc> @computed get childDocs() { return DocListCast(this.rootDoc.presentationLinearizedDocuments); } - @observable _treeViewMap: Map<string, Doc> = new Map<string, Doc>(); + @observable _treeViewMap: Map<number, Doc> = new Map<number, Doc>(); @computed get tagDocs() { const tagDocs: Doc[] = []; @@ -750,7 +750,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { //Regular click @action selectElement = async (doc: Doc) => { - console.log("child docs are:", doc); + console.log("tree docs are:", this._treeViewMap); + console.log("child docs are:", this.childDocs); + console.log("linearized docs:", this.rootDoc.presentationLinearizedDocuments); console.log("got here", this.childDocs.indexOf(doc)); const context = Cast(doc.context, Doc, null); this.gotoDocument(this.childDocs.indexOf(doc), this.activeItem); @@ -2427,19 +2429,30 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { } AddToMap = (treeViewDoc: Doc, index: number[]): Doc[] => { - this._treeViewMap.set(String(index), treeViewDoc); - this.props.Document.presentationaLinearizedDocuments = new List<Doc>(this.sort(this._treeViewMap)); // this is a flat array of Docs + var indexNum = 0; + for (let i = 0; i < index.length; i++) { + indexNum += (index[i] * (10 ** (-i))); + } + this._treeViewMap.set(indexNum, treeViewDoc); + console.log(String(index), treeViewDoc) + this.props.Document.presentationLinearizedDocuments = new List<Doc>(this.sort(this._treeViewMap)); // this is a flat array of Docs + console.log(this.props.Document.presentationLinearizedDocuments) return this.childDocs; } RemFromMap = (treeViewDoc: Doc, index: number[]): Doc[] => { - this._treeViewMap.delete(String(index)) - this.props.Document.presentationaLinearizedDocuments = new List<Doc>(this.sort(this._treeViewMap)); + var indexNum = 0; + for (let i = 0; i < index.length; i++) { + indexNum += (index[i] * (10 ** (-i))); + } + console.log(String(index), treeViewDoc) + this._treeViewMap.delete(indexNum) + this.props.Document.presentationLinearizedDocuments = new List<Doc>(this.sort(this._treeViewMap)); return this.childDocs; } // TODO: [AL] implement sort function for an array of numbers (e.g. arr[1,2,4] v arr[1,2,1]) - sort = (treeViewMap: Map<string, Doc>): Doc[] => { + sort = (treeViewMap: Map<number, Doc>): Doc[] => { // TODO const sortedMap = [...treeViewMap.entries()].sort(); var sortedDocs = []; |