From afd1b40f79ce284b66e95866f4dae637e19411c5 Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Thu, 12 Oct 2023 21:38:04 +0200 Subject: [PATCH 1/2] :sparkles: Add link/unlink button for the subtitle in the chart admin --- adminSiteClient/ChartEditorPage.tsx | 2 +- adminSiteClient/EditorTextTab.tsx | 8 +- adminSiteClient/Forms.tsx | 177 ++++++++++++++---- .../grapher/src/core/Grapher.tsx | 6 +- 4 files changed, 150 insertions(+), 43 deletions(-) diff --git a/adminSiteClient/ChartEditorPage.tsx b/adminSiteClient/ChartEditorPage.tsx index ae89940a5e5..8a7f40abeb9 100644 --- a/adminSiteClient/ChartEditorPage.tsx +++ b/adminSiteClient/ChartEditorPage.tsx @@ -238,7 +238,7 @@ export class ChartEditorPage // these may point to non-existent details e.g. ["not_a_real_term", "pvotery"] @computed get currentDetailReferences() { return { - subtitle: extractDetailsFromSyntax(this.grapher.subtitle), + subtitle: extractDetailsFromSyntax(this.grapher.currentSubtitle), note: extractDetailsFromSyntax(this.grapher.note), } } diff --git a/adminSiteClient/EditorTextTab.tsx b/adminSiteClient/EditorTextTab.tsx index 9161fb4e2c6..be974204886 100644 --- a/adminSiteClient/EditorTextTab.tsx +++ b/adminSiteClient/EditorTextTab.tsx @@ -17,6 +17,7 @@ import { ChartEditor } from "./ChartEditor.js" import { AutoTextField, BindAutoString, + BindAutoStringExt, BindString, Button, RadioGroup, @@ -155,8 +156,11 @@ export class EditorTextTab extends React.Component<{ editor: ChartEditor }> { } helpText="Human-friendly URL for this chart" /> - g.currentSubtitle} + writeFn={(g, newVal) => (g.subtitle = newVal)} + isAuto={grapher.subtitle === undefined} store={grapher} placeholder="Briefly describe the context of the data. It's best to avoid duplicating any information which can be easily inferred from other visual elements of the chart." textarea diff --git a/adminSiteClient/Forms.tsx b/adminSiteClient/Forms.tsx index b1087093b12..5c744264eba 100644 --- a/adminSiteClient/Forms.tsx +++ b/adminSiteClient/Forms.tsx @@ -192,14 +192,29 @@ export class TextAreaField extends React.Component { )} )} -