diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx')
-rw-r--r-- | src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx index 7b7431bbe..0939247b7 100644 --- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx +++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx @@ -434,23 +434,37 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { // Create an array of promises for each document const childDocPromises = data.map(async doc => { const parsedDoc = JSON.parse(doc); - + console.log('Parse #3: ' + parsedDoc); if (parsedDoc.doc_type !== 'collection') { // Handle non-collection documents return await this.whichDoc(parsedDoc.doc_type, parsedDoc.data, parsedDoc.options, parsedDoc.id); } else { // Recursively process collections - const nestedDocs = await this.createCollectionWithChildren(parsedDoc.data); - return nestedDocs; // This will return an array of Docs + const nestedDocs = await this.createCollectionWithChildren(JSON.parse(parsedDoc.data) as string[]); + const collectionOptions: DocumentOptions = { + title: parsedDoc.title, + backgroundColor: parsedDoc.background_color, + _width: parsedDoc.width, + _height: parsedDoc.height, + _layout_fitWidth: true, + _freeform_backgroundGrid: true, + }; + const collectionDoc = DocCast(Docs.Create.FreeformDocument(nestedDocs, collectionOptions)); + return collectionDoc; // Return th } }); // Await all child document creations concurrently const nestedResults = await Promise.all(childDocPromises); - + console.log('n' + nestedResults); // Flatten any nested arrays from recursive collection calls - const childDocs = nestedResults.flat(); - + const childDocs = nestedResults.flat() as Doc[]; + console.log('c' + childDocs); + childDocs.forEach(doc => { + console.log(DocCast(doc)); + console.log(DocCast(doc)[DocData].data); + console.log(DocCast(doc)[DocData].data); + }); return childDocs; }; @@ -478,8 +492,12 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { break; case 'collection': { const par = JSON.parse(data); + console.log('Parse #2: ' + par); const arr = await this.createCollectionWithChildren(par); - doc = DocCast(Docs.Create.FreeformDocument(arr, options)); + options._layout_fitWidth = true; + options._freeform_backgroundGrid = true; + const opts = { _width: 500, _height: 800, _layout_fitWidth: true, _freeform_backgroundGrid: true }; + doc = DocCast(Docs.Create.FreeformDocument(arr, opts)); break; } case 'web': |