summaryrefslogtreecommitdiff
path: root/client/table/citations.table.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-04-01 10:23:29 +0200
committerJules Laplace <julescarbon@gmail.com>2019-04-01 10:23:29 +0200
commit0bede27de3bcc0c7f03d16c7607a0ae693daebc7 (patch)
tree20646e82e6b608e452408ad1af24f70fa079387e /client/table/citations.table.js
parentfd5d46b71af450fb582506dc8dd9c8d343d3a5c5 (diff)
citations table in react
Diffstat (limited to 'client/table/citations.table.js')
-rw-r--r--client/table/citations.table.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/client/table/citations.table.js b/client/table/citations.table.js
new file mode 100644
index 00000000..1ec2d10c
--- /dev/null
+++ b/client/table/citations.table.js
@@ -0,0 +1,53 @@
+import React, { Component } from 'react'
+import { bindActionCreators } from 'redux'
+import { connect } from 'react-redux'
+import { ReactTabulator } from 'react-tabulator'
+import { Loader } from '../common'
+import { toArray, toTuples } from '../util'
+
+export const citationsColumns = [
+ { title: 'Title', field: 'title', sorter: 'string' },
+ { title: 'Institution', field: 'institution', sorter: 'string' },
+ { title: 'Country', field: 'country', sorter: 'string', width: 140 },
+ { title: 'Year', field: 'year', sorter: 'number', width: 70 },
+ { title: 'PDF', field: 'pdf_text', formatter: 'link',
+ formatterParams: { target: "_blank", urlField: 'pdf_link', },
+ sorter: 'string', width: 100 },
+]
+
+class CitationsTable extends Component {
+ render() {
+ const { payload } = this.props
+ const { paper, citations } = payload.data
+ console.log(this.props)
+ if (!citations.length) return <Loader />
+
+ const formattedCitations = citations.map(citation => ({
+ title: citation.title,
+ institution: citation.addresses[0].name,
+ country: citation.addresses[0].country,
+ year: citation.year,
+ pdf: (citation.pdf && citation.pdf.length)
+ ? citation.pdf[0]
+ : (citation.doi && citation.doi.length)
+ ? citation.doi[0]
+ : "",
+ }))
+
+ console.log(formattedCitations)
+
+ return (
+ <ReactTabulator
+ columns={citationsColumns}
+ data={formattedCitations}
+ options={{
+ height: 311,
+ layout: 'fitColumns',
+ placeholder: 'No Data Set',
+ }}
+ />
+ )
+ }
+}
+
+export default CitationsTable