From 3b98831182a4d830cf577fa217a477b2cadcd7bc Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Wed, 26 Feb 2025 16:27:10 -0500 Subject: separated field content classes technically working --- .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx | 12 ++- .../DocCreatorMenu/FieldTypes/DecorationField.tsx | 38 +++++++ .../DocCreatorMenu/FieldTypes/DynamicField.tsx | 11 ++- .../DataVizBox/DocCreatorMenu/FieldTypes/Field.tsx | 19 ++-- .../DocCreatorMenu/FieldTypes/FieldUtils.tsx | 12 ++- .../DocCreatorMenu/FieldTypes/StaticContentField | 98 ------------------ .../FieldTypes/StaticContentField.tsx | 109 +++++++++++++++++++++ .../nodes/DataVizBox/DocCreatorMenu/Template.tsx | 8 +- .../DataVizBox/DocCreatorMenu/TemplateManager.tsx | 2 +- 9 files changed, 183 insertions(+), 126 deletions(-) create mode 100644 src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/DecorationField.tsx delete mode 100644 src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/StaticContentField create mode 100644 src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/StaticContentField.tsx (limited to 'src') diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx index b576aee82..6f3647133 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx @@ -568,13 +568,17 @@ export class DocCreatorMenu extends ObservableReactComponent { let prompt: string = `(${origCount}) ${inputText}`; + console.log('prompt is: ', prompt) + this._GPTLoading = true; try { const res = await gptAPICall(prompt, GPTCallType.TEMPLATE); if (res) { + console.log('res is: ', res) const assignments: { [templateTitle: string]: { [fieldID: string]: string } } = JSON.parse(res); + console.log('assignments: ', assignments) const brokenDownAssignments: [Template, { [fieldID: number]: Col }][] = []; Object.entries(assignments).forEach(([tempTitle, assignment]) => { @@ -583,7 +587,7 @@ export class DocCreatorMenu extends ObservableReactComponent { const toObj = Object.entries(assignment).reduce( (a, [fieldID, colTitle]) => { const col = this.getColByTitle(colTitle); - if (!this._userCreatedFields.includes(col)){ // do the following for any fields not added by the user; will change in the future, for now only GPT content works with user-added fields + if (!this._userCreatedFields.includes(col)){ // do the following for any fields not added by the user; will change in the future, for now only GPT content works with user-added field const field = template.getFieldByID(Number(fieldID)); field.setContent(col.defaultContent ?? '', col.type === TemplateFieldType.VISUAL ? ViewType.IMG : ViewType.TEXT); field.setTitle(col.title); @@ -594,7 +598,9 @@ export class DocCreatorMenu extends ObservableReactComponent { }, {} as { [field: number]: Col } ); + console.log('all assignments: ', toObj) brokenDownAssignments.push([template, toObj]); + console.log('brokendownassignments: ', brokenDownAssignments) }); return brokenDownAssignments; @@ -612,13 +618,15 @@ export class DocCreatorMenu extends ObservableReactComponent { const cols = this.fieldsInfos; const templates = this.templateManager.getValidTemplates(cols); + console.log(templates) + const assignments: [Template, { [field: number]: Col }][] = await this.assignColsToFields(templates, cols); const renderedTemplatePromises: Promise