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 ++++++++++------ .../views/collections/collectionSchema/SchemaRowBox.tsx | 8 +++++++- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src') 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>(); - @observable _highlightedCells: Array = []; - @observable _cellHighlightColors: ObservableMap = new ObservableMap(); + @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(`solid 2px ${color[0]}`, color[1]))} cell.style.border = this._cellHighlightColors.get(cell)[0]; cell.style.backgroundColor = this._cellHighlightColors.get(cell)[1]; diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx index c0ad95141..6f6b6decf 100644 --- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx +++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx @@ -125,7 +125,13 @@ export class SchemaRowBox extends ViewBoxBaseComponent() { equationHighlightRef = (text: string) => { } - eqHighlightFunc = (text: string, raw: boolean) => {return this.schemaView.findCellRefs(text, raw)}; + eqHighlightFunc = (text: string, raw: boolean) => { + const info = this.schemaView.findCellRefs(text, raw); + if (raw) return info; + const cells: HTMLDivElement[] = []; + info.forEach(info => {cells.push(this.schemaView.getCellElement(info[0], info[1]))}) + return cells; + }; render() { return (