From 03f9fd4beb2bd3efa8f88c71bdbaf52dbec82e66 Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Mon, 10 Jun 2024 14:56:42 -0400
Subject: sub-collection doc adding refactor complete except for small bug

---
 .../collectionSchema/SchemaColumnHeader.tsx        | 60 +++++++++++++++-------
 1 file changed, 41 insertions(+), 19 deletions(-)

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

diff --git a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
index 3719840ff..0da186f81 100644
--- a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
@@ -30,8 +30,6 @@ export interface SchemaColumnHeaderProps {
     columnKeys: string[];
     columnWidths: number[];
     columnIndex: number;
-    sortField: string;
-    sortDesc: boolean;
     schemaView: CollectionSchemaView;
     keysDropdown: React.JSX.Element;
     //cleanupField: (s: string) => string;
@@ -158,6 +156,46 @@ export class SchemaColumnHeader extends ObservableReactComponent<SchemaColumnHea
         return isDefault;
     }
 
+    get headerButton(){
+        const toRender = SchemaColumnHeader.isDefaultField(this.fieldKey) ? 
+        (<IconButton
+            icon={ <FontAwesomeIcon icon="trash" size='sm'/>}
+            size={Size.XSMALL}
+            color={'black'}
+            onPointerDown={e =>
+                setupMoveUpEvents(
+                    this,
+                    e,
+                    returnFalse,
+                    emptyFunction,
+                    undoable(clickEv => {
+                        clickEv.stopPropagation();
+                        this._props.schemaView.removeColumn(this._props.columnIndex);
+                    }, 'open column menu')
+                )
+            }
+        />)
+        : (<IconButton
+            icon={ <FontAwesomeIcon icon="caret-down" size='lg'/>}
+            size={Size.XSMALL}
+            color={'black'}
+            onPointerDown={e =>
+                setupMoveUpEvents(
+                    this,
+                    e,
+                    returnFalse,
+                    emptyFunction,
+                    undoable(clickEv => {
+                        clickEv.stopPropagation();
+                        this._props.openContextMenu(e.clientX, e.clientY, this._props.columnIndex)
+                    }, 'open column menu')
+                )
+            }
+        />)
+
+        return toRender;
+    }
+
     render() {
         return (
                 <div
@@ -177,23 +215,7 @@ export class SchemaColumnHeader extends ObservableReactComponent<SchemaColumnHea
 
                     <div className="schema-header-menu">
                         <div className="schema-header-button">
-                            <IconButton
-                            icon={ <FontAwesomeIcon icon="caret-down" size='lg'/>}
-                            size={Size.XSMALL}
-                            color={'black'}
-                            onPointerDown={e =>
-                                setupMoveUpEvents(
-                                    this,
-                                    e,
-                                    returnFalse,
-                                    emptyFunction,
-                                    undoable(clickEv => {
-                                        clickEv.stopPropagation();
-                                        this._props.openContextMenu(e.clientX, e.clientY, this._props.columnIndex)
-                                    }, 'open column menu')
-                                )
-                            }
-                        />
+                            {this.headerButton}
                         </div>
                     </div>  
                 </div>
-- 
cgit v1.2.3-70-g09d2

