aboutsummaryrefslogtreecommitdiff
path: root/src/views/collections/CollectionSchemaView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/collections/CollectionSchemaView.tsx')
-rw-r--r--src/views/collections/CollectionSchemaView.tsx49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/views/collections/CollectionSchemaView.tsx b/src/views/collections/CollectionSchemaView.tsx
new file mode 100644
index 000000000..01a5ab639
--- /dev/null
+++ b/src/views/collections/CollectionSchemaView.tsx
@@ -0,0 +1,49 @@
+import { CollectionViewProps, DocumentFieldViewProps } from "../nodes/DocumentView";
+import React = require("react")
+import ReactTable, { ReactTableDefaults, CellInfo } from "react-table";
+import { observer } from "mobx-react";
+import { KeyStore as KS, Key } from "../../fields/Key";
+import { Document } from "../../fields/Document";
+import { FieldView } from "../nodes/FieldView";
+import "react-table/react-table.css"
+
+@observer
+export class CollectionSchemaView extends React.Component<CollectionViewProps> {
+ public static LayoutString() { return '<CollectionSchemaView Document={Document} fieldKey={DataKey} ContainingDocumentView={ContainingDocumentView}/>'; }
+
+ renderCell = (rowProps: CellInfo) => {
+ if (!this.props.ContainingDocumentView) {
+ return <div></div>
+ }
+ let props: DocumentFieldViewProps = {
+ doc: rowProps.value[0],
+ fieldKey: rowProps.value[1],
+ containingDocumentView: this.props.ContainingDocumentView
+ }
+ return <FieldView {...props} />
+ }
+
+ render() {
+ const { Document, fieldKey } = this.props;
+ const children = Document.GetListField<Document>(fieldKey, []);
+ const columns = Document.GetListField(KS.ColumnsKey,
+ [KS.Title, KS.Data, KS.Author])
+ return (
+ <ReactTable
+ data={children}
+ columns={columns.map(col => {
+ return (
+ {
+ Header: col.Name,
+ accessor: (doc: Document) => [doc, col],
+ id: col.Id
+ })
+ })}
+ column={{
+ ...ReactTableDefaults.column,
+ Cell: this.renderCell
+ }}
+ />
+ )
+ }
+} \ No newline at end of file