diff options
| author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-03-21 00:43:08 -0400 |
|---|---|---|
| committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-03-21 00:43:08 -0400 |
| commit | 9ccbc0a6d6f6fffbc479d37ac2a880eafe85c65d (patch) | |
| tree | 9eb60db4c05a7a79bf12a4bb31920b15f7689eac /src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | |
| parent | a598877cc71c1f2a25e8cac4b831ab947a2539e0 (diff) | |
multiple cell column switching working
Diffstat (limited to 'src/client/views/collections/collectionSchema/CollectionSchemaView.tsx')
| -rw-r--r-- | src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index 60b3ae4ab..e722e774d 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -87,8 +87,9 @@ export class CollectionSchemaView extends CollectionSubView() { @observable _filterColumnIndex: number | undefined = undefined; @observable _filterSearchValue: string = ''; //an array of selected docs and the index representing the selected column - @observable selectedCol: number = 0; - @observable _selectedCells: [Array<Doc>, number] | undefined; + @observable _selectedCol: number = 0; + @observable _selectedCells: Array<Doc> | undefined; + // target HTMLelement portal for showing a popup menu to edit cell values. public get MenuTarget() { @@ -197,7 +198,7 @@ export class CollectionSchemaView extends CollectionSubView() { } else { const shift: boolean = e.shiftKey; - this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 2, shift); + this.selectCell(newDoc, this._selectedCol, shift); this.scrollToDoc(newDoc, {}); } } @@ -218,7 +219,7 @@ export class CollectionSchemaView extends CollectionSubView() { } else { const shift: boolean = e.shiftKey; - this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 2, shift); + this.selectCell(newDoc, this._selectedCol, shift); this.scrollToDoc(newDoc, {}); } } @@ -228,16 +229,14 @@ export class CollectionSchemaView extends CollectionSubView() { break; case 'ArrowRight': if (this._selectedCells) { - this.selectCell(this._selectedCells[0][0], this._selectedCells[1] + 1, false); + ++this._selectedCol; } else if (this._selectedDocs.length > 0) { this.selectCell(this._selectedDocs[0], 0, false); } break; case 'ArrowLeft': if (this._selectedCells) { - this._selectedCells = undefined; - //this._selectedCells = [this._selectedCells[0], 2] - //this._selectedCells[1] = Math.max(this._selectedCells[1] - 1, 0); + --this._selectedCol; } else if (this._selectedDocs.length > 0) { this.selectCell(this._selectedDocs[0], 0, false); } @@ -448,16 +447,16 @@ export class CollectionSchemaView extends CollectionSubView() { for (let i = startRow; i <= endRow; i++) { const currDoc = this.sortedDocs.docs[i]; if (!this._selectedDocs.includes(currDoc)) this.addDocToSelection(currDoc, true, i); - this._selectedCells && this._selectedCells[0].push(currDoc); + this._selectedCells && this._selectedCells.push(currDoc); } }; @action selectCell = (doc: Doc, index: number, shiftKey: boolean) => { !shiftKey && this.deselectAllCells(); - !this._selectedCells && (this._selectedCells = [[], index]); - this._selectedCells[0].push(doc); - this._selectedCells[1] = index; + !this._selectedCells && (this._selectedCells = []); + this._selectedCells.push(doc); + this._selectedCol = index; if (!this) return; const lastSelected = Array.from(this._selectedDocs).lastElement(); @@ -466,16 +465,18 @@ export class CollectionSchemaView extends CollectionSubView() { this.addDocToSelection(doc, false, this.rowIndex(doc)); } - let selectedIndexes: Array<Number> = this._selectedCells[0].map(doc => this.rowIndex(doc)); + let selectedIndexes: Array<Number> = this._selectedCells.map(doc => this.rowIndex(doc)); console.log("cells: " + selectedIndexes); + console.log("index: " + this._selectedCol); + }; @action deselectCell = (doc: Doc) => { if (this._selectedCells) - this._selectedCells[0] = this._selectedCells[0].filter(d => d !== doc); + this._selectedCells = this._selectedCells.filter(d => d !== doc); if (this._selectedCells){ - let selectedIndexes: Array<Number> = this._selectedCells[0].map(doc => this.rowIndex(doc)); + let selectedIndexes: Array<Number> = this._selectedCells.map(doc => this.rowIndex(doc)); console.log("cells: " + selectedIndexes); } }; @@ -607,7 +608,7 @@ export class CollectionSchemaView extends CollectionSubView() { setColumnValues = (key: string, value: string) => { this.childDocs.forEach(doc => { - let docIsSelected = this._selectedCells && !(this._selectedCells[0]?.filter(d => d === doc).length === 0); + let docIsSelected = this._selectedCells && !(this._selectedCells?.filter(d => d === doc).length === 0); console.log(docIsSelected); if (docIsSelected){ KeyValueBox.SetField(doc, key, value) @@ -621,7 +622,7 @@ export class CollectionSchemaView extends CollectionSubView() { setSelectedColumnValues = (key: string, value: string) => { console.log("called"); this.childDocs.forEach(doc => { - let docIsSelected = this._selectedCells && !(this._selectedCells[0]?.filter(d => d === doc).length === 0); + let docIsSelected = this._selectedCells && !(this._selectedCells?.filter(d => d === doc).length === 0); if (docIsSelected){ KeyValueBox.SetField(doc, key, value) } |
