aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2023-02-28 17:13:11 -0500
committermehekj <mehek.jethani@gmail.com>2023-02-28 17:13:11 -0500
commitdf4781b27848731b329068b13da89a17d04ad1a9 (patch)
tree684d562362bbc14dff719f8d7c7b5013167b441c /src/client/views/collections/collectionSchema/SchemaRowBox.tsx
parentd7d94fb4a9480a699eafa250a95821f7c584911d (diff)
selection working (except ctrl+click)
Diffstat (limited to 'src/client/views/collections/collectionSchema/SchemaRowBox.tsx')
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index e72ed3c4f..d67e6f2d7 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -1,6 +1,6 @@
import React = require('react');
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { computed, ObservableSet } from 'mobx';
+import { action, computed, ObservableSet } from 'mobx';
import { observer } from 'mobx-react';
import { Doc } from '../../../../fields/Doc';
import { undoBatch } from '../../../util/UndoManager';
@@ -12,19 +12,7 @@ import './CollectionSchemaView.scss';
import { SchemaTableCell } from './SchemaTableCell';
import { Colors } from '../../global/globalEnums';
import { DocCast, StrCast } from '../../../../fields/Types';
-
-export interface SchemaRowBoxProps extends FieldViewProps {
- rowIndex: number;
- columnKeys: string[];
- columnWidths: number[];
- rowMenuWidth: number;
- selectedDocs: ObservableSet<Doc>;
- selectRow: (e: any, doc: Doc, ref: HTMLDivElement, index: number) => void;
- startDrag: (e: any, doc: Doc, ref: HTMLDivElement, index: number) => boolean;
- dragging: boolean;
- dropIndex: (index: number) => void;
- addRowRef: (doc: Doc, ref: HTMLDivElement) => void;
-}
+import { setupMoveUpEvents, emptyFunction } from '../../../../Utils';
@observer
export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
@@ -38,7 +26,6 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed get schemaView() {
const vpath = this.props.docViewPath();
- console.log(vpath[vpath.length - 2]);
return vpath.length > 1 ? (vpath[vpath.length - 2].ComponentView as CollectionSchemaView) : undefined;
}
@@ -46,20 +33,25 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
return this.props.ContainingCollectionDoc!;
}
+ @computed get rowIndex() {
+ return this.schemaView?.rowIndex(this.rootDoc) ?? -1;
+ }
+
// isSelected = () => this.props.selectedDocs.has(this.props.Document);
- // @action
- // onRowPointerDown = (e: React.PointerEvent) => {
- // e.stopPropagation();
+ @action
+ onRowPointerDown = (e: React.PointerEvent) => {
+ e.stopPropagation();
- // setupMoveUpEvents(
- // this,
- // e,
- // e => this.props.startDrag(e, this.props.Document, this._ref!, this.props.rowIndex),
- // emptyFunction,
- // e => this.props.selectRow(e, this.props.Document, this._ref!, this.props.rowIndex)
- // );
- // };
+ setupMoveUpEvents(
+ this,
+ e,
+ // e => this.schemaView?.startDrag(e, this.props.Document, this._ref!, this.props.rowIndex) ?? true,
+ returnTrue,
+ emptyFunction,
+ e => this.schemaView?.selectRow(e, this.props.Document, this._ref!, this.rowIndex)
+ );
+ };
// onPointerEnter = (e: any) => {
// if (!this.props.dragging) return;
@@ -102,8 +94,12 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
return (
<div
className="schema-row"
- style={this.props.isSelected() ? { height: CollectionSchemaView._rowHeight, backgroundColor: Colors.LIGHT_BLUE /*, opacity: this.props.dragging ? 0.5 : 1 */ } : { height: CollectionSchemaView._rowHeight }}
- // onPointerDown={this.onRowPointerDown}
+ style={
+ this.props.isSelected()
+ ? { 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}
ref={(row: HTMLDivElement | null) => {
@@ -141,3 +137,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
);
}
}
+function // e => this.schemaView?.startDrag(e, this.props.Document, this._ref!, this.props.rowIndex) ?? true,
+returnTrue(e: PointerEvent, down: number[], delta: number[]): boolean {
+ throw new Error('Function not implemented.');
+}