From 8cc8c972c73ea52e6be3d6dc25d9abc6905327df Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Tue, 19 Mar 2024 17:49:44 -0400
Subject: routing select through selectCell; shift select kind of working; cell
 selection updating still broken; cell select with shift select broken

---
 .../collectionSchema/SchemaTableCell.tsx           | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

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

diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index 85b3158a8..2769b5042 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -4,7 +4,7 @@ import { extname } from 'path';
 import * as React from 'react';
 import DatePicker from 'react-datepicker';
 import Select from 'react-select';
-import { Utils, emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnZero } from '../../../../Utils';
+import { Utils, emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, returnZero } from '../../../../Utils';
 import { DateField } from '../../../../fields/DateField';
 import { Doc, DocListCast, Field } from '../../../../fields/Doc';
 import { RichTextField } from '../../../../fields/RichTextField';
@@ -35,8 +35,8 @@ export interface SchemaTableCellProps {
     Document: Doc;
     col: number;
     deselectCell: () => void;
-    selectCell: (doc: Doc, col: number) => void;
-    selectedCell: () => [Doc[], number] | undefined;
+    selectCell: (doc: Doc, col: number, shift: boolean) => void;
+    selectedCells: () => [Doc[], number] | undefined;
     fieldKey: string;
     maxWidth?: () => number;
     columnWidth: () => number;
@@ -76,7 +76,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
             doc = DocCast(doc.proto);
         }
         const parenCount = Math.max(0, protoCount - 1);
-        const color = protoCount === 0 || (fieldKey.startsWith('_') && Document[fieldKey] === undefined) ? 'black' : 'blue';
+        const color = protoCount === 0 || (fieldKey.startsWith('_') && Document[fieldKey] === undefined) ? 'black' : 'blue'; //color of text in cells
         const textDecoration = color !== 'black' && parenCount ? 'underline' : '';
         const fieldProps: FieldViewProps = {
             childFilters: returnEmptyFilter,
@@ -107,8 +107,10 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
     }
 
     @computed get selected() {
-        const selected = this._props.selectedCell();
-        return this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
+        const selected = this._props.selectedCells();
+        let istrue = this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
+        //console.log("col: " + this._props.col + "true: " + istrue);
+        return istrue;
     }
 
     @computed get defaultCellContent() {
@@ -177,7 +179,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
         return (
             <div
                 className="schema-table-cell"
-                onPointerDown={action(e => !this.selected && this._props.selectCell(this._props.Document, this._props.col))}
+                onPointerDown={action(e => !this.selected && this._props.selectCell(this._props.Document, this._props.col, e.shiftKey))}
                 style={{ padding: this._props.padding, maxWidth: this._props.maxWidth?.(), width: this._props.columnWidth() || undefined, border: this.selected ? `solid 2px ${Colors.MEDIUM_BLUE}` : undefined }}>
                 {this.content}
             </div>
@@ -309,7 +311,7 @@ export class SchemaRTFCell extends ObservableReactComponent<SchemaTableCellProps
     }
 
     @computed get selected() {
-        const selected = this._props.selectedCell();
+        const selected = this._props.selectedCells();
         return this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
         //return this._props.isRowActive() && selected?.[0] === this._props.Document && selected[1] === this._props.col;
     }
@@ -332,7 +334,7 @@ export class SchemaBoolCell extends ObservableReactComponent<SchemaTableCellProp
     }
 
     @computed get selected() {
-        const selected = this._props.selectedCell();
+        const selected = this._props.selectedCells();
         return this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
     }
     render() {
@@ -376,7 +378,7 @@ export class SchemaEnumerationCell extends ObservableReactComponent<SchemaTableC
     }
 
     @computed get selected() {
-        const selected = this._props.selectedCell();
+        const selected = this._props.selectedCells();
         return this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
     }
     render() {
-- 
cgit v1.2.3-70-g09d2

