aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2023-02-27 17:00:49 -0500
committermehekj <mehek.jethani@gmail.com>2023-02-27 17:00:49 -0500
commit222f659b8c291fafce2648e367392dd9f467cb25 (patch)
tree2592b253f380624323285c325cf415d22ea42cbb /src/client/views/collections/collectionSchema/SchemaRowBox.tsx
parentfecf9bdf8fc6d551e4595af688179950af6ca684 (diff)
rows are documentviews but clipped
Diffstat (limited to 'src/client/views/collections/collectionSchema/SchemaRowBox.tsx')
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx120
1 files changed, 67 insertions, 53 deletions
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index 2cf0a1b79..0378fa67e 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -1,17 +1,17 @@
import React = require('react');
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, ObservableSet } from 'mobx';
+import { computed, ObservableSet } from 'mobx';
import { observer } from 'mobx-react';
import { Doc } from '../../../../fields/Doc';
-import { DragManager } from '../../../util/DragManager';
import { undoBatch } from '../../../util/UndoManager';
import { ViewBoxBaseComponent } from '../../DocComponent';
-import { Colors } from '../../global/globalEnums';
import { OpenWhere } from '../../nodes/DocumentView';
-import { FieldViewProps } from '../../nodes/FieldView';
+import { FieldView, FieldViewProps } from '../../nodes/FieldView';
+import { CollectionSchemaView } from './CollectionSchemaView';
import './CollectionSchemaView.scss';
import { SchemaTableCell } from './SchemaTableCell';
-import { setupMoveUpEvents, emptyFunction } from '../../../../Utils';
+import { Colors } from '../../global/globalEnums';
+import { DocCast, StrCast } from '../../../../fields/Types';
export interface SchemaRowBoxProps extends FieldViewProps {
rowIndex: number;
@@ -27,79 +27,93 @@ export interface SchemaRowBoxProps extends FieldViewProps {
}
@observer
-export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
+export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
+ public static LayoutString(fieldKey: string) {
+ return FieldView.LayoutString(SchemaRowBox, fieldKey);
+ }
+
private _ref: HTMLDivElement | null = null;
bounds = () => this._ref?.getBoundingClientRect();
- isSelected = () => this.props.selectedDocs.has(this.props.Document);
+ @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;
+ }
- @action
- onRowPointerDown = (e: React.PointerEvent) => {
- e.stopPropagation();
+ @computed get schemaDoc() {
+ return this.props.ContainingCollectionDoc!;
+ }
- 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)
- );
- };
+ // isSelected = () => this.props.selectedDocs.has(this.props.Document);
- onPointerEnter = (e: any) => {
- if (!this.props.dragging) return;
- document.removeEventListener('pointermove', this.onPointerMove);
- document.addEventListener('pointermove', this.onPointerMove);
- };
+ // @action
+ // onRowPointerDown = (e: React.PointerEvent) => {
+ // e.stopPropagation();
- onPointerMove = (e: any) => {
- if (!this.props.dragging) return;
- let dragIsRow: boolean = true;
- DragManager.docsBeingDragged.forEach(doc => {
- dragIsRow = this.props.selectedDocs.has(doc);
- });
- if (this._ref && dragIsRow) {
- const rect = this._ref.getBoundingClientRect();
- const y = e.clientY - rect.top; //y position within the element.
- const height = this._ref.clientHeight;
- const halfLine = height / 2;
- 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);
- }
- }
- };
+ // 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)
+ // );
+ // };
+
+ // 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.selectedDocs.has(doc);
+ // });
+ // if (this._ref && dragIsRow) {
+ // const rect = this._ref.getBoundingClientRect();
+ // const y = e.clientY - rect.top; //y position within the element.
+ // const height = this._ref.clientHeight;
+ // const halfLine = height / 2;
+ // 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);
+ // }
+ // }
+ // };
onPointerLeave = (e: any) => {
if (this._ref) {
this._ref.style.borderTop = '0px';
this._ref.style.borderBottom = '0px';
}
- document.removeEventListener('pointermove', this.onPointerMove);
+ // document.removeEventListener('pointermove', this.onPointerMove);
};
render() {
return (
<div
className="schema-row"
- style={this.isSelected() ? { backgroundColor: Colors.LIGHT_BLUE, opacity: this.props.dragging ? 0.5 : 1 } : {}}
- onPointerDown={this.onRowPointerDown}
- onPointerEnter={this.onPointerEnter}
+ style={this.props.isSelected() ? { backgroundColor: Colors.LIGHT_BLUE /*, opacity: this.props.dragging ? 0.5 : 1 */ } : {}}
+ // onPointerDown={this.onRowPointerDown}
+ // onPointerEnter={this.onPointerEnter}
onPointerLeave={this.onPointerLeave}
ref={(row: HTMLDivElement | null) => {
- row && this.props.addRowRef(this.props.Document, row);
+ // row && this.props.addRowRef(this.props.Document, row);
this._ref = row;
}}>
<div
className="row-menu"
style={{
- width: this.props.rowMenuWidth,
+ width: CollectionSchemaView._rowMenuWidth,
}}>
<div
className="schema-row-button"
@@ -119,8 +133,8 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
</div>
</div>
<div className="row-cells">
- {this.props.columnKeys.map((key, index) => (
- <SchemaTableCell key={key} Document={this.props.Document} fieldKey={key} columnWidth={this.props.columnWidths[index]} />
+ {this.schemaView?.columnKeys?.map((key, index) => (
+ <SchemaTableCell key={key} Document={this.props.Document} fieldKey={key} columnWidth={this.schemaView?.displayColumnWidths[index] ?? CollectionSchemaView._minColWidth} />
))}
</div>
</div>