aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx20
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx20
-rw-r--r--src/client/views/nodes/DocumentView.tsx3
3 files changed, 25 insertions, 18 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;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 36c0240f1..5e7037754 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -644,7 +644,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
}
} else if (!this._longPress && this.onClickHandler?.script && !isScriptBox()) {
// bcz: hack? don't execute script if you're clicking on a scripting box itself
- const { clientX, clientY, shiftKey, altKey } = e;
+ const { clientX, clientY, shiftKey, altKey, metaKey } = e;
const func = () =>
this.onClickHandler.script.run(
{
@@ -658,6 +658,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
clientY,
shiftKey,
altKey,
+ metaKey,
},
console.log
).result?.select === true