From d9d32abedf7163a2683798879e668dc92966caa6 Mon Sep 17 00:00:00 2001
From: madelinegr <laura_wilson@brown.edu>
Date: Sat, 2 Mar 2019 17:37:19 -0500
Subject: delete is working

---
 src/client/views/collections/CollectionTreeView.tsx | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

(limited to 'src/client/views/collections/CollectionTreeView.tsx')

diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index b075737d2..bb1b49f4f 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -32,8 +32,10 @@ class TreeView extends React.Component<TreeViewProps> {
     @observable
     collapsed: boolean = false;
 
-    delete() {
-        this.props.deleteDoc;
+    delete = () => {
+        if (this) {
+            this.props.deleteDoc(this.props.document);
+        }
     }
 
     renderBullet(type: BulletType) {
@@ -126,6 +128,14 @@ class TreeView extends React.Component<TreeViewProps> {
 @observer
 export class CollectionTreeView extends CollectionViewBase {
 
+    @action
+    remove(document: Document) {
+        var children = this.props.Document.GetT<ListField<Document>>(KeyStore.Data, ListField);
+        if (children && children !== FieldWaiting) {
+            children.Data.splice(children.Data.indexOf(document), 1);
+        }
+    }
+
     render() {
         let titleStr = "";
         let title = this.props.Document.GetT<TextField>(KeyStore.Title, TextField);
@@ -136,7 +146,7 @@ export class CollectionTreeView extends CollectionViewBase {
         var children = this.props.Document.GetT<ListField<Document>>(KeyStore.Data, ListField);
         let childrenElement = !children || children === FieldWaiting ? (null) :
             (children.Data.map(value =>
-                <TreeView document={value} deleteDoc={() => console.log("test")} />)
+                <TreeView document={value} key={value.Id} deleteDoc={(value) => this.remove(value)} />)
             )
 
         return (
-- 
cgit v1.2.3-70-g09d2


From e67ea3e4df4af7b85c213baf2fc2fa0c695c3b8b Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Sat, 2 Mar 2019 22:46:48 -0500
Subject: Minor fixes

---
 .../views/collections/CollectionTreeView.tsx       | 31 ++++++++++++----------
 1 file changed, 17 insertions(+), 14 deletions(-)

(limited to 'src/client/views/collections/CollectionTreeView.tsx')

diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index bb1b49f4f..8b06d9ac4 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -33,8 +33,15 @@ class TreeView extends React.Component<TreeViewProps> {
     collapsed: boolean = false;
 
     delete = () => {
-        if (this) {
-            this.props.deleteDoc(this.props.document);
+        this.props.deleteDoc(this.props.document);
+    }
+
+
+    @action
+    remove = (document: Document) => {
+        var children = this.props.document.GetT<ListField<Document>>(KeyStore.Data, ListField);
+        if (children && children !== FieldWaiting) {
+            children.Data.splice(children.Data.indexOf(document), 1);
         }
     }
 
@@ -85,15 +92,14 @@ class TreeView extends React.Component<TreeViewProps> {
 
         // check if this document is a collection
         if (children && children !== FieldWaiting) {
-            var subView = null;
-
-            // render all children elements
-            let childrenElement = (children.Data.map(value =>
-                <TreeView document={value} deleteDoc={() => console.log("test")} />)
-            )
+            let subView;
 
             // if uncollapsed, then add the children elements
             if (!this.collapsed) {
+                // render all children elements
+                let childrenElement = (children.Data.map(value =>
+                    <TreeView document={value} deleteDoc={this.remove} />)
+                )
                 subView =
                     <li key={this.props.document.Id} >
                         {this.renderBullet(BulletType.Collapsible)}
@@ -129,7 +135,7 @@ class TreeView extends React.Component<TreeViewProps> {
 export class CollectionTreeView extends CollectionViewBase {
 
     @action
-    remove(document: Document) {
+    remove = (document: Document) => {
         var children = this.props.Document.GetT<ListField<Document>>(KeyStore.Data, ListField);
         if (children && children !== FieldWaiting) {
             children.Data.splice(children.Data.indexOf(document), 1);
@@ -146,7 +152,7 @@ export class CollectionTreeView extends CollectionViewBase {
         var children = this.props.Document.GetT<ListField<Document>>(KeyStore.Data, ListField);
         let childrenElement = !children || children === FieldWaiting ? (null) :
             (children.Data.map(value =>
-                <TreeView document={value} key={value.Id} deleteDoc={(value) => this.remove(value)} />)
+                <TreeView document={value} key={value.Id} deleteDoc={this.remove} />)
             )
 
         return (
@@ -154,10 +160,7 @@ export class CollectionTreeView extends CollectionViewBase {
                 <h3>
                     <EditableView contents={titleStr}
                         height={72} GetValue={() => {
-                            let title = this.props.Document.GetT<TextField>(KeyStore.Title, TextField);
-                            if (title && title !== "<Waiting>")
-                                return title.Data;
-                            return "";
+                            return this.props.Document.Title;
                         }} SetValue={(value: string) => {
                             this.props.Document.SetData(KeyStore.Title, value, TextField);
                             return true;
-- 
cgit v1.2.3-70-g09d2

