-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathListEntry.js
89 lines (75 loc) · 3.45 KB
/
ListEntry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React from 'react';
import PDFModal from './PDFModal';
import PDFPreviewModal from './PDFPreviewModal';
import HighlightableText from '../HighlightableText';
import { observer } from 'mobx-react';
import { onListClick } from '../../eventhandlers/ListEvents';
import {Button} from 'react-bootstrap';
/* eslint-disable jsx-a11y/href-no-hash */
/**
* ListEntry component
* Sets content and styling of a list entry according to state and renders it;
* @type {<T extends IReactComponent>(clazz: T) => void | IReactComponent | (function({store?: *, paper?: *}))}
*/
const ListEntry =
observer(
({store, paper}) => {
// TODO clear this mess up
const abstract = paper.clicked ? paper.paper_abstract : paper.paper_abstract.slice(0, 300) + '...';
const listEntryClassName = paper.clicked ? "list_entry_full" : "list_entry";
const openAccessLogo = paper.oa ?
<span id="open-access-logo_list">open access <span
className="outlink_symbol"></span></span> : '';
const authors = (paper.authors);
const htmlLink = <Button bsStyle="info" bsSize="xsmall" href={paper.oa_link} target="_blank"> HTML <span className="outlink_symbol"></span></Button>;
const pdfLink = paper.oa ? <PDFModal link={paper.oa_link_pdf}/> : '';
const listTitleClass = paper.oa ? 'list_title oa' : 'list_title';
const highlightStrings = store.searchString.split(' ');
const preview = (paper.clicked && paper.oa)?
<PDFPreviewModal link={paper.oa_link_pdf}/> : '';
return (
/* HTML starts here */
<div id="list_holder">
<div className={listEntryClassName}>
<div className="list_metadata">
<div className={listTitleClass} onClick={onListClick.bind(this, paper, store)}>
{openAccessLogo}
<a href="#" id="paper_list_title" className="highlightable">
<HighlightableText highlightStrings={highlightStrings} value={paper.title}/></a>
</div>
<div className="list_links">
{htmlLink}
{pdfLink}
</div>
<div className="list_details highlightable">
<span className="list_authors">
<HighlightableText highlightStrings={highlightStrings} value={authors} />
</span>
<span className="list_in"> in </span>
<span className="list_published_in">{paper.published_in}</span>
<span className="list_pubyear">
(<HighlightableText highlightStrings={highlightStrings} value={paper.year} />)
</span>
</div>
</div>
<div className="highlightable">
<p id="list_abstract">
<HighlightableText highlightStrings={highlightStrings} value={abstract} />
</p>
</div>
<div id="list_area">
<span className="area_tag">Area:</span> <span className="area_name">
<HighlightableText highlightStrings={highlightStrings} value={paper.area}/>
</span>
</div>
<div className="list_readers">
<span className="num_readers">{paper.readers}</span> <span className="list_readers_entity">{store.config.sortOptions['readers']}</span>
</div>
</div>
{preview}
</div>
/* HTML ends here */
);
}
);
export default ListEntry;