diff options
| author | bob <bcz@cs.brown.edu> | 2019-05-21 12:35:36 -0400 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2019-05-21 12:35:36 -0400 |
| commit | 7bafa21e8c37826686a012151674b71631fa9c8b (patch) | |
| tree | dd313df373c15f67a253eea249339ba8567a2ace /src/client/views/collections/CollectionSchemaView.tsx | |
| parent | 3abf1b817a5ed0e2bcacaa08f4a15a9193794a3a (diff) | |
fixed dragging headers for histograms
Diffstat (limited to 'src/client/views/collections/CollectionSchemaView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionSchemaView.tsx | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index b25b48339..c42a0332d 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; } @@ -237,7 +246,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 +255,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; } } } |
