diff options
-rw-r--r-- | src/client/views/collections/CollectionSchemaView.tsx | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index 77ed2d8dc..8436b22a4 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -289,6 +289,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { @computed get columns() { return Cast(this.props.Document.schemaColumns, listSpec(SchemaHeaderField), []); } + @computed get childDocs() { return this.props.childDocs; } set columns(columns: SchemaHeaderField[]) { this.props.Document.schemaColumns = new List<SchemaHeaderField>(columns); } @computed get borderWidth() { return Number(COLLECTION_BORDER_WIDTH); } @computed get tableColumns(): Column<Doc>[] { @@ -301,7 +302,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { // let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document; // let children = DocListCast(cdoc[this.props.fieldKey]); - let children = this.props.childDocs; + let children = this.childDocs; if (children.reduce((found, doc) => found || doc.type === "collection", false)) { columns.push( @@ -425,8 +426,8 @@ export class SchemaTable extends React.Component<SchemaTableProps> { tableRemoveDoc = (document: Doc): boolean => { let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document; - // let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []); - let children = this.props.childDocs; + let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []); + // let children = this.childDocs; if (children.indexOf(document) !== -1) { children.splice(children.indexOf(document), 1); return true; @@ -522,7 +523,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document; // let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []); - let children = this.props.childDocs; + let children = this.childDocs; const pdoc = FieldValue(children[this._focusedCell.row]); pdoc && this.props.setPreviewDoc(pdoc); } @@ -532,7 +533,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { changeFocusedCellByDirection = (direction: string): void => { let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document; // let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []); - let children = this.props.childDocs; + let children = this.childDocs; switch (direction) { case "tab": if (this._focusedCell.col + 1 === this.columns.length && this._focusedCell.row + 1 === children.length) { @@ -575,7 +576,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { createRow = () => { let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document; // let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []); - let children = this.props.childDocs; + let children = this.childDocs; let newDoc = Docs.Create.TextDocument({ width: 100, height: 30 }); let proto = Doc.GetProto(newDoc); @@ -688,7 +689,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { get documentKeys() { // const docs = DocListCast(this.props.Document[this.props.fieldKey]); - let docs = this.props.childDocs; + let docs = this.childDocs; let keys: { [key: string]: boolean } = {}; // bcz: ugh. this is untracked since otherwise a large collection of documents will blast the server for all their fields. // then as each document's fields come back, we update the documents _proxies. Each time we do this, the whole schema will be @@ -718,7 +719,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document; // let children = DocListCast(cdoc[this.props.fieldKey]); - let children = this.props.childDocs; + let children = this.childDocs; let previewWidth = this.previewWidth(); // + 2 * this.borderWidth + this.DIVIDER_WIDTH + 1; let hasCollectionChild = children.reduce((found, doc) => found || doc.type === "collection", false); @@ -730,7 +731,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { return <ReactTable style={{ position: "relative", float: "left", width: `calc(100% - ${previewWidth}px` }} - data={children} + data={this.childDocs} page={0} pageSize={children.length} showPagination={false} @@ -764,7 +765,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { let csv: string = this.columns.reduce((val, col) => val + col + ",", ""); csv = csv.substr(0, csv.length - 1) + "\n"; let self = this; - this.props.childDocs.map(doc => { + this.childDocs.map(doc => { csv += self.columns.reduce((val, col) => val + (doc[col.heading] ? doc[col.heading]!.toString() : "0") + ",", ""); csv = csv.substr(0, csv.length - 1) + "\n"; }); @@ -785,7 +786,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> { let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document; // const docs = DocListCast(cdoc[this.props.fieldKey]); - let docs = this.props.childDocs; + let docs = this.childDocs; row = row % docs.length; while (row < 0) row += docs.length; |