aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx20
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx20
2 files changed, 23 insertions, 17 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 1a26f1178..02591489b 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -25,6 +25,7 @@ import { SchemaColumnHeader } from './SchemaColumnHeader';
import { SchemaRowBox } from './SchemaRowBox';
import { DefaultStyleProvider } from '../../StyleProvider';
import { DocumentManager } from '../../../util/DocumentManager';
+import { ScriptField } from '../../../../fields/ScriptField';
export enum ColumnType {
Number,
@@ -338,12 +339,13 @@ export class CollectionSchemaView extends CollectionSubView() {
this._lastSelectedRow = undefined;
};
+ rowOnClickScript = ScriptField.MakeFunction('scriptContext.selectRow(self, shiftKey, ctrlKey || metaKey)', { scriptContext: 'any', shiftKey: 'boolean', ctrlKey: 'boolean', metaKey: 'boolean' })!;
+
@action
- selectRow = (e: PointerEvent, doc: Doc, ref: HTMLDivElement, index: number) => {
- e.stopPropagation();
+ selectRow = (doc: Doc, shift: boolean, ctrl: boolean) => {
+ console.log(ctrl);
+ const index = this.childDocs.indexOf(doc);
if (index < 0) return;
- const ctrl = e.ctrlKey || e.metaKey;
- const shift = e.shiftKey;
if (shift && this._lastSelectedRow !== undefined) {
const startRow = Math.min(this._lastSelectedRow, index);
const endRow = Math.max(this._lastSelectedRow, index);
@@ -358,8 +360,10 @@ export class CollectionSchemaView extends CollectionSubView() {
this.removeDocFromSelection(doc);
}
} else {
- this.clearSelection();
- this.addDocToSelection(doc, false, index);
+ if (!this._selectedDocs.has(doc)) {
+ this.clearSelection();
+ this.addDocToSelection(doc, false, index);
+ }
}
};
@@ -405,7 +409,7 @@ export class CollectionSchemaView extends CollectionSubView() {
};
@action
- startDrag = (e: PointerEvent, doc: Doc, ref: HTMLDivElement, index: number) => {
+ startDrag = (e: PointerEvent, doc: Doc, index: number) => {
if (!this._selectedDocs.has(doc)) {
this.clearSelection();
this.addDocToSelection(doc, false, index);
@@ -604,6 +608,8 @@ export class CollectionSchemaView extends CollectionSubView() {
hideTitle={true}
hideDocumentButtonBar={true}
fitWidth={returnTrue}
+ onClick={() => this.rowOnClickScript}
+ scriptContext={this}
/>
</div>
);
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index d6a00966d..5de9fdf5c 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -42,13 +42,13 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
onRowPointerDown = (e: React.PointerEvent) => {
e.stopPropagation();
- setupMoveUpEvents(
- this,
- e,
- e => this.schemaView?.startDrag(e, this.rootDoc, this._ref!, this.rowIndex) ?? true,
- emptyFunction,
- e => this.schemaView?.selectRow(e, this.rootDoc, this._ref!, this.rowIndex)
- );
+ // setupMoveUpEvents(
+ // this,
+ // e,
+ // e => this.schemaView?.startDrag(e, this.rootDoc, this.rowIndex) ?? true,
+ // emptyFunction,
+ // e => this.schemaView?.selectRow(e, this.rootDoc, this.rowIndex)
+ // );
};
onPointerEnter = (e: any) => {
@@ -97,9 +97,9 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
? { height: CollectionSchemaView._rowHeight, backgroundColor: Colors.LIGHT_BLUE, pointerEvents: this.schemaView?.props.isContentActive() ? 'all' : undefined /*, opacity: this.props.dragging ? 0.5 : 1 */ }
: { height: CollectionSchemaView._rowHeight, pointerEvents: this.schemaView?.props.isContentActive() ? 'all' : undefined }
}
- onPointerDown={this.onRowPointerDown}
- onPointerEnter={this.onPointerEnter}
- onPointerLeave={this.onPointerLeave}
+ // onPointerDown={this.onRowPointerDown}
+ // onPointerEnter={this.onPointerEnter}
+ // onPointerLeave={this.onPointerLeave}
ref={(row: HTMLDivElement | null) => {
row && this.schemaView?.addRowRef(this.rootDoc, row);
this._ref = row;