From 22152c38c3e1485c107b321f1ce3894e87c0226f Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Fri, 21 Jun 2024 01:57:54 -0400
Subject: refactor

---
 .../collectionSchema/CollectionSchemaView.tsx            | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

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

diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 5c8a84163..992ee2ec9 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -101,8 +101,8 @@ export class CollectionSchemaView extends CollectionSubView() {
     @observable _colBeingDragged: boolean = false;
     @observable _colKeysFiltered: boolean = false;
     @observable _cellTags: ObservableMap = new ObservableMap<Doc, Array<string>>();
-    @observable _highlightedCells: Array<HTMLDivElement> = [];
-    @observable _cellHighlightColors: ObservableMap = new ObservableMap<HTMLDivElement, string[]>();
+    @observable _highlightedCells: Array<[doc: Doc, field: string]> = [];
+    @observable _cellHighlightColors: ObservableMap = new ObservableMap<[doc: Doc, field: string], string[]>();
     @observable _docs: Doc[] = [];
     
     // target HTMLelement portal for showing a popup menu to edit cell values.
@@ -290,7 +290,7 @@ export class CollectionSchemaView extends CollectionSubView() {
                     break;
                 }
                 case 'P': {
-                    this.highlightSortedColumn();
+                    console.log(this._cellHighlightColors)
                     break;
                 }
                 default:
@@ -551,14 +551,17 @@ export class CollectionSchemaView extends CollectionSubView() {
         matches.forEach((match: Match) => {
             const {docRef, field} = match;
             const doc = DocumentManager.Instance.DocumentViews[Number(docRef)].Document;
-            if (this.columnKeys.includes(field)) {cells.push(this.getCellElement(doc, field))}
+            if (this.columnKeys.includes(field)) {cells.push([doc, field])}
         })
 
         return cells;
     }
 
     removeCellHighlights = () => {
-        this._highlightedCells.forEach(cell => {cell.style.border = ''; cell.style.backgroundColor = '';});
+        this._highlightedCells.forEach(info => {
+            const cell = this.getCellElement(info[0], info[1]);
+            cell.style.border = ''; cell.style.backgroundColor = '';
+        });
         this._highlightedCells = [];
     }
 
@@ -580,8 +583,9 @@ export class CollectionSchemaView extends CollectionSubView() {
 
         const cellsToHighlight = this.findCellRefs(text);
         this._highlightedCells = [...cellsToHighlight];
-        this._highlightedCells.forEach(cell => {
+        this._highlightedCells.forEach(info => {
             const color = randomRGBColor();
+            const cell = this.getCellElement(info[0], info[1]);
             if (!this._cellHighlightColors.has(cell)) {this._cellHighlightColors.set(cell, new Array<string>(`solid 2px ${color[0]}`, color[1]))}
             cell.style.border = this._cellHighlightColors.get(cell)[0];
             cell.style.backgroundColor = this._cellHighlightColors.get(cell)[1];
-- 
cgit v1.2.3-70-g09d2

