aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/SelectionManager.ts3
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx36
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx6
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx19
-rw-r--r--src/client/views/nodes/DocumentView.tsx2
5 files changed, 38 insertions, 28 deletions
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts
index f3b2acb5e..6f6278662 100644
--- a/src/client/util/SelectionManager.ts
+++ b/src/client/util/SelectionManager.ts
@@ -9,6 +9,7 @@ import { DocumentView } from '../views/nodes/DocumentView';
import { LinkManager } from './LinkManager';
import { ScriptingGlobals } from './ScriptingGlobals';
import { UndoManager } from './UndoManager';
+import { SchemaRowBox } from '../views/collections/collectionSchema/SchemaRowBox';
export class SelectionManager {
private static _manager: SelectionManager;
@@ -43,7 +44,6 @@ export class SelectionManager {
});
public static DeselectView = action((docView?: DocumentView): void => {
- console.log(3);
if (docView && this.Instance.SelectedViews.includes(docView)) {
docView.IsSelected = false;
this.Instance.SelectedViews.splice(this.Instance.SelectedViews.indexOf(docView), 1);
@@ -63,6 +63,7 @@ export class SelectionManager {
dv._props.whenChildContentsActiveChanged(false);
});
runInAction(() => (this.Instance.SelectedViews.length = 0));
+ //not responsible for select onPointerDown
if (found) this.SelectView(found, false);
};
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));
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index c30eee237..36e58d610 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -59,7 +59,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
const lastSelected = Array.from(this.schemaView._selectedDocs).lastElement();
if (shiftKey && lastSelected) this.schemaView.selectRows(this.Document, lastSelected);
else {
- this._props.select?.(ctrlKey);
+ this.schemaView.addDocToSelection(this.Document, false, 0);
}
};
@@ -100,8 +100,8 @@ 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);
- deselectCell = () => this.schemaView?.deselectCell();
- selectedCell = () => this.schemaView?._selectedCell;
+ deselectCell = () => this.schemaView?.deselectAllCells();
+ selectedCell = () => this.schemaView?._selectedCells;
setColumnValues = (field: any, value: any) => this.schemaView?.setColumnValues(field, value) ?? false;
columnWidth = computedFn((index: number) => () => this.schemaView?.displayColumnWidths[index] ?? CollectionSchemaView._minColWidth);
render() {
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index 46867665d..85b3158a8 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -36,7 +36,7 @@ export interface SchemaTableCellProps {
col: number;
deselectCell: () => void;
selectCell: (doc: Doc, col: number) => void;
- selectedCell: () => [Doc, number] | undefined;
+ selectedCell: () => [Doc[], number] | undefined;
fieldKey: string;
maxWidth?: () => number;
columnWidth: () => number;
@@ -107,8 +107,8 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
}
@computed get selected() {
- const selected: [Doc, number] | undefined = this._props.selectedCell();
- return this._props.isRowActive() && selected?.[0] === this._props.Document && selected[1] === this._props.col;
+ 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;
}
@computed get defaultCellContent() {
@@ -309,8 +309,9 @@ export class SchemaRTFCell extends ObservableReactComponent<SchemaTableCellProps
}
@computed get selected() {
- const selected: [Doc, number] | undefined = this._props.selectedCell();
- return this._props.isRowActive() && selected?.[0] === this._props.Document && selected[1] === this._props.col;
+ 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;
+ //return this._props.isRowActive() && selected?.[0] === this._props.Document && selected[1] === this._props.col;
}
selectedFunc = () => this.selected;
render() {
@@ -331,8 +332,8 @@ export class SchemaBoolCell extends ObservableReactComponent<SchemaTableCellProp
}
@computed get selected() {
- const selected: [Doc, number] | undefined = this._props.selectedCell();
- return this._props.isRowActive() && selected?.[0] === this._props.Document && selected[1] === this._props.col;
+ 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;
}
render() {
const { color, textDecoration, fieldProps, cursor, pointerEvents } = SchemaTableCell.renderProps(this._props);
@@ -375,8 +376,8 @@ export class SchemaEnumerationCell extends ObservableReactComponent<SchemaTableC
}
@computed get selected() {
- const selected: [Doc, number] | undefined = this._props.selectedCell();
- return this._props.isRowActive() && selected?.[0] === this._props.Document && selected[1] === this._props.col;
+ 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;
}
render() {
const { color, textDecoration, fieldProps, cursor, pointerEvents } = SchemaTableCell.renderProps(this._props);
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 38e60721f..a46426e0b 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -360,7 +360,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
const sendToBack = e.altKey;
this._singleClickFunc =
// prettier-ignore
- clickFunc ?? (() => (sendToBack ? documentView._props.bringToFront?.(this.Document, true) :
+ clickFunc ?? (() => (sendToBack ? documentView._props.bringToFront?.(this.Document, true) :
this._props.select(e.ctrlKey||e.shiftKey, e.metaKey)));
const waitFordblclick = this._props.waitForDoubleClickToClick?.() ?? this.Document.waitForDoubleClickToClick;
if ((clickFunc && waitFordblclick !== 'never') || waitFordblclick === 'always') {