From 090093a50397ddc2a8fc2c50f5097f4a4ea8a74c Mon Sep 17 00:00:00 2001 From: Hannah Date: Thu, 7 Feb 2019 15:50:23 -0500 Subject: started adding editable schema cells --- src/views/collections/CollectionSchemaView.tsx | 29 ++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/views/collections') diff --git a/src/views/collections/CollectionSchemaView.tsx b/src/views/collections/CollectionSchemaView.tsx index 8817cb496..c7a3d81a4 100644 --- a/src/views/collections/CollectionSchemaView.tsx +++ b/src/views/collections/CollectionSchemaView.tsx @@ -11,6 +11,9 @@ import "./CollectionSchemaView.scss" import { ScrollBox } from "../../util/ScrollBox"; import { CollectionViewBase } from "./CollectionViewBase"; import { DocumentView } from "../nodes/DocumentView"; +import { EditableView } from "../EditableView"; +import { CompileScript } from "../../util/Scripting"; +import { Field } from "../../fields/Field"; @observer export class CollectionSchemaView extends CollectionViewBase { @@ -25,9 +28,29 @@ export class CollectionSchemaView extends CollectionViewBase { fieldKey: rowProps.value[1], DocumentViewForField: undefined } - return ( + let contents = ( ) + return ( + { + let field = props.doc.Get(props.fieldKey); + if (field && field instanceof Field) { + return field.ToScriptString(); + } + return field || ""; + }} SetValue={(value: string) => { + let script = CompileScript(value); + if (!script.compiled) { + return false; + } + let field = script(); + if (field instanceof Field) { + props.doc.Set(props.fieldKey, field); + return true; + } + return false; + }}> + ) } private getTrProps: ComponentPropsGetterR = (state, rowInfo) => { @@ -74,7 +97,9 @@ export class CollectionSchemaView extends CollectionViewBase { [KS.Title, KS.Data, KS.Author]) let content; if (this.selectedIndex != -1) { - content = () + content = ( + + ) } else { content =
} -- cgit v1.2.3-70-g09d2