diff options
| author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-03-19 00:56:01 -0400 |
|---|---|---|
| committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-03-19 00:56:01 -0400 |
| commit | be5c28d20f4c3af1a20b03fe8e93c8fd551e99e6 (patch) | |
| tree | 5f3b6760db734e56236dae2ced89e9e78512d179 /src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | |
| parent | fdf02e0b421f98512378b21a6435c87da92ecd30 (diff) | |
multiple cell selection started
Diffstat (limited to 'src/client/views/collections/collectionSchema/CollectionSchemaView.tsx')
| -rw-r--r-- | src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index d179a00ca..b78bd5558 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -86,7 +86,7 @@ export class CollectionSchemaView extends CollectionSubView() { @observable _filterColumnIndex: number | undefined = undefined; @observable _filterSearchValue: string = ''; //Doc = the row; number = the index of the cell to select within the row - @observable _selectedCell: [Doc, number] | undefined = undefined; + @observable _selectedCells: [Array<Doc>, number] | undefined; // target HTMLelement portal for showing a popup menu to edit cell values. public get MenuTarget() { @@ -190,13 +190,11 @@ export class CollectionSchemaView extends CollectionSubView() { if (lastIndex >= 0 && lastIndex < this.childDocs.length - 1) { !e.shiftKey && this.clearSelection(); const newDoc = this.sortedDocs.docs[lastIndex + 1]; - const newDoc2 = this.sortedDocs.docs[lastIndex + 2]; if (this._selectedDocs.includes(newDoc)) { SelectionManager.DeselectView(DocumentManager.Instance.getFirstDocumentView(curDoc)); } else { - this.addDocToSelection(newDoc, true, lastIndex + 1); - this.addDocToSelection(newDoc2, true, lastIndex + 2); - this._selectedCell && (this._selectedCell[0] = newDoc); + this.addDocToSelection(newDoc, e.shiftKey, lastIndex + 1); + this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 0); this.scrollToDoc(newDoc, {}); } } @@ -215,7 +213,7 @@ export class CollectionSchemaView extends CollectionSubView() { if (this._selectedDocs.includes(newDoc)) SelectionManager.DeselectView(DocumentManager.Instance.getFirstDocumentView(curDoc)); else { this.addDocToSelection(newDoc, e.shiftKey, firstIndex - 1); - this._selectedCell && (this._selectedCell[0] = newDoc); + this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 0); this.scrollToDoc(newDoc, {}); } } @@ -224,15 +222,15 @@ export class CollectionSchemaView extends CollectionSubView() { } break; case 'ArrowRight': - if (this._selectedCell) { - this._selectedCell[1] = Math.min(this._selectedCell[1] + 1, this.columnKeys.length - 1); + if (this._selectedCells) { + this._selectedCells[1] = Math.min(this._selectedCells[1] + 1, this.columnKeys.length - 1); } else if (this._selectedDocs.length > 0) { this.selectCell(this._selectedDocs[0], 0); } break; case 'ArrowLeft': - if (this._selectedCell) { - this._selectedCell[1] = Math.max(this._selectedCell[1] - 1, 0); + if (this._selectedCells) { + this._selectedCells[1] = Math.max(this._selectedCells[1] - 1, 0); } else if (this._selectedDocs.length > 0) { this.selectCell(this._selectedDocs[0], 0); } @@ -242,7 +240,7 @@ export class CollectionSchemaView extends CollectionSubView() { break; } case 'Escape': { - this.deselectCell(); + this.deselectAllCells(); } } } @@ -414,7 +412,6 @@ export class CollectionSchemaView extends CollectionSubView() { @action addDocToSelection = (doc: Doc, extendSelection: boolean, index: number) => { - console.log("addDoc called"); const rowDocView = DocumentManager.Instance.getDocumentView(doc); if (rowDocView) SelectionManager.SelectView(rowDocView, extendSelection); }; @@ -437,10 +434,21 @@ export class CollectionSchemaView extends CollectionSubView() { }; @action - selectCell = (doc: Doc, index: number) => (this._selectedCell = [doc, index]); + selectCell = (doc: Doc, index: number) => { + !this._selectedCells && (this._selectedCells = [[doc], index]); + this._selectedCells[0].push(doc); + this._selectedCells[1] = index; + }; @action - deselectCell = () => (this._selectedCell = undefined); + deselectCell = (doc: Doc) => { + this._selectedCells && this._selectedCells[0].filter(d => d !== doc); + }; + + @action + deselectAllCells = () => { + this._selectedCells = [[], 0]; + } sortedSelectedDocs = () => this.sortedDocs.docs.filter(doc => this._selectedDocs.includes(doc)); |
