aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSchemaView.tsx
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-05-21 16:37:41 -0400
committerab <abdullah_ahmed@brown.edu>2019-05-21 16:37:41 -0400
commit33c29d0e58c1b083e72df7e7fd81bb130f46bd2a (patch)
treef87bd33e2d98ce2752abec9d189de0de5161fddb /src/client/views/collections/CollectionSchemaView.tsx
parentb3f1e5f60ee4a00522d3e4b0b03495685bde006c (diff)
parent7e5ba95b02e4ead3ee2b41eca1af0acb72d6f7cd (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into cont_menu_ui
Diffstat (limited to 'src/client/views/collections/CollectionSchemaView.tsx')
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index b25b48339..bfd70ceae 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -68,7 +68,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
return this.columns.map(col => {
const ref = React.createRef<HTMLParagraphElement>();
return {
- Header: <p ref={ref} onPointerDown={SetupDrag(ref, () => this.onHeaderDrag(col))}>{col}</p>,
+ Header: <p ref={ref} onPointerDown={SetupDrag(ref, () => this.onHeaderDrag(col), undefined, "copy")}>{col}</p>,
accessor: (doc: Doc) => doc ? doc[col] : 0,
id: col
};
@@ -76,6 +76,15 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
}
onHeaderDrag = (columnName: string) => {
+ let dbDoc = Cast(this.props.Document.DBDoc, Doc);
+ if (dbDoc instanceof Doc) {
+ let columnDocs = DocListCast(dbDoc.data);
+ if (columnDocs) {
+ let ddoc = columnDocs.find(doc => doc.title === columnName);
+ if (ddoc)
+ return ddoc;
+ }
+ }
return this.props.Document;
}
@@ -115,22 +124,20 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
height={Number(MAX_ROW_HEIGHT)}
GetValue={() => {
let field = props.Document[props.fieldKey];
- if (field) {
- //TODO Types
- // return field.ToScriptString();
- return String(field);
+ if (Field.IsField(field)) {
+ return Field.toScriptString(field);
}
return "";
}}
SetValue={(value: string) => {
- let script = CompileScript(value, { addReturn: true, params: { this: Document.name } });
+ let script = CompileScript(value, { addReturn: true, params: { this: Doc.name } });
if (!script.compiled) {
return false;
}
return applyToDoc(props.Document, script.run);
}}
OnFillDown={async (value: string) => {
- let script = CompileScript(value, { addReturn: true, params: { this: Document.name } });
+ let script = CompileScript(value, { addReturn: true, params: { this: Doc.name } });
if (!script.compiled) {
return;
}
@@ -237,7 +244,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
csv = csv.substr(0, csv.length - 1) + "\n";
let self = this;
DocListCast(this.props.Document.data).map(doc => {
- csv += self.columns.reduce((val, col) => val + (doc[col] ? doc[col]!.toString() : "") + ",", "");
+ csv += self.columns.reduce((val, col) => val + (doc[col] ? doc[col]!.toString() : "0") + ",", "");
csv = csv.substr(0, csv.length - 1) + "\n";
});
csv.substring(0, csv.length - 1);
@@ -246,7 +253,8 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
if (self.props.CollectionView.props.addDocument) {
let schemaDoc = await Docs.DBDocument("https://www.cs.brown.edu/" + dbName, { title: dbName });
if (schemaDoc) {
- self.props.CollectionView.props.addDocument(schemaDoc, false);
+ //self.props.CollectionView.props.addDocument(schemaDoc, false);
+ self.props.Document.DBDoc = schemaDoc;
}
}
}