aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/EditableView.tsx2
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx18
-rw-r--r--src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx12
3 files changed, 13 insertions, 19 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 1eec11e64..011b6c77a 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -137,9 +137,7 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
if (!e.currentTarget.value) this._props.OnEmpty?.();
break;
case 'Enter':
- console.log("enter press detected")
if (this._props.allowCRs !== true) {
- console.log("noCrs??")
e.stopPropagation();
if (!e.ctrlKey) {
this.finalizeEdit(e.currentTarget.value, e.shiftKey, false, true);
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 2d181a772..3d7c7882e 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -275,9 +275,7 @@ export class CollectionSchemaView extends CollectionSubView() {
changeColumnKey = (index: number, newKey: string, defaultVal?: any) => {
if (!this.documentKeys.includes(newKey)) {
this.addNewKey(newKey, defaultVal);
- console.log("added")
}
- console.log("changed " + index)
const currKeys = this.columnKeys.slice(); // copy the column key array first, then change it.
currKeys[index] = newKey;
@@ -308,6 +306,7 @@ export class CollectionSchemaView extends CollectionSubView() {
});
}
+ // parses a field from the "idToDoc(####)" format to DocumentId (d#) format for readability
cleanupComputedField = (field: string) => {
const idPattern = /idToDoc\((.*?)\)/g;
let modField = field.slice();
@@ -403,7 +402,7 @@ export class CollectionSchemaView extends CollectionSubView() {
};
findColDropIndex = (mouseX: number) => {
- let xOffset: number = this._props.ScreenToLocalTransform().inverse().transformPoint(0,0)[0] + CollectionSchemaView._rowMenuWidth;
+ let xOffset: number = this._props.ScreenToLocalTransform().inverse().transformPoint(0,0)[0] + CollectionSchemaView._rowMenuWidth;
let index: number | undefined;
this.displayColumnWidths.reduce((total, curr, i) => {
if (total <= mouseX && total + curr >= mouseX) {
@@ -466,7 +465,7 @@ export class CollectionSchemaView extends CollectionSubView() {
const edgeStyle = i === index ? `solid 2px ${Colors.MEDIUM_BLUE}` : '';
const cellEles = [
colRef,
- ...this.childDocs //
+ ...this.childDocs
.filter(doc => i !== this._selectedCol || !this._selectedDocs.includes(doc))
.map(doc => this._rowEles.get(doc).children[1].children[i]),
];
@@ -714,7 +713,11 @@ export class CollectionSchemaView extends CollectionSubView() {
@action
setKey = (key: string, defaultVal?: any, index?: number) => {
- console.log("setKey called with" + key)
+ if (this.columnKeys.includes(key)){
+ this._newFieldWarning = 'Field already exists';
+ return;
+ }
+
if (this._makeNewColumn) {
this.addColumn(key, defaultVal);
this._makeNewColumn = false;
@@ -724,12 +727,7 @@ export class CollectionSchemaView extends CollectionSubView() {
this.closeColumnMenu();
};
- setColumnValue = () => {
-
- }
-
setCellValues = (key: string, value: string) => {
- console.log("field: " + key + " vale: " + value);
const selectedDocs: Doc[] = [];
this.childDocs.forEach(doc => {
const docIsSelected = this._selectedCells && !(this._selectedCells?.filter(d => d === doc).length === 0);
diff --git a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
index 794d5d8ac..58ac4e45d 100644
--- a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
@@ -25,8 +25,6 @@ import { FInfo } from '../../../documents/Documents';
export interface SchemaColumnHeaderProps {
Document: Doc;
autoFocus?: boolean;
- oneLine?: boolean; // whether all input should fit on one line vs allowing textare multiline inputs
- allowCRs?: boolean; // allow carriage returns in text input (othewrise CR ends the edit)
columnKeys: string[];
columnWidths: number[];
columnIndex: number;
@@ -123,20 +121,20 @@ export class SchemaColumnHeader extends ObservableReactComponent<SchemaColumnHea
}}>
<EditableView
ref={r => this._props.autoFocus && r?.setIsFocused(true)}
- oneLine={this._props.oneLine}
- allowCRs={this._props.allowCRs}
+ oneLine={true}
+ allowCRs={false}
contents={undefined}
fieldContents={fieldProps}
editing={undefined}
- isColHeader={true}
+ isColHeader={true} // tells the EditableView to display the fieldKey itself, and not its value
GetValue={() => {console.log(this.fieldKey); return this.fieldKey}}
SetValue={undoable((value: string, shiftKey?: boolean, enterKey?: boolean) => {
- if (shiftKey && enterKey) {
+ if (shiftKey && enterKey) { // if shift & enter, set value of each cell in column
this.setColumnValues(value, value);
this._props.finishEdit?.();
return true;
}
- this._props.finishEdit?.();
+ this._props.finishEdit?.(); // else save new value to header field
return true;
}, 'edit column header')}
/>