diff options
Diffstat (limited to 'src/client/views/nodes')
| -rw-r--r-- | src/client/views/nodes/trails/PresBox.tsx | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx index 4fa52565e..60d54c433 100644 --- a/src/client/views/nodes/trails/PresBox.tsx +++ b/src/client/views/nodes/trails/PresBox.tsx @@ -98,7 +98,13 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { @observable private openMovementDropdown: boolean = false; @observable private openEffectDropdown: boolean = false; @observable private presentTools: boolean = false; - @computed get childDocs() { return DocListCast(this.rootDoc[this.fieldKey]); } + // @computed get childDocs() { return DocListCast(this.rootDoc[this.fieldKey]); } + // TODO: [AL] add childDocs() and treeMap fields + // @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>(); + @computed get tagDocs() { const tagDocs: Doc[] = []; for (const doc of this.childDocs) { @@ -134,6 +140,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { { field: "string", data: Doc.name, container: Doc.name }); } this.props.Document.presentationFieldKey = this.fieldKey; // provide info to the presElement script so that it can look up rendering information about the presBox + //TODO: [AL] change this + this.props.Document.presentationLinearizedDocuments = new List<Doc>(); } @computed get selectedDocumentView() { if (SelectionManager.Views().length) return SelectionManager.Views()[0]; @@ -214,6 +222,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { } //TODO: al: it seems currently that tempMedia doesn't stop onslidechange after clicking the button; the time the tempmedia stop depends on the start & end time + // TODO: to handle child slides (entering into subtrail and exiting), also the next() and back() functions // No more frames in current doc and next slide is defined, therefore move to next slide nextSlide = (activeNext: Doc) => { const targetNext = Cast(activeNext.presentationTargetDoc, Doc, null); @@ -741,7 +750,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { //Regular click @action selectElement = async (doc: Doc) => { - console.log("got here", this.childDocs.indexOf(doc)) + console.log("child docs are:", doc); + console.log("got here", this.childDocs.indexOf(doc)); const context = Cast(doc.context, Doc, null); this.gotoDocument(this.childDocs.indexOf(doc), this.activeItem); if (doc.presPinView || doc.presentationTargetDoc === this.layoutDoc.presCollection) setTimeout(() => this.updateCurrentPresentation(context), 0); @@ -2416,6 +2426,29 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { PresBox.startMarquee = true; } + 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 + 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)); + 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[] => { + // TODO + const sortedMap = [...treeViewMap.entries()].sort(); + var sortedDocs = []; + for (var kv of sortedMap) { + sortedDocs.push(kv[1]); + } + return sortedDocs; + } + render() { // calling this method for keyEvents this.isPres; @@ -2465,6 +2498,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { dontRegisterView={true} focus={this.selectElement} ScreenToLocalTransform={this.getTransform} + // TODO: [AL] implement AddToMap, RemFromMap functions (outside this) + AddToMap={this.AddToMap} + RemFromMap={this.RemFromMap} + hierarchyIndex={[]} /> : (null) } </div> @@ -2480,11 +2517,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { </div>; } } -ScriptingGlobals.add(function lookupPresBoxField(container: Doc, field: string, data: Doc) { - if (field === 'indexInPres') return DocListCast(container[StrCast(container.presentationFieldKey)]).indexOf(data); - if (field === 'presCollapsedHeight') return [CollectionViewType.Tree || CollectionViewType.Stacking].includes(container._viewType as any) ? 35 : 31; - if (field === 'presStatus') return container.presStatus; - if (field === '_itemIndex') return container._itemIndex; - if (field === 'presBox') return container; +// this func communicates with PresBoxElement to send information of the doc +ScriptingGlobals.add(function lookupPresBoxField(presBoxDoc: Doc, field: string, presEleDoc: Doc) { + if (field === 'indexInPres') return DocListCast(presBoxDoc.presentationLinearizedDocuments).indexOf(presEleDoc); + if (field === 'presCollapsedHeight') return [CollectionViewType.Tree || CollectionViewType.Stacking].includes(presBoxDoc._viewType as any) ? 35 : 31; + if (field === 'presStatus') return presBoxDoc.presStatus; + if (field === '_itemIndex') return presBoxDoc._itemIndex; + if (field === 'presBox') return presBoxDoc; return undefined; });
\ No newline at end of file |
