aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionSchema/SchemaTable.tsx
diff options
context:
space:
mode:
authorAubrey Li <Aubrey-Li>2021-10-26 17:16:16 -0400
committerAubrey Li <Aubrey-Li>2021-10-26 17:16:16 -0400
commit34ce1ba0275406aff180a49f99d333ffa0d86e3b (patch)
tree25e8ae29b145e5e1e33c59e285f3b29f5a481dc5 /src/client/views/collections/collectionSchema/SchemaTable.tsx
parent3c1b393732ef9dc704a2f40b103c37b3f8370ba7 (diff)
parent48d5e650ddc8caa8252561bbc91961f2f4677d6e (diff)
Merge branch 'master' into trails-aubrey
Diffstat (limited to 'src/client/views/collections/collectionSchema/SchemaTable.tsx')
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTable.tsx16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/client/views/collections/collectionSchema/SchemaTable.tsx b/src/client/views/collections/collectionSchema/SchemaTable.tsx
index 3833f968b..bc5a9559f 100644
--- a/src/client/views/collections/collectionSchema/SchemaTable.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTable.tsx
@@ -1,7 +1,7 @@
import React = require("react");
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, computed, observable } from "mobx";
+import { action, computed, observable, trace } from "mobx";
import { observer } from "mobx-react";
import ReactTable, { CellInfo, Column, ComponentPropsGetterR, Resize, SortingRule } from "react-table";
import "react-table/react-table.css";
@@ -386,13 +386,13 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
@undoBatch
@action
createColumn = () => {
- let index = 0;
- let found = this.props.columns.findIndex(col => col.heading.toUpperCase() === "New field".toUpperCase()) > -1;
- while (found) {
- index++;
- found = this.props.columns.findIndex(col => col.heading.toUpperCase() === ("New field (" + index + ")").toUpperCase()) > -1;
+ const newFieldName = (index: number) => `New field${index ? ` (${index})` : ""}`;
+ for (let index = 0; index < 100; index++) {
+ if (this.props.columns.findIndex(col => col.heading === newFieldName(index)) === -1) {
+ this.props.columns.push(new SchemaHeaderField(newFieldName(index), "#f1efeb"));
+ break;
+ }
}
- this.props.columns.push(new SchemaHeaderField(`New field ${index ? "(" + index + ")" : ""}`, "#f1efeb"));
}
@action
@@ -567,7 +567,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
<div className="collectionSchemaView-documentPreview" ref="overlay"
style={{
position: "absolute", width: 150, height: 150,
- background: "dimGray", display: "block", top: 0, left: 0,
+ background: "dimgray", display: "block", top: 0, left: 0,
transform: `translate(${this._showDocPos[0]}px, ${this._showDocPos[1] - 180}px)`
}} >
<DocumentView