aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/EditableView.tsx6
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx19
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx6
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx28
4 files changed, 43 insertions, 16 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 164b6c57a..d1311a60a 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -106,6 +106,12 @@ export class EditableView extends React.Component<EditableProps> {
case ':':
this.props.menuCallback?.(e.currentTarget.getBoundingClientRect().x, e.currentTarget.getBoundingClientRect().y);
break;
+ case 'ArrowUp':
+ case 'ArrowDown':
+ case 'ArrowLeft':
+ case 'ArrowRight':
+ e.stopPropagation();
+ break;
case 'Shift':
case 'Alt':
case 'Meta':
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 92a04f5ec..8cd307adf 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -1,6 +1,6 @@
import React = require('react');
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, computed, observable, ObservableMap, untracked } from 'mobx';
+import { action, computed, observable, ObservableMap, trace, untracked } from 'mobx';
import { observer } from 'mobx-react';
import { computedFn } from 'mobx-utils';
import { Doc, DocListCast, Field, StrListCast } from '../../../../fields/Doc';
@@ -170,12 +170,12 @@ export class CollectionSchemaView extends CollectionSubView() {
const lastDoc = this._selectedDocs.lastElement();
const lastIndex = this.rowIndex(lastDoc);
const curDoc = this.sortedDocs.docs[lastIndex];
- // const curDoc = this.childDocs[lastIndex];
if (lastIndex >= 0 && lastIndex < this.childDocs.length - 1) {
!e.shiftKey && this.clearSelection();
const newDoc = this.sortedDocs.docs[lastIndex + 1];
- if (this._selectedDocs.includes(newDoc)) SelectionManager.DeselectView(DocumentManager.Instance.getFirstDocumentView(curDoc));
- else {
+ if (this._selectedDocs.includes(newDoc)) {
+ SelectionManager.DeselectView(DocumentManager.Instance.getFirstDocumentView(curDoc));
+ } else {
this.addDocToSelection(newDoc, e.shiftKey, lastIndex + 1);
this._selectedCell && (this._selectedCell[0] = newDoc);
this.scrollToDoc(newDoc, {});
@@ -189,7 +189,6 @@ export class CollectionSchemaView extends CollectionSubView() {
{
const firstDoc = this._selectedDocs.lastElement();
const firstIndex = this.rowIndex(firstDoc);
- // const curDoc = this.childDocs[firstIndex];
const curDoc = this.sortedDocs.docs[firstIndex];
if (firstIndex > 0 && firstIndex < this.childDocs.length) {
!e.shiftKey && this.clearSelection();
@@ -224,7 +223,7 @@ export class CollectionSchemaView extends CollectionSubView() {
break;
}
case 'Escape': {
- this._selectedCell = undefined;
+ this.deselectCell();
}
}
}
@@ -425,6 +424,11 @@ export class CollectionSchemaView extends CollectionSubView() {
this._selectedCell = [doc, index];
};
+ @action
+ deselectCell = () => {
+ this._selectedCell = undefined;
+ };
+
sortedSelectedDocs = () => this.sortedDocs.docs.filter(doc => this._selectedDocs.includes(doc));
setDropIndex = (index: number) => (this._closestDropIndex = index);
@@ -456,7 +460,7 @@ export class CollectionSchemaView extends CollectionSubView() {
return true;
}
const draggedDocs = de.complete.docDragData?.draggedDocuments;
- if (draggedDocs && super.onInternalDrop(e, de)) {
+ if (draggedDocs && super.onInternalDrop(e, de) && !this.sortField) {
const pushedDocs = this.childDocs.filter((doc, index) => index >= this._closestDropIndex && !draggedDocs.includes(doc));
const pushedAndDraggedDocs = [...pushedDocs, ...draggedDocs];
const removed = this.childDocs.slice().filter(doc => !pushedAndDraggedDocs.includes(doc));
@@ -829,6 +833,7 @@ export class CollectionSchemaView extends CollectionSubView() {
}
@computed get sortedDocs() {
+ trace();
const field = StrCast(this.layoutDoc.sortField);
const desc = BoolCast(this.layoutDoc.sortDesc);
const docs = !field
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index f5a16cec0..9864820a3 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -28,6 +28,8 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
return vpath.length > 1 ? (vpath[vpath.length - 2].ComponentView as CollectionSchemaView) : undefined;
}
+ schemaViewFunc = () => this.schemaView;
+
@computed get schemaDoc() {
return this.props.DocumentView?.().props.docViewPath().lastElement()?.rootDoc;
}
@@ -124,11 +126,11 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
key={key}
Document={this.rootDoc}
col={index}
- schemaView={this.schemaView}
+ schemaView={this.schemaViewFunc}
fieldKey={key}
columnWidth={this.schemaView?.displayColumnWidths[index] ?? CollectionSchemaView._minColWidth}
isRowActive={this.props.isContentActive}
- setColumnValues={(field, value) => this.schemaView?.setColumnValues(field, value) ?? false}
+ // setColumnValues={(field, value) => this.schemaView?.setColumnValues(field, value) ?? false}
/>
))}
</div>
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index 2b61ea261..374b92d72 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -21,11 +21,11 @@ import { SelectionManager } from '../../../util/SelectionManager';
export interface SchemaTableCellProps {
Document: Doc;
col: number;
- schemaView: CollectionSchemaView | undefined;
+ schemaView: () => CollectionSchemaView | undefined;
fieldKey: string;
columnWidth: number;
isRowActive: () => boolean | undefined;
- setColumnValues: (field: string, value: string) => boolean;
+ // setColumnValues: (field: string, value: string) => boolean;
}
@observer
@@ -33,20 +33,34 @@ export class SchemaTableCell extends React.Component<SchemaTableCellProps> {
private _editorRef: EditableView | null = null;
@computed get readOnly() {
- return this.props.schemaView?.fieldInfos[this.props.fieldKey]?.readOnly ?? false;
+ return this.props.schemaView()?.fieldInfos[this.props.fieldKey]?.readOnly ?? false;
}
@computed get selected() {
- const selected: [Doc, number] | undefined = this.props.schemaView?._selectedCell;
+ const selected: [Doc, number] | undefined = this.props.schemaView()?._selectedCell;
return this.props.isRowActive() && selected && selected[0] == this.props.Document && selected[1] == this.props.col;
}
componentDidUpdate() {
if (!this.selected) {
this._editorRef?.setIsFocused(false);
+ document.removeEventListener('keydown', this.onKeyDown);
+ } else if (!this.readOnly) {
+ document.addEventListener('keydown', this.onKeyDown);
}
}
+ @action
+ onKeyDown = (e: KeyboardEvent) => {
+ e.stopPropagation();
+ if (e.key == 'Enter') {
+ this._editorRef?.setIsFocused(true);
+ }
+ if (e.key == 'Escape') {
+ this.props.schemaView()?.deselectCell();
+ }
+ };
+
get defaultCellContent() {
const props: FieldViewProps = {
Document: this.props.Document,
@@ -81,7 +95,7 @@ export class SchemaTableCell extends React.Component<SchemaTableCellProps> {
GetValue={() => Field.toKeyValueString(this.props.Document, this.props.fieldKey)}
SetValue={(value: string, shiftDown?: boolean, enterKey?: boolean) => {
if (shiftDown && enterKey) {
- this.props.setColumnValues(this.props.fieldKey, value);
+ // this.props.setColumnValues(this.props.fieldKey, value);
}
return KeyValueBox.SetField(this.props.Document, this.props.fieldKey, value);
}}
@@ -92,7 +106,7 @@ export class SchemaTableCell extends React.Component<SchemaTableCellProps> {
}
get getCellType() {
- const columnTypeStr = this.props.schemaView?.fieldInfos[this.props.fieldKey]?.fieldType;
+ const columnTypeStr = this.props.schemaView()?.fieldInfos[this.props.fieldKey]?.fieldType;
if (columnTypeStr) {
if (columnTypeStr in FInfotoColType) {
return FInfotoColType[columnTypeStr];
@@ -125,7 +139,7 @@ export class SchemaTableCell extends React.Component<SchemaTableCellProps> {
<div
className="schema-table-cell"
onPointerDown={action(e => {
- if (!this.selected) this.props.schemaView?.selectCell(this.props.Document, this.props.col);
+ if (!this.selected) this.props.schemaView()?.selectCell(this.props.Document, this.props.col);
})}
style={{ width: this.props.columnWidth, border: this.selected ? `solid 2px ${Colors.MEDIUM_BLUE}` : undefined }}>
{this.content}