aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/collectionSchema/SchemaRowBox.tsx')
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index 0065a0938..8b658d834 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -13,14 +13,15 @@ import { emptyFunction, setupMoveUpEvents } from '../../../../Utils';
import { DragManager } from '../../../util/DragManager';
export interface SchemaRowBoxProps extends FieldViewProps {
+ rowIndex: number;
columnKeys: string[];
columnWidths: number[];
rowMenuWidth: number;
selectedRows: ObservableSet<Doc>;
- selectRow: (e: any, doc: Doc) => void;
+ selectRow: (e: any, doc: Doc, index: number) => void;
startDrag: (e: any, doc: Doc) => boolean;
- endDrag: (e: any) => void
dragging: boolean;
+ dropIndex: (index: number) => void;
}
@observer
@@ -38,16 +39,18 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
this, e,
(e) => this.props.startDrag(e, this.props.Document),
emptyFunction,
- (e) => this.props.selectRow(e, this.props.Document)
+ (e) => this.props.selectRow(e, this.props.Document, this.props.rowIndex)
)
}
onPointerEnter = (e: any) => {
+ if (!this.props.dragging) return;
document.removeEventListener('pointermove', this.onPointerMove);
document.addEventListener('pointermove', this.onPointerMove);
};
onPointerMove = (e: any) => {
+ if (!this.props.dragging) return;
let dragIsRow: boolean = true;
DragManager.docsBeingDragged.forEach(doc => {
dragIsRow = this.props.selectedRows.has(doc);
@@ -60,9 +63,11 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
if (y <= halfLine) {
this._ref.style.borderTop = `solid 2px ${Colors.MEDIUM_BLUE}`;
this._ref.style.borderBottom = '0px';
+ this.props.dropIndex(this.props.rowIndex);
} else if (y > halfLine) {
this._ref.style.borderTop = '0px';
this._ref.style.borderBottom = `solid 2px ${Colors.MEDIUM_BLUE}`;
+ this.props.dropIndex(this.props.rowIndex + 1);
}
}
};
@@ -85,6 +90,9 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
<div className="row-button" onPointerDown={(e) => {e.stopPropagation(); this.props.addDocTab(this.props.Document, 'add:right')}}>
<FontAwesomeIcon icon="external-link-alt" />
</div>
+ <div className="row-button">
+ {this.props.rowIndex}
+ </div>
</div>
<div className="row-cells">
{this.props.columnKeys.map((key, index) => (