From 45e3384b31ed2816e6846c2ff545fe55dc155339 Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Tue, 23 Jun 2020 16:41:07 -0500 Subject: minor changes --- .../views/collections/CollectionSchemaCells.tsx | 33 +++++++++--- .../views/collections/CollectionSchemaHeaders.tsx | 10 ++++ .../views/collections/CollectionSchemaView.scss | 4 ++ .../views/collections/CollectionSchemaView.tsx | 63 +++++++++++++++------- 4 files changed, 85 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx index 6f43a2097..a79360a20 100644 --- a/src/client/views/collections/CollectionSchemaCells.tsx +++ b/src/client/views/collections/CollectionSchemaCells.tsx @@ -94,6 +94,7 @@ export class CollectionSchemaCell extends React.Component { @action onPointerDown = async (e: React.PointerEvent): Promise => { + this.props.changeFocusedCellByIndex(this.props.row, this.props.col); this.props.setPreviewDoc(this.props.rowProps.original); @@ -239,10 +240,14 @@ export class CollectionSchemaCell extends React.Component { // ); trace(); + + return (
+ + { height={"auto"} maxHeight={Number(MAX_ROW_HEIGHT)} GetValue={() => { - const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); - const cscript = cfield instanceof ComputedField ? cfield.script.originalScript : undefined; - const cfinalScript = cscript?.split("return")[cscript.split("return").length - 1]; - const val = cscript !== undefined ? `:=${cfinalScript?.substring(0, cfinalScript.length - 2)}` : - Field.IsField(cfield) ? Field.toScriptString(cfield) : ""; - return val; + if (type === "number" && (contents === 0 || contents === "0")) { + return "0"; + } else { + const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); + console.log(cfield); + if (type === "number") { + return StrCast(cfield); + } + const cscript = cfield instanceof ComputedField ? cfield.script.originalScript : undefined; + const cfinalScript = cscript?.split("return")[cscript.split("return").length - 1]; + const val = cscript !== undefined ? `:=${cfinalScript?.substring(0, cfinalScript.length - 2)}` : + Field.IsField(cfield) ? Field.toScriptString(cfield) : ""; + return val; + } + }} SetValue={action((value: string) => { let retVal = false; + if (value.startsWith(":=")) { retVal = this.props.setComputed(value.substring(2), props.Document, this.props.rowProps.column.id!, this.props.row, this.props.col); } else { const script = CompileScript(value, { requiredType: type, typecheck: false, editable: true, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } }); if (script.compiled) { retVal = this.applyToDoc(props.Document, this.props.row, this.props.col, script.run); + console.log("compiled"); } + } if (retVal) { this._isEditing = false; // need to set this here. otherwise, the assignment of the field will invalidate & cause render() to be called with the wrong value for 'editing' this.props.setIsEditing(false); } return retVal; + + //return true; })} OnFillDown={async (value: string) => { const script = CompileScript(value, { requiredType: type, typecheck: false, editable: true, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } }); @@ -284,6 +303,8 @@ export class CollectionSchemaCell extends React.Component { } }} /> + +
{/* {fieldIsDoc ? docExpander : null} */}
diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx index 0d6cf4474..d9a27f355 100644 --- a/src/client/views/collections/CollectionSchemaHeaders.tsx +++ b/src/client/views/collections/CollectionSchemaHeaders.tsx @@ -73,6 +73,16 @@ export class CollectionSchemaAddColumnHeader extends React.Component { private DIVIDER_WIDTH = 4; @@ -320,19 +316,48 @@ export class SchemaTable extends React.Component { } const cols = this.columns.map(col => { - const header = c.heading)} - keyType={this.getColumnType(col)} - typeConst={columnTypes.get(col.heading) !== undefined} - onSelect={this.changeColumns} - setIsEditing={this.setHeaderIsEditing} - deleteColumn={this.deleteColumn} - setColumnType={this.setColumnType} - setColumnSort={this.setColumnSort} - setColumnColor={this.setColumnColor} - />; + + const icon: IconProp = this.getColumnType(col) === ColumnType.Number ? "hashtag" : this.getColumnType(col) === ColumnType.String ? "font" : + this.getColumnType(col) === ColumnType.Boolean ? "check-square" : this.getColumnType(col) === ColumnType.Doc ? "file" : + this.getColumnType(col) === ColumnType.Image ? "image" : this.getColumnType(col) === ColumnType.List ? "list-ul" : "align-justify"; + + + + const header =
+ c.heading)} + // keyType={this.getColumnType(col)} + typeConst={columnTypes.get(col.heading) !== undefined} + menuButtonContent={
{col.heading}
} + addNew={false} + onSelect={this.changeColumns} + setIsEditing={this.setHeaderIsEditing} + deleteColumn={this.deleteColumn} + onlyShowOptions={false} + setColumnType={this.setColumnType} + setColumnSort={this.setColumnSort} + setColumnColor={this.setColumnColor} + /> +
; + + + // c.heading)} + // keyType={this.getColumnType(col)} + // typeConst={columnTypes.get(col.heading) !== undefined} + // onSelect={this.changeColumns} + // setIsEditing={this.setHeaderIsEditing} + // deleteColumn={this.deleteColumn} + // setColumnType={this.setColumnType} + // setColumnSort={this.setColumnSort} + // setColumnColor={this.setColumnColor} + // />; + return { Header: , -- cgit v1.2.3-70-g09d2