-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Externalized VirtualScroll functionalities to be reused - implemented wfsTable enhancer to support auto-data fetch/update with virtual scroll - Added to RequestBuilder sortBy and propertyName support - Add wfs to observable to reuse streams - Provided a getLayerJSONFeature (to extend) for a more rational usage of parameters ( old requests had to manage filterObj was containing sort and pagination options) - Set widgetContainer to be traggable only by header ( the cursor now changes where the widget is draggable) - Add sortable and defaultWidth options to FeatureGrid editor enhancer - Add support for columns resize, memorization and reset - tabular view of attribute selection
- Loading branch information
1 parent
3dc8b5a
commit 62ef950
Showing
49 changed files
with
1,469 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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> | ||
|
||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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 ReactDataGrid = require('react-data-grid'); | ||
const Message = require('../../I18N/Message'); | ||
|
||
module.exports = ({ | ||
style = {}, | ||
titleMsg = "featuregrid.columns", | ||
onChange = () => { }, | ||
attributes = [] | ||
} = {}) => ( | ||
<div className="bg-body data-attribute-selector" style={style}> | ||
<h4 className="text-center"><strong><Message msgId={titleMsg} /></strong></h4> | ||
<ReactDataGrid | ||
rowKey="id" | ||
columns={[{ | ||
name: '', | ||
key: 'attribute' | ||
}]} | ||
rowGetter={idx => attributes[idx]} | ||
rowsCount={attributes.length} | ||
rowSelection={{ | ||
showCheckbox: true, | ||
enableShiftSelect: true, | ||
onRowsSelected: rows => onChange(rows.map(row => attributes[row.rowIdx].name), false), | ||
onRowsDeselected: rows => onChange(rows.map(row => attributes[row.rowIdx].name), true), | ||
selectBy: { | ||
indexes: attributes.reduce( (acc, a, idx) => [...acc, ...(a.hide ? [] : [idx] )], []) | ||
} | ||
}} /> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
web/client/components/data/featuregrid/__tests__/AttributeTable-test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2017, 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. | ||
*/ | ||
var React = require('react'); | ||
var ReactDOM = require('react-dom'); | ||
var AttributeSelector = require('../AttributeTable'); | ||
var expect = require('expect'); | ||
const spyOn = expect.spyOn; | ||
|
||
|
||
describe('Test for AttributeTable component', () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
|
||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
it('render with defaults', () => { | ||
ReactDOM.render(<AttributeSelector/>, document.getElementById("container")); | ||
const el = document.getElementsByClassName("data-attribute-selector")[0]; | ||
expect(el).toExist(); | ||
}); | ||
it('render with attributes, checked by default', () => { | ||
ReactDOM.render(<AttributeSelector attributes={[{label: "label", attribute: "attr"}]}/>, document.getElementById("container")); | ||
const check = document.getElementsByTagName("input")[1]; | ||
expect(check).toExist(); | ||
expect(check.checked).toBe(true); | ||
}); | ||
it('check hide is not selected', () => { | ||
ReactDOM.render(<AttributeSelector attributes={[{label: "label", attribute: "attr", hide: true}]}/>, document.getElementById("container")); | ||
const checks = document.getElementsByTagName("input"); | ||
expect(checks.length).toBe(2); | ||
expect(checks[0].checked).toBe(false); | ||
}); | ||
it('click event', () => { | ||
const events = { | ||
onChange: () => {} | ||
}; | ||
spyOn(events, "onChange"); | ||
ReactDOM.render(<AttributeSelector onChange={events.onChange} attributes={[{label: "label", attribute: "attr", hide: true}]}/>, document.getElementById("container")); | ||
const checks = document.getElementsByTagName("input"); | ||
expect(checks.length).toBe(2); | ||
checks[0].click(); | ||
expect(events.onChange).toHaveBeenCalled(); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.