From 3b8e60f743ccf4a8f2e2a68462a852664e922a1e Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Thu, 18 Jun 2020 00:09:27 -0500 Subject: slight restructure of doc type --- .../views/collections/CollectionSchemaCells.tsx | 124 +++++++++++++++++---- 1 file changed, 102 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx index 33b6e7bec..2d29f978c 100644 --- a/src/client/views/collections/CollectionSchemaCells.tsx +++ b/src/client/views/collections/CollectionSchemaCells.tsx @@ -29,6 +29,7 @@ import { List } from "../../../fields/List"; import { LinkBox } from "../nodes/LinkBox"; import { OverlayView } from "../OverlayView"; import { DocumentIconContainer } from "../nodes/DocumentIcon"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; const path = require('path'); library.add(faExpand); @@ -314,8 +315,102 @@ export class CollectionSchemaStringCell extends CollectionSchemaCell { @observer export class CollectionSchemaDocCell extends CollectionSchemaCell { + + _overlayDisposer?: () => void; + + private prop: 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 + }; + @observable private _field = this.prop.Document[this.prop.fieldKey]; + @observable private _text = "this._field"; + + + @action + onSetValue = (value: string) => { + this._text = value; + //this.prop.Document[this.prop.fieldKey] = this._text; + + const script = CompileScript(value, { + addReturn: true, + typecheck: false, + transformer: DocumentIconContainer.getTransformer() + }); + const results = script.compiled && script.run(); + if (results && results.success) { + + this._text = results.result; + + return true; + } + return false; + } + + onFocus = () => { + + console.log(this._field); + this._overlayDisposer?.(); + this._overlayDisposer = OverlayView.Instance.addElement(, { x: 0, y: 0 }); + } + + render() { - return this.renderCellWithType("document"); + + const dragRef: React.RefObject = React.createRef(); + const reference = React.createRef(); + + if (typeof this._field === "object" && this._text) { + + + return ( +
+
this._overlayDisposer?.()} + ref={this.dropRef}> + { + const val = this._text ? this._text : ""; + return StrCast(val); + }} + SetValue={action((value: string) => { + this.onSetValue(value); + return true; + })} + /> +
+
+ ); + } else { + return this.renderCellWithType("document"); + } } } @@ -489,28 +584,11 @@ export class CollectionSchemaListCell extends CollectionSchemaCell { let type = "list"; - // const fieldIsDoc = (type === "document" && typeof this._field === "object") || (typeof this._field === "object" && document); - - // const onItemDown = (e: React.PointerEvent) => { - // fieldIsDoc && SetupDrag(this._focusRef, - // () => this._document[this.prop.fieldKey] instanceof Doc ? this._document[this.prop.fieldKey] : this._document, - // this._document[this.prop.fieldKey] instanceof Doc ? (doc: Doc | Doc[], target: Doc | undefined, addDoc: (newDoc: Doc | Doc[]) => any) => addDoc(doc) : this.props.moveDocument, - // this._document[this.prop.fieldKey] instanceof Doc ? "alias" : this.props.Document.schemaDoc ? "copy" : undefined)(e); - // }; - // const onPointerEnter = (e: React.PointerEvent): void => { - // if (e.buttons === 1 && SnappingManager.GetIsDragging() && (type === "document" || type === undefined)) { - // dragRef.current!.className = "collectionSchemaView-cellContainer doc-drag-over"; - // } - // }; - // const onPointerLeave = (e: React.PointerEvent): void => { - // dragRef.current!.className = "collectionSchemaView-cellContainer"; - // }; - let link = false; let doc = false; const reference = React.createRef(); - if (typeof this._field === "object" && this._optionsList[1]) { + if (typeof this._field === "object" && this._optionsList[0]) { const options = this._optionsList.map((element, index) => { @@ -538,7 +616,7 @@ export class CollectionSchemaListCell extends CollectionSchemaCell { } }); - const plainText =
{this._text}
; + const plainText =
{this._text}
; // const textarea = ; const textarea =
; + //☰ const dropdown =
{options} @@ -578,7 +657,8 @@ export class CollectionSchemaListCell extends CollectionSchemaCell {
{link ? plainText : textarea}
-- cgit v1.2.3-70-g09d2