aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2023-03-15 18:15:18 -0400
committermehekj <mehek.jethani@gmail.com>2023-03-15 18:15:18 -0400
commit61ce7b4d434aff7e642d2af17b8643297f99e4a3 (patch)
tree0562ddcab46ef1c10996baaada7001c083dea820 /src/client/views/collections
parent504c8046c13dfe77316e42943e48c017d67c2ad8 (diff)
column drag in progress
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.scss112
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx40
-rw-r--r--src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx21
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx16
4 files changed, 103 insertions, 86 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
index 5eb5cc86d..1853fb589 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
@@ -8,6 +8,7 @@
.schema-table {
background-color: $white;
+ cursor: default;
.schema-column-menu,
.schema-filter-menu {
@@ -80,68 +81,70 @@
align-self: center;
}
}
+ }
- .schema-header-row {
- justify-content: flex-end;
+ .schema-preview-divider {
+ height: 100%;
+ background: black;
+ cursor: ew-resize;
+ }
+}
- .row-menu {
- display: flex;
- justify-content: flex-end;
- }
+.schema-header-row {
+ cursor: grab;
+ justify-content: flex-end;
- .schema-column-header {
- font-weight: bold;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- padding: 0;
- z-index: 1;
-
- .schema-column-title {
- flex-grow: 2;
- margin: 5px;
- }
+ .row-menu {
+ display: flex;
+ justify-content: flex-end;
+ }
+}
- .schema-header-menu {
- margin: 5px;
- }
+.schema-column-header {
+ background-color: $light-gray;
+ font-weight: bold;
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ align-items: center;
+ padding: 0;
+ z-index: 1;
- .schema-column-resizer {
- height: 100%;
- width: 3px;
- cursor: ew-resize;
+ .schema-column-title {
+ flex-grow: 2;
+ margin: 5px;
+ }
- &:hover {
- background-color: $light-blue;
- }
- }
+ .schema-header-menu {
+ margin: 5px;
+ }
- .schema-column-resizer.right {
- margin-left: 5px;
- align-self: flex-end;
- }
+ .schema-column-resizer {
+ height: 100%;
+ width: 3px;
+ cursor: ew-resize;
- .schema-column-resizer.left {
- margin-right: 5px;
- align-self: flex-start;
- }
- }
+ &:hover {
+ background-color: $light-blue;
}
+ }
- .schema-header-menu {
- display: flex;
- flex-direction: row;
- }
+ .schema-column-resizer.right {
+ margin-left: 5px;
+ align-self: flex-end;
}
- .schema-preview-divider {
- height: 100%;
- background: black;
- cursor: ew-resize;
+ .schema-column-resizer.left {
+ margin-right: 5px;
+ align-self: flex-start;
}
}
+.schema-header-menu {
+ display: flex;
+ flex-direction: row;
+}
+
.schema-row-wrapper {
// max-height: 70px;
overflow: hidden;
@@ -158,17 +161,18 @@
height: 100%;
// max-height: 70px;
overflow: auto;
+}
- .schema-column-header,
- .schema-table-cell,
- .row-menu {
- border: 1px solid $medium-gray;
- padding: 5px;
- overflow: hidden;
- }
+.schema-column-header,
+.schema-table-cell,
+.row-menu {
+ border: 1px solid $medium-gray;
+ padding: 5px;
+ overflow: hidden;
}
.schema-row {
+ cursor: default;
justify-content: flex-end;
background: white;
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index e1c2d989f..b0114a226 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -54,6 +54,7 @@ export class CollectionSchemaView extends CollectionSubView() {
@observable _lastSelectedRow: number | undefined;
@observable _selectedDocs: ObservableSet = new ObservableSet<Doc>();
@observable _rowEles: ObservableMap = new ObservableMap<Doc, HTMLDivElement>();
+ @observable _colEles: HTMLDivElement[] = [];
@observable _isDragging: boolean = false;
@observable _displayColumnWidths: number[] | undefined;
@observable _columnMenuIndex: number | undefined;
@@ -301,23 +302,17 @@ export class CollectionSchemaView extends CollectionSubView() {
this.layoutDoc.columnWidths = new List<number>(currWidths);
};
- // @action
- // dragColumn = (e: any, index: number) => {
- // e.stopPropagation();
- // e.preventDefault();
- // const rect = e.target.getBoundingClientRect();
- // if (e.clientX < rect.x) {
- // if (index < 1) return true;
- // this.swapColumns(index - 1, index);
- // return true;
- // }
- // if (e.clientX > rect.x + rect.width) {
- // if (index === this.columnKeys.length) return true;
- // this.swapColumns(index, index + 1);
- // return true;
- // }
- // return false;
- // };
+ @action
+ dragColumn = (e: PointerEvent, index: number) => {
+ const dragData = new DragManager.ColumnDragData(index);
+ const dragEles = [this._colEles[index]];
+ this.childDocs.forEach(doc => {
+ dragEles.push(this._rowEles.get(doc).children[1].children[index]);
+ });
+ DragManager.StartColumnDrag(dragEles, dragData, e.x, e.y);
+
+ return true;
+ };
@action
addRowRef = (doc: Doc, ref: HTMLDivElement) => {
@@ -325,6 +320,15 @@ export class CollectionSchemaView extends CollectionSubView() {
};
@action
+ setColRef = (index: number, ref: HTMLDivElement) => {
+ if (this._colEles.length <= index) {
+ this._colEles.push(ref);
+ } else {
+ this._colEles[index] = ref;
+ }
+ };
+
+ @action
addDocToSelection = (doc: Doc, extendSelection: boolean, index: number) => {
this._selectedDocs.add(doc);
const rowDocView = DocumentManager.Instance.getDocumentView(doc);
@@ -842,6 +846,8 @@ export class CollectionSchemaView extends CollectionSubView() {
removeColumn={this.removeColumn}
resizeColumn={this.startResize}
openContextMenu={this.openContextMenu}
+ dragColumn={this.dragColumn}
+ setColRef={this.setColRef}
/>
);
})}
diff --git a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
index 42626697a..e648356f4 100644
--- a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
@@ -26,8 +26,9 @@ export interface SchemaColumnHeaderProps {
setSort: (field: string, desc: boolean) => void;
removeColumn: (index: number) => void;
resizeColumn: (e: any, index: number, left: boolean) => void;
- // dragColumn: (e: any, index: number) => boolean;
+ dragColumn: (e: any, index: number) => boolean;
openContextMenu: (x: number, y: number, index: number) => void;
+ setColRef: (index: number, ref: HTMLDivElement) => void;
}
@observer
@@ -47,16 +48,20 @@ export class SchemaColumnHeader extends React.Component<SchemaColumnHeaderProps>
}
};
- // @action
- // onPointerDown = (e: React.PointerEvent) => {
- // e.stopPropagation();
-
- // setupMoveUpEvents(this, e, e => this.props.dragColumn(e, this.props.columnIndex), emptyFunction, emptyFunction);
- // };
+ @action
+ onPointerDown = (e: React.PointerEvent) => {
+ setupMoveUpEvents(this, e, e => this.props.dragColumn(e, this.props.columnIndex), emptyFunction, emptyFunction);
+ };
render() {
return (
- <div className="schema-column-header" style={{ width: this.props.columnWidths[this.props.columnIndex] }}>
+ <div
+ className="schema-column-header"
+ style={{ width: this.props.columnWidths[this.props.columnIndex] }}
+ onPointerDown={this.onPointerDown}
+ ref={(col: HTMLDivElement | null) => {
+ col && this.props.setColRef(this.props.columnIndex, col);
+ }}>
<div className="schema-column-resizer left" onPointerDown={e => this.props.resizeColumn(e, this.props.columnIndex, true)}></div>
<div className="schema-column-title">{this.fieldKey}</div>
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index 43b7da544..91b292b28 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -48,13 +48,15 @@ export class SchemaTableCell extends React.Component<SchemaTableCellProps> {
};
return (
- <div className="schema-table-cell" style={{ width: this.props.columnWidth, pointerEvents: this.props.isRowActive() ? 'all' : 'none' }}>
- <EditableView
- contents={<FieldView {...props} />}
- height={'auto'}
- GetValue={() => Field.toKeyValueString(this.props.Document, this.props.fieldKey)}
- SetValue={(value: string) => KeyValueBox.SetField(this.props.Document, this.props.fieldKey, value)}
- />
+ <div className="schema-table-cell" style={{ width: this.props.columnWidth }}>
+ <div className="schemacell-edit-wrapper" style={{ cursor: this.props.isRowActive() ? 'text' : 'default' }}>
+ <EditableView
+ contents={<FieldView {...props} />}
+ GetValue={() => Field.toKeyValueString(this.props.Document, this.props.fieldKey)}
+ SetValue={(value: string) => KeyValueBox.SetField(this.props.Document, this.props.fieldKey, value)}
+ editing={this.props.isRowActive() ? undefined : false}
+ />
+ </div>
</div>
);
}