From b6ed6542f911694c673b9e324d7387ea16dc7d0b Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:37:49 -0500 Subject: template reset option and fixed preview not rendering on edits after 1st --- .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx | 21 +++++++++++++-------- .../DocCreatorMenu/FieldTypes/StaticField.tsx | 2 ++ .../nodes/DataVizBox/DocCreatorMenu/Template.tsx | 12 ++++++------ 3 files changed, 21 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx index fe91254f8..48f87ebfe 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx @@ -118,7 +118,7 @@ export class DocCreatorMenu extends ObservableReactComponent { @action updateTemplatePreview = (template: Template) => { template.renderUpdates(); const preview = {template: template, doc: template.getRenderedDoc()}; - this._suggestedTemplatePreviews.map(t => { return t.template === preview.template ? preview : t }); //prettier-ignore + this._suggestedTemplatePreviews = this._suggestedTemplatePreviews.map(t => { return t.template === preview.template ? preview : t }); //prettier-ignore this._userTemplates = this._userTemplates.map(t => { return t.template === preview.template ? preview : t }); //prettier-ignore }; @action setSuggestedTemplates = (templates: Template[]) => { @@ -740,10 +740,12 @@ export class DocCreatorMenu extends ObservableReactComponent { this.closeMenu(); } - @action setExpandedView = (doc: Doc | undefined) => { - if (doc) { - this._expandedPreview = doc; //Docs.Create.FreeformDocument([doc], { _height: NumListCast(doc._height)[0], _width: NumListCast(doc._width)[0], title: ''}); + @action setExpandedView = (template: Template | undefined) => { + if (template) { + this._currEditingTemplate = template; + this._expandedPreview = template.mainField.renderedDoc(); //Docs.Create.FreeformDocument([doc], { _height: NumListCast(doc._height)[0], _width: NumListCast(doc._width)[0], title: ''}); } else { + this._currEditingTemplate = undefined; this._expandedPreview = undefined; } }; @@ -781,10 +783,13 @@ export class DocCreatorMenu extends ObservableReactComponent {
{rendered}
- -
@@ -832,7 +837,7 @@ export class DocCreatorMenu extends ObservableReactComponent { className="option-button left" onPointerDown={e => this.setUpButtonClick(e, () => { - this.setExpandedView(template.getRenderedDoc()); + this.setExpandedView(template); }) }> @@ -901,7 +906,7 @@ export class DocCreatorMenu extends ObservableReactComponent { className="option-button left" onPointerDown={e => this.setUpButtonClick(e, () => { - this.setExpandedView(template.getRenderedDoc()); + this.setExpandedView(template); }) }> diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/StaticField.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/StaticField.tsx index e55c127e7..dfef77c0b 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/StaticField.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/StaticField.tsx @@ -118,6 +118,8 @@ export class StaticField { updateRenderedDoc = (oldDoc?: Doc): Doc => { const opts = this.settings.opts; + console.log('called') + if (!this.contentType) { this.contentType = FieldContentType.STRING }; let doc: Doc; diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx index 292c20a10..11fad3bf1 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx @@ -31,12 +31,6 @@ export class Template { return clone; } - applyFields = () => { - this.contentFields.forEach(field => { - this.mainField - }); - } - getRenderedDoc = () => { const doc: Doc = this.mainField.renderedDoc(); this.contentFields.forEach(field => { @@ -83,6 +77,12 @@ export class Template { }); }; + resetToBase = () => { + this.allFields.forEach(field => { + field.updateRenderedDoc(); + }) + } + isValidTemplate = (cols: Col[]) => { const matches: number[][] = this.getMatches(cols); const maxMatches: number = this.maxMatches(matches); -- cgit v1.2.3-70-g09d2