diff options
Diffstat (limited to 'src')
5 files changed, 47 insertions, 26 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index b78bd5558..33ae8aad1 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -25,6 +25,7 @@ import { CollectionSubView } from '../CollectionSubView'; import './CollectionSchemaView.scss'; import { SchemaColumnHeader } from './SchemaColumnHeader'; import { SchemaRowBox } from './SchemaRowBox'; +import { faLessThanEqual } from '@fortawesome/free-solid-svg-icons'; const { default: { SCHEMA_NEW_NODE_HEIGHT } } = require('../../global/globalCssVariables.module.scss'); // prettier-ignore export enum ColumnType { @@ -85,7 +86,8 @@ export class CollectionSchemaView extends CollectionSubView() { @observable _menuValue: string = ''; @observable _filterColumnIndex: number | undefined = undefined; @observable _filterSearchValue: string = ''; - //Doc = the row; number = the index of the cell to select within the row + //an array of selected docs and the index representing the selected column + @observable selectedCol: number = 0; @observable _selectedCells: [Array<Doc>, number] | undefined; // target HTMLelement portal for showing a popup menu to edit cell values. @@ -194,7 +196,7 @@ export class CollectionSchemaView extends CollectionSubView() { SelectionManager.DeselectView(DocumentManager.Instance.getFirstDocumentView(curDoc)); } else { this.addDocToSelection(newDoc, e.shiftKey, lastIndex + 1); - this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 0); + this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 0, false); this.scrollToDoc(newDoc, {}); } } @@ -213,7 +215,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.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 0); + this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] + 1 : 0, false); this.scrollToDoc(newDoc, {}); } } @@ -223,17 +225,13 @@ export class CollectionSchemaView extends CollectionSubView() { break; case 'ArrowRight': if (this._selectedCells) { - this._selectedCells[1] = Math.min(this._selectedCells[1] + 1, this.columnKeys.length - 1); + this.selectCell(this._selectedCells[0][0], this._selectedCells[1] + 1, false); } else if (this._selectedDocs.length > 0) { - this.selectCell(this._selectedDocs[0], 0); + this.selectCell(this._selectedDocs[0], 0, false); } break; case 'ArrowLeft': - 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); - } + this.changeSelectedCellColumn(); break; case 'Backspace': { this.removeDocument(this._selectedDocs); @@ -246,6 +244,15 @@ export class CollectionSchemaView extends CollectionSubView() { } }; + @action + changeSelectedCellColumn = () => { + 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, false); + } + } + @undoBatch setColumnSort = (field: string | undefined, desc: boolean = false) => { this.layoutDoc.sortField = field; @@ -412,6 +419,7 @@ export class CollectionSchemaView extends CollectionSubView() { @action addDocToSelection = (doc: Doc, extendSelection: boolean, index: number) => { + //console.log("doc added"); const rowDocView = DocumentManager.Instance.getDocumentView(doc); if (rowDocView) SelectionManager.SelectView(rowDocView, extendSelection); }; @@ -427,6 +435,8 @@ export class CollectionSchemaView extends CollectionSubView() { const lastSelectedRow = this.rowIndex(lastSelected); const startRow = Math.min(lastSelectedRow, index); const endRow = Math.max(lastSelectedRow, index); + console.log(lastSelectedRow); + console.log("start: " + startRow + " end: " + endRow); for (let i = startRow; i <= endRow; i++) { const currDoc = this.sortedDocs.docs[i]; if (!this._selectedDocs.includes(currDoc)) this.addDocToSelection(currDoc, true, i); @@ -434,10 +444,19 @@ export class CollectionSchemaView extends CollectionSubView() { }; @action - selectCell = (doc: Doc, index: number) => { + selectCell = (doc: Doc, index: number, shiftKey: boolean) => { + //console.log("cellSelect"); + //console.log(shiftKey); + shiftKey = true; !this._selectedCells && (this._selectedCells = [[doc], index]); this._selectedCells[0].push(doc); this._selectedCells[1] = index; + if (!this) return; + const lastSelected = Array.from(this._selectedDocs).lastElement(); + if (shiftKey && lastSelected) this.selectRows(doc, lastSelected); + else { + this.addDocToSelection(doc, false, 0); + } }; @action @@ -447,7 +466,7 @@ export class CollectionSchemaView extends CollectionSubView() { @action deselectAllCells = () => { - this._selectedCells = [[], 0]; + this._selectedCells = undefined; } sortedSelectedDocs = () => this.sortedDocs.docs.filter(doc => this._selectedDocs.includes(doc)); diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx index 36e58d610..0ef78fe07 100644 --- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx +++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx @@ -99,7 +99,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() { }; getFinfo = computedFn((fieldKey: string) => this.schemaView?.fieldInfos.get(fieldKey)); - selectCell = (doc: Doc, col: number) => this.schemaView?.selectCell(doc, col); + selectCell = (doc: Doc, col: number, shift: boolean) => this.schemaView?.selectCell(doc, col, shift); deselectCell = () => this.schemaView?.deselectAllCells(); selectedCell = () => this.schemaView?._selectedCells; setColumnValues = (field: any, value: any) => this.schemaView?.setColumnValues(field, value) ?? false; @@ -186,7 +186,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() { getFinfo={this.getFinfo} selectCell={this.selectCell} deselectCell={this.deselectCell} - selectedCell={this.selectedCell} + selectedCells={this.selectedCell} setColumnValues={this.setColumnValues} oneLine={BoolCast(this.schemaDoc?._singleLine)} menuTarget={this.schemaView.MenuTarget} 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() { diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index a46426e0b..c957e7429 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -1335,7 +1335,7 @@ export class DocumentView extends DocComponent<DocumentViewProps>() { zoomTime: 500, }); } - /*}*/ + //} }; DataTransition = () => this._props.DataTransition?.() || StrCast(this.Document.dataTransition); ShouldNotScale = () => this.shouldNotScale; diff --git a/src/client/views/nodes/formattedText/DashFieldView.tsx b/src/client/views/nodes/formattedText/DashFieldView.tsx index b49e7dcf0..b0c35b161 100644 --- a/src/client/views/nodes/formattedText/DashFieldView.tsx +++ b/src/client/views/nodes/formattedText/DashFieldView.tsx @@ -140,7 +140,7 @@ export class DashFieldViewInternal extends ObservableReactComponent<IDashFieldVi selectCell={emptyFunction} maxWidth={this._props.hideKey ? undefined : this.return100} columnWidth={this._props.hideKey ? () => this._props.tbox._props.PanelWidth() - 20 : returnZero} - selectedCell={() => [this._dashDoc!, 0]} + selectedCells={() => [this._dashDoc!, 0]} fieldKey={this._fieldKey} rowHeight={returnZero} isRowActive={() => this._expanded && this._props.editable} |