-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrow.js
71 lines (63 loc) · 2.23 KB
/
row.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
import React from 'react';
import ColumnHelper from './utils/column-helper';
import { getStyleProperties } from './utils/styleHelper';
class Row extends React.Component {
constructor(props, context) {
super(props, context);
}
render() {
//TODO: Refactor this -- the logic to show / hide columns is kind of rough
// Also, it seems that if we moved this operation to a store, it could be a bit faster
let columns = [];
const { columnProperties,
ignoredColumns,
tableProperties,
rowData,
events,
originalRowData,
rowIndex,
absoluteRowIndex } = this.props;
const { griddleKey } = rowData.__metadata;
//render just the columns that are contained in the metdata
for (var column in rowData) {
//get the additional properties defined in the creation of the object
let columnProperty = ColumnHelper.getColumnPropertyObject(columnProperties, column);
//render the column if there are no properties, there are properties and the column is in the collection OR there are properties and no column properties.
if(ColumnHelper.isColumnVisible(column, {columnProperties, ignoredColumns: ignoredColumns || []})) {
columns.push(<this.props.components.Column
{...this.props}
key={column}
originalRowData={originalRowData}
absoluteRowIndex={absoluteRowIndex}
dataKey={column}
value={rowData[column]}
{...columnProperty}
/>);
}
}
const { style, className } = getStyleProperties(this.props, 'row');
return (
<tr
style={style}
className={className}
onMouseOver={this._handleHover}
onClick={this._onClick}
key={griddleKey}
>
{columns}
</tr>
);
}
//TODO: this can go -- double confirm that nothing is using it
_handleHover = (e) => {
this.props.events.rowHover(this.props.rowIndex, this.props.rowData);
}
//TODO: this can go -- double confirm that nothing is using it
_handleSelect = (e) => {
this.props.events.rowSelect(this.props.rowIndex, this.props.rowData);
}
_onClick = () => {
this.props.events.rowClick(this.props.rowData, this.props.originalRowData)
}
}
export default Row;