aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSchemaCells.tsx
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2019-07-27 17:03:20 -0400
committerFawn <fangrui_tong@brown.edu>2019-07-27 17:03:20 -0400
commit905d77804bf9a810822e5e43f0cd06019aef7620 (patch)
treedca88255cf86fbd071e485334daa0689c3238742 /src/client/views/collections/CollectionSchemaCells.tsx
parenta53d76d28750b03744727f2646313bccb120dbcb (diff)
schema headers changed to schemaheaderfields, a bug with udpating the headers (in CollectionSchemaView>ChangeColumn)
Diffstat (limited to 'src/client/views/collections/CollectionSchemaCells.tsx')
-rw-r--r--src/client/views/collections/CollectionSchemaCells.tsx30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 4a618a436..c91f1017b 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -21,7 +21,12 @@ import { NumCast, StrCast, BoolCast, FieldValue, Cast } from "../../../new_field
import { Docs } from "../../documents/Documents";
import { DocumentContentsView } from "../nodes/DocumentContentsView";
import { SelectionManager } from "../../util/SelectionManager";
+import { library } from '@fortawesome/fontawesome-svg-core';
+import { faExpand } from '@fortawesome/free-solid-svg-icons';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { SchemaHeaderField, RandomPastel } from "../../../new_fields/SchemaHeaderField";
+library.add(faExpand);
export interface CellProps {
row: number;
@@ -38,6 +43,7 @@ export interface CellProps {
changeFocusedCellByIndex: (row: number, col: number) => void;
setIsEditing: (isEditing: boolean) => void;
isEditable: boolean;
+ setPreviewDoc: (doc: Doc) => void;
}
@observer
@@ -92,7 +98,7 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
this._document[fieldKey] = de.data.draggedDocuments[0];
}
else {
- let coll = Docs.Create.SchemaDocument(["title"], de.data.draggedDocuments, {});
+ let coll = Docs.Create.SchemaDocument([new SchemaHeaderField("title")], de.data.draggedDocuments, {});
this._document[fieldKey] = coll;
}
e.stopPropagation();
@@ -106,6 +112,18 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
}
}
+ expandDoc = (e: React.PointerEvent) => {
+ let field = this.props.rowProps.original[this.props.rowProps.column.id as string];
+ let doc = FieldValue(Cast(field, Doc));
+
+ console.log("Expanding doc", StrCast(doc!.title));
+ this.props.setPreviewDoc(doc!);
+
+ // this.props.changeFocusedCellByIndex(this.props.row, this.props.col);
+
+ e.stopPropagation();
+ }
+
renderCellWithType(type: string | undefined) {
let dragRef: React.RefObject<HTMLDivElement> = React.createRef();
@@ -157,6 +175,15 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
if (this.props.isFocused && this.props.isEditable) className += " focused";
if (this.props.isFocused && !this.props.isEditable) className += " inactive";
+ let doc = FieldValue(Cast(field, Doc));
+ if (type === "document") console.log("doc", typeof field);
+ let fieldIsDoc = (type === "document" && typeof field === "object") || (typeof field === "object" && doc);
+ let docExpander = (
+ <div className="collectionSchemaView-cellContents-docExpander" onPointerDown={this.expandDoc} >
+ <FontAwesomeIcon icon="expand" size="sm" />
+ </div>
+ );
+
return (
<div className="collectionSchemaView-cellContainer" ref={dragRef} onPointerDown={this.onPointerDown} onPointerEnter={onPointerEnter} onPointerLeave={onPointerLeave}>
<div className={className} ref={this._focusRef} tabIndex={-1}>
@@ -193,6 +220,7 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
val && val.forEach(doc => this.applyToDoc(doc, run));
}} />
</div >
+ {fieldIsDoc ? docExpander : null}
</div>
</div>
);