aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSchemaView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/CollectionSchemaView.tsx')
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 7463429e0..bb620cd63 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -290,10 +290,10 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
console.log("columns");
return Cast(this.props.Document.schemaColumns, listSpec(SchemaHeaderField), []);
}
- @computed get childDocs() {
- let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
- return DocListCast(doc[this.props.fieldKey]);
- }
+ // @computed get childDocs() {
+ // let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ // return DocListCast(doc[this.props.fieldKey]);
+ // }
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>[] {
@@ -304,9 +304,8 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
let focusedCol = this._focusedCell.col;
let isEditable = !this._headerIsEditing;// && this.props.isSelected();
- // let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
- // let children = DocListCast(cdoc[this.props.fieldKey]);
- let children = this.childDocs;
+ let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ let children = DocListCast(cdoc[this.props.fieldKey]);
if (children.reduce((found, doc) => found || doc.type === "collection", false)) {
columns.push(
@@ -430,9 +429,9 @@ 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.childDocs;
+ let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ 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;
@@ -526,9 +525,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
let direction = e.key === "Tab" ? "tab" : e.which === 39 ? "right" : e.which === 37 ? "left" : e.which === 38 ? "up" : e.which === 40 ? "down" : "";
this.changeFocusedCellByDirection(direction);
- // let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
- // let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
- let children = this.childDocs;
+ let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
+ // let children = this.childDocs;
const pdoc = FieldValue(children[this._focusedCell.row]);
pdoc && this.props.setPreviewDoc(pdoc);
}
@@ -536,9 +535,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
@action
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.childDocs;
+ let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
+ // let children = this.childDocs;
switch (direction) {
case "tab":
if (this._focusedCell.col + 1 === this.columns.length && this._focusedCell.row + 1 === children.length) {
@@ -579,9 +578,9 @@ 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.childDocs;
+ let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
+ // let children = this.childDocs;
let newDoc = Docs.Create.TextDocument({ width: 100, height: 30 });
let proto = Doc.GetProto(newDoc);
@@ -700,8 +699,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
}
get documentKeys() {
- // const docs = DocListCast(this.props.Document[this.props.fieldKey]);
- let docs = this.childDocs;
+ const docs = DocListCast(this.props.Document[this.props.fieldKey]);
+
+ // 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
@@ -729,9 +729,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
@computed
get reactTable() {
- // let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
- // let children = DocListCast(cdoc[this.props.fieldKey]);
- let children = this.childDocs;
+ let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ let children = DocListCast(cdoc[this.props.fieldKey]);
+ // 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);
@@ -743,7 +743,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
return <ReactTable
style={{ position: "relative", float: "left", width: `calc(100% - ${previewWidth}px` }}
- data={this.childDocs}
+ data={children}
page={0}
pageSize={children.length}
showPagination={false}
@@ -777,7 +777,9 @@ 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.childDocs.map(doc => {
+ let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ let children = DocListCast(cdoc[this.props.fieldKey]);
+ children.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";
});
@@ -796,9 +798,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
getField = (row: number, col?: number) => {
// const docs = DocListCast(this.props.Document[this.props.fieldKey]);
- // let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
- // const docs = DocListCast(cdoc[this.props.fieldKey]);
- let docs = this.childDocs;
+ let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ const docs = DocListCast(cdoc[this.props.fieldKey]);
+ // let docs = this.childDocs;
row = row % docs.length;
while (row < 0) row += docs.length;