From 4a0686ca3db91cf6e2c984c53f1ad4f2fea8de8b Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 17 Nov 2022 16:28:01 -0500
Subject: more cleanup to addDocTab.  fixed pile views to show proper icons
 instead of loading document label icons

---
 .../collectionFreeForm/CollectionFreeFormView.tsx  | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

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

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 8cabf060d..56a5c3dcc 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1330,17 +1330,23 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
         );
     }
     addDocTab = action((doc: Doc, where: OpenWhere) => {
-        if (where === OpenWhere.inParent) {
-            (doc instanceof Doc ? [doc] : doc).forEach(doc => {
-                const pt = this.getTransform().transformPoint(NumCast(doc.x), NumCast(doc.y));
-                doc.x = pt[0];
-                doc.y = pt[1];
-            });
-            return this.props.addDocument?.(doc) || false;
-        }
-        if (where === OpenWhere.inPlace && this.layoutDoc.isInPlaceContainer) {
-            this.dataDoc[this.props.fieldKey] = doc instanceof Doc ? doc : new List<Doc>(doc as any as Doc[]);
-            return true;
+        switch (where) {
+            case OpenWhere.inParent:
+                return (
+                    this.props.addDocument?.(
+                        (doc instanceof Doc ? [doc] : doc).map(doc => {
+                            const pt = this.getTransform().transformPoint(NumCast(doc.x), NumCast(doc.y));
+                            doc.x = pt[0];
+                            doc.y = pt[1];
+                            return doc;
+                        })
+                    ) || false
+                );
+            case OpenWhere.inPlace:
+                if (this.layoutDoc.isInPlaceContainer) {
+                    this.dataDoc[this.props.fieldKey] = new List<Doc>(doc instanceof Doc ? [doc] : doc);
+                    return true;
+                }
         }
         return this.props.addDocTab(doc, where);
     });
-- 
cgit v1.2.3-70-g09d2

