From bf8a62fbb1b70bc013ec2f342930f35d6108065b Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sun, 13 Sep 2020 04:29:37 -0400
Subject: fixed making delegates of custom headerViews.  fixed non-responsive
 carriage returns in textBoxes occasionally at the end of the text stream. 
 fixed upating titles on templated text boxes.   fixed setting layoutfield
 values in DashFieldViews to update the template and layout doc.

---
 .../views/nodes/formattedText/DashFieldView.tsx    | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

(limited to 'src/client/views/nodes/formattedText/DashFieldView.tsx')

diff --git a/src/client/views/nodes/formattedText/DashFieldView.tsx b/src/client/views/nodes/formattedText/DashFieldView.tsx
index f14a57e31..0332bb4fd 100644
--- a/src/client/views/nodes/formattedText/DashFieldView.tsx
+++ b/src/client/views/nodes/formattedText/DashFieldView.tsx
@@ -1,5 +1,5 @@
 import { IReactionDisposer, observable, runInAction, computed, action } from "mobx";
-import { Doc, DocListCast, Field } from "../../../../fields/Doc";
+import { Doc, DocListCast, Field, LayoutSym } from "../../../../fields/Doc";
 import { List } from "../../../../fields/List";
 import { listSpec } from "../../../../fields/Schema";
 import { SchemaHeaderField } from "../../../../fields/SchemaHeaderField";
@@ -70,7 +70,7 @@ export class DashFieldViewInternal extends React.Component<IDashFieldViewInterna
             DocServer.GetRefField(this.props.docid).
                 then(action(async dashDoc => dashDoc instanceof Doc && (this._dashDoc = dashDoc)));
         } else {
-            this._dashDoc = this.props.tbox.props.DataDoc || this.props.tbox.dataDoc;
+            this._dashDoc = this.props.tbox.rootDoc;
         }
     }
     componentWillUnmount() {
@@ -92,7 +92,10 @@ export class DashFieldViewInternal extends React.Component<IDashFieldViewInterna
                 return <input
                     className="dashFieldView-fieldCheck"
                     type="checkbox" checked={boolVal}
-                    onChange={e => this._dashDoc![this._fieldKey] = e.target.checked}
+                    onChange={e => {
+                        if (this._fieldKey.startsWith("_")) Doc.Layout(this._textBoxDoc)[this._fieldKey] = e.target.checked;
+                        this._dashDoc![this._fieldKey] = e.target.checked;
+                    }}
                 />;
             }
             else // field value is a string, so display it as an editable span
@@ -159,9 +162,16 @@ export class DashFieldViewInternal extends React.Component<IDashFieldViewInterna
                 } else if (nodeText.startsWith("=:=")) {
                     Doc.Layout(this._textBoxDoc)[this._fieldKey] = ComputedField.MakeFunction(nodeText.substring(3));
                 } else {
-                    const splits = newText.split(this.multiValueDelimeter);
-                    if (this._fieldKey !== "PARAMS" || !this._textBoxDoc[this._fieldKey] || this._dashDoc?.PARAMS) {
-                        this._dashDoc![this._fieldKey] = splits.length > 1 ? new List<string>(splits) : newText;
+                    if (Number(newText).toString() === newText) {
+                        if (this._fieldKey.startsWith("_")) Doc.Layout(this._textBoxDoc)[this._fieldKey] = Number(newText);
+                        this._dashDoc![this._fieldKey] = Number(newText);
+                    } else {
+                        const splits = newText.split(this.multiValueDelimeter);
+                        if (this._fieldKey !== "PARAMS" || !this._textBoxDoc[this._fieldKey] || this._dashDoc?.PARAMS) {
+                            const strVal = splits.length > 1 ? new List<string>(splits) : newText;
+                            if (this._fieldKey.startsWith("_")) Doc.Layout(this._textBoxDoc)[this._fieldKey] = strVal;
+                            this._dashDoc![this._fieldKey] = strVal;
+                        }
                     }
                 }
             });
-- 
cgit v1.2.3-70-g09d2

