From b0d3aa2fff87cdaeb4308c278b248f2d11cc043e Mon Sep 17 00:00:00 2001
From: anika-ahluwalia <anika.ahluwalia@gmail.com>
Date: Thu, 18 Jun 2020 15:27:01 -0500
Subject: doc opening button

---
 src/client/views/collections/CollectionSchemaCells.tsx | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

(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 df2a90366..2aed880ec 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -364,7 +364,9 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
         if (results && results.success) {
 
             console.log(results.result);
-            // this._docTitle = results.result;
+            this._doc = results.result;
+            this.prop.Document[this.prop.fieldKey] = results.result;
+            this._docTitle = this._doc?.title;
 
             return true;
         }
@@ -378,18 +380,26 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
         this._overlayDisposer = OverlayView.Instance.addElement(<DocumentIconContainer />, { x: 0, y: 0 });
     }
 
+    onOpenClick = () => {
+        if (this._doc) {
+            this.prop.addDocTab(this._doc, "onRight");
+            return true;
+        }
+        return false;
+    }
+
 
     render() {
 
         const dragRef: React.RefObject<HTMLDivElement> = React.createRef();
         const reference = React.createRef<HTMLDivElement>();
 
-        if (typeof this._field === "object" && this._docTitle) {
+        if (typeof this._field === "object" && this._doc && this._docTitle) {
 
 
             return (
                 <div className="collectionSchemaView-cellWrapper" ref={this._focusRef} tabIndex={-1} onPointerDown={this.onPointerDown}>
-                    <div className="collectionSchemaView-cellContents"
+                    <div className="collectionSchemaView-cellContents-document"
                         style={{ padding: "5.9px" }}
                         onFocus={this.onFocus} onBlur={() => this._overlayDisposer?.()}
                         ref={this.dropRef}>
@@ -409,6 +419,8 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
                             })}
                         />
                     </div >
+                    <button onClick={this.onOpenClick} className="collectionSchemaView-cellContents-docButton">
+                        <FontAwesomeIcon icon="external-link-alt" size="1x" ></FontAwesomeIcon> </button>
                 </div>
             );
         } else {
-- 
cgit v1.2.3-70-g09d2

