-
Notifications
You must be signed in to change notification settings - Fork 316
/
main_map_page.jsx
69 lines (56 loc) · 2.42 KB
/
main_map_page.jsx
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
import React, {PropTypes, Component} from 'react/addons';
import shouldPureComponentUpdate from 'react-pure-render/function';
import MainMapLayout from './main_map_layout.jsx';
import IceTable from 'components/controls/fixed_table_examples/ice_table.jsx';
import MainMapBlock from './main_map_block.jsx';
import { Connector } from 'redux/react';
import { bindActionCreators } from 'redux';
import * as allMapActions from 'actions/map_actions.js';
// slice actions to support map and table interfaces
const mapActions = (({ changeBounds: onBoundsChange, markerHoverIndexChange: onMarkerHover, showBallon: onChildClick}) => ({
onBoundsChange, onMarkerHover, onChildClick
}))(allMapActions);
const tableActions = (({ tableHoveredRowIndexChange: onHoveredRowIndexChange, tableVisibleRowsChange: onVisibleRowsChange, showBallon: onRowClick}) => ({
onHoveredRowIndexChange, onVisibleRowsChange, onRowClick
}))(allMapActions);
export default class MainMapPage extends Component {
static propTypes = {
layout: PropTypes.string
};
shouldComponentUpdate = shouldPureComponentUpdate;
constructor(props) {
super(props);
}
_renderMap() {
return (
<Connector select={state => ({
center: state.map.get('mapInfo').get('center'),
zoom: state.map.get('mapInfo').get('zoom'),
markers: state.map.get('dataFiltered'),
visibleRowFirst: state.map.get('tableRowsInfo').get('visibleRowFirst'),
visibleRowLast: state.map.get('tableRowsInfo').get('visibleRowLast'),
maxVisibleRows: state.map.get('tableRowsInfo').get('maxVisibleRows'),
hoveredRowIndex: state.map.get('tableRowsInfo').get('hoveredRowIndex'),
openBallonIndex: state.map.get('openBalloonIndex')
})}>
{({dispatch, ...mapProps}) => (<MainMapBlock {...mapProps} {...bindActionCreators(mapActions, dispatch)} />)}
</Connector>
);
}
_renderTable() {
return (
<Connector select={state => ({
markers: state.map.get('dataFiltered'),
hoveredMapRowIndex: state.map.get('hoverMarkerIndex'),
resetToStartObj: state.map.get('mapInfo')
})}>
{({dispatch, ...tableProps}) => (<IceTable {...tableProps} {...bindActionCreators(tableActions, dispatch)} />)}
</Connector>
);
}
render() {
return (
<MainMapLayout layout={this.props.layout} renderMap={this._renderMap} renderTable={this._renderTable} />
);
}
}