forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTableWidget.jsx
74 lines (69 loc) · 2.79 KB
/
TableWidget.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
70
71
72
73
74
/*
* Copyright 2018, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
const React = require('react');
const Message = require('../../I18N/Message');
const loadingState = require('../../misc/enhancers/loadingState');
const FeatureGrid = loadingState(({ describeFeatureType }) => !describeFeatureType)(require('../../data/featuregrid/FeatureGrid'));
const InfoPopover = require('./InfoPopover');
const WidgetContainer = require('./WidgetContainer');
const {
Glyphicon,
ButtonToolbar,
DropdownButton,
MenuItem
} = require('react-bootstrap');
const renderHeaderLeftTopItem = ({ title, description }) => {
return title || description ? <InfoPopover placement="top" title={title} text={description} /> : null;
};
module.exports = ({
id,
title,
description,
loading,
confirmDelete = false,
toggleTableView = () => { },
toggleDeleteConfirm = () => { },
exportCSV = () => { },
onEdit = () => { },
onDelete = () => { },
pageEvents = {
moreFeatures: () => {}
},
describeFeatureType,
features,
size,
pages,
pagination = {},
virtualScroll = true
}) =>
(<WidgetContainer
id={`widget-chart-${id}`}
title={title}
topLeftItems={renderHeaderLeftTopItem({ loading, title, description, toggleTableView })}
confirmDelete={confirmDelete}
onDelete={onDelete}
toggleDeleteConfirm={toggleDeleteConfirm}
topRightItems={<ButtonToolbar>
<DropdownButton pullRight bsStyle="default" className="widget-menu" title={<Glyphicon glyph="option-vertical" />} noCaret id="dropdown-no-caret">
<MenuItem onClick={() => toggleTableView()} eventKey="1"><Glyphicon glyph="features-grid" /> <Message msgId="widgets.widget.menu.showChartData" /></MenuItem>
<MenuItem onClick={() => onEdit()} eventKey="3"><Glyphicon glyph="pencil" /> <Message msgId="widgets.widget.menu.edit" /></MenuItem>
<MenuItem onClick={() => toggleDeleteConfirm(true)} eventKey="2"><Glyphicon glyph="trash" /> <Message msgId="widgets.widget.menu.delete" /></MenuItem>
<MenuItem onClick={() => exportCSV({ title })} eventKey="4"><Glyphicon className="exportCSV" glyph="download" /> <Message msgId="widgets.widget.menu.downloadData" /></MenuItem>
</DropdownButton>
</ButtonToolbar>}>
<FeatureGrid
pageEvents={pageEvents}
virtualScroll={virtualScroll}
features={features}
pages={pages}
size={size}
rowKey="id"
describeFeatureType={describeFeatureType}
pagination={pagination} />
</WidgetContainer>
);