-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiSamples_results.js
40 lines (33 loc) · 1.11 KB
/
iSamples_results.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
// This is the customized result component of solr-faceted-search-react
import PropTypes from 'prop-types';
import React from "react";
import cx from "classnames";
import { ResultWrapper } from "components/utilities";
class iSamples_Result extends React.Component {
renderValue(field, doc) {
const value = [].concat(doc[field] || null).filter((v) => v !== null);
return value.join(", ");
}
render() {
const { bootstrapCss, doc, fields } = this.props;
return (
<li className={cx({ "list-group-item": bootstrapCss })} onClick={() => this.props.onSelect(doc)}>
<ul>
{fields.filter((field) => field.field !== "*" && field.hidden !== true).map((field, i) =>
<li key={i}>
<label>{field.label || field.field}</label>
<ResultWrapper field={field} value={this.renderValue(field.field, doc)} />
</li>
)}
</ul>
</li>
);
}
}
iSamples_Result.propTypes = {
bootstrapCss: PropTypes.bool,
doc: PropTypes.object,
fields: PropTypes.array,
onSelect: PropTypes.func.isRequired
};
export default iSamples_Result;