From 966c93e3a5b70e5e579b4b67061c859df1ac357d Mon Sep 17 00:00:00 2001
From: srichman333 <sarah_n_richman@brown.edu>
Date: Mon, 4 Dec 2023 16:00:53 -0500
Subject: default keys bug fix + image to drag

---
 .../collections/collectionFreeForm/CollectionFreeFormView.tsx      | 7 ++++---
 1 file changed, 4 insertions(+), 3 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 19689f972..3a1ea766a 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1976,9 +1976,10 @@ ScriptingGlobals.add(function sendToBack(doc: Doc) {
 });
 ScriptingGlobals.add(function datavizFromSchema(doc: Doc) {
     SelectionManager.Views().forEach(view => {
-        const keys = Cast(view.rootDoc.schema_columnKeys, listSpec('string'))?.filter(key => key!="text");
-       
-        if (!keys) return;
+        var keys = Cast(view.layoutDoc.schema_columnKeys, listSpec('string'))?.filter(key => key!="text");
+        const defaultColumnKeys: string[] = ['title', 'type', 'author', 'author_date'];
+        if (!keys) keys = Cast(view.layoutDoc.schema_columnKeys, listSpec('string'), defaultColumnKeys);;
+
         const children = DocListCast(view.rootDoc[Doc.LayoutFieldKey(view.rootDoc)]);
         let csvRows = [];
         csvRows.push(keys.join(','));
-- 
cgit v1.2.3-70-g09d2

