From c5c7fa9c0b17bbcee582d4fd788d378a2f7cd243 Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Sun, 14 Jun 2020 12:54:38 -0500 Subject: adding list and image types --- .../views/collections/CollectionSchemaCells.tsx | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'src/client/views/collections/CollectionSchemaCells.tsx') diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx index baf9d4156..4f2bfac08 100644 --- a/src/client/views/collections/CollectionSchemaCells.tsx +++ b/src/client/views/collections/CollectionSchemaCells.tsx @@ -24,6 +24,7 @@ import { SchemaHeaderField } from "../../../fields/SchemaHeaderField"; import { undoBatch } from "../../util/UndoManager"; import { SnappingManager } from "../../util/SnappingManager"; import { ComputedField } from "../../../fields/ScriptField"; +import { ImageField } from "../../../fields/URLField"; library.add(faExpand); @@ -205,6 +206,18 @@ export class CollectionSchemaCell extends React.Component { const doc = FieldValue(Cast(field, Doc)); contents = typeof field === "object" ? doc ? StrCast(doc.title) === "" ? "--" : StrCast(doc.title) : `--${typeof field}--` : `--${typeof field}--`; } + if (type === "image") { + // fix this + + const image = FieldValue(Cast(field, ImageField)); + const doc = FieldValue(Cast(field, Doc)); + contents = typeof field === "object" ? doc ? StrCast(doc.title) === "" ? "--" : StrCast(doc.title) : `--${typeof field}--` : `--${typeof field}--`; + } + if (type === "list") { + // fix this + contents = typeof field === "object" ? doc ? StrCast(field) === "" ? "--" : StrCast(field) : `--${typeof field}--` : `--${typeof field}--`; + } + let className = "collectionSchemaView-cellWrapper"; if (this._isEditing) className += " editing"; @@ -304,6 +317,71 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell { } } +@observer +export class CollectionSchemaImageCell extends CollectionSchemaCell { + render() { + return this.renderCellWithType("image"); + } + // render() { + // const props: FieldViewProps = { + // Document: this.props.rowProps.original, + // DataDoc: this.props.rowProps.original, + // LibraryPath: [], + // dropAction: "alias", + // bringToFront: emptyFunction, + // rootSelected: returnFalse, + // fieldKey: this.props.rowProps.column.id as string, + // ContainingCollectionView: this.props.CollectionView, + // ContainingCollectionDoc: this.props.CollectionView && this.props.CollectionView.props.Document, + // isSelected: returnFalse, + // select: emptyFunction, + // renderDepth: this.props.renderDepth + 1, + // ScreenToLocalTransform: Transform.Identity, + // focus: emptyFunction, + // active: returnFalse, + // whenActiveChanged: emptyFunction, + // PanelHeight: returnZero, + // PanelWidth: returnZero, + // NativeHeight: returnZero, + // NativeWidth: returnZero, + // addDocTab: this.props.addDocTab, + // pinToPres: this.props.pinToPres, + // ContentScaling: returnOne + // }; + + // if (props.fieldKey === "data") { + // const reference = React.createRef(); + // return ( + //
+ //
+ // {props.DataDoc?.data} + //
+ //
+ // ); + // } else { + // return this.renderCellWithType("image"); + // } + // } +} + +@observer +export class CollectionSchemaListCell extends CollectionSchemaCell { + render() { + return this.renderCellWithType("list"); + } + + // render() { + // const reference = React.createRef(); + // return ( + //
+ //
+ // + //
+ //
+ // ); + // } +} + @observer export class CollectionSchemaCheckboxCell extends CollectionSchemaCell { @observable private _isChecked: boolean = typeof this.props.rowProps.original[this.props.rowProps.column.id as string] === "boolean" ? BoolCast(this.props.rowProps.original[this.props.rowProps.column.id as string]) : false; -- cgit v1.2.3-70-g09d2