-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #2542 Custom Format on Get Feature Info #2591
Changes from 5 commits
5d005f7
9450b79
6de398c
857aaf3
20bd980
a0c6e1b
9d9edc3
68c0dd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
* 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 {Row, Col, Nav, NavItem, Glyphicon} = require('react-bootstrap'); | ||
const DockablePanel = require('../misc/panels/DockablePanel'); | ||
const Toolbar = require('../misc/toolbar/Toolbar'); | ||
const tooltip = require('../misc/enhancers/tooltip'); | ||
const NavItemT = tooltip(NavItem); | ||
const ResizableModal = require('../misc/ResizableModal'); | ||
const Portal = require('../misc/Portal'); | ||
const {head, isObject} = require('lodash'); | ||
const Message = require('../I18N/Message'); | ||
|
||
/** | ||
* Component for rendering TOC Settings as tabs inside a Dockable contanier | ||
* @memberof components.TOC | ||
* @name TOCItemsSettings | ||
* @class | ||
* @prop {dock} dock switch between Dockable Panel and Resizable Modal, default true (DockPanel) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably |
||
* @prop {string} activeTab current active tab, should match the tab id | ||
* @prop {function} getTabs must return an array of object representing the tabs, eg (props) => [{ id: 'general', Component: MyGeneralComponent}] | ||
* @prop {string} className additional calss name | ||
*/ | ||
|
||
module.exports = props => { | ||
const { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not generic, too many properties are dependent on specific item info (e.g. chartStyle, getDimension, generalInfoFormat). If it has to be a generic item setting container component, it should only have reference to generic things (e.g. the item node) |
||
className = '', | ||
activeTab = 'general', | ||
currentLocale = 'en-US', | ||
width = 500, | ||
groups = [], | ||
element = {}, | ||
settings = {}, | ||
getTabs = () => [], | ||
onSave = () => {}, | ||
onClose = () => {}, | ||
onHideSettings = () => {}, | ||
onSetTab = () => {}, | ||
onUpdateParams = () => {}, | ||
onRetrieveLayerData = () => {}, | ||
onShowAlertModal = () => {}, | ||
realtimeUpdate = true, | ||
alertModal = false, | ||
dockStyle = {}, | ||
dock = true, | ||
showFullscreen, | ||
draggable, | ||
position = 'left' | ||
} = props; | ||
|
||
const tabs = getTabs(props); | ||
|
||
return ( | ||
<span> | ||
<DockablePanel | ||
open={settings.expanded} | ||
glyph="wrench" | ||
title={element.title && isObject(element.title) && (element.title[currentLocale] || element.title.default) || element.title || ''} | ||
className={className} | ||
onClose={onClose ? () => { onClose(); } : onHideSettings} | ||
size={width} | ||
style={dockStyle} | ||
showFullscreen={showFullscreen} | ||
dock={dock} | ||
draggable={draggable} | ||
position={position} | ||
header={[ | ||
<Row key="ms-toc-settings-toolbar" className="text-center"> | ||
<Col xs={12}> | ||
<Toolbar | ||
btnDefaultProps={{ bsStyle: 'primary', className: 'square-button-md' }} | ||
buttons={[{ | ||
glyph: 'floppy-disk', | ||
tooltipId: 'save', | ||
visible: !!onSave, | ||
onClick: onSave | ||
}, | ||
...(head(tabs.filter(tab => tab.id === activeTab && tab.toolbar).map(tab => tab.toolbar)) || [])]}/> | ||
</Col> | ||
</Row>, | ||
...(tabs.length > 1 ? [<Row key="ms-toc-settings-navbar" className="ms-row-tab"> | ||
<Col xs={12}> | ||
<Nav bsStyle="tabs" activeKey={activeTab} justified> | ||
{tabs.map(tab => | ||
<NavItemT | ||
key={'ms-tab-settings-' + tab.id} | ||
tooltip={<Message msgId={tab.tooltipId}/> } | ||
eventKey={tab.id} | ||
onClick={() => onSetTab(tab.id)}> | ||
<Glyphicon glyph={tab.glyph}/> | ||
</NavItemT> | ||
)} | ||
</Nav> | ||
</Col> | ||
</Row>] : []) | ||
]}> | ||
{tabs.filter(tab => tab.id && tab.id === activeTab).filter(tab => tab.Component).map(tab => ( | ||
<tab.Component | ||
{...props} | ||
key={'ms-tab-settings-body-' + tab.id} | ||
containerWidth={width} | ||
element={element} | ||
groups={groups} | ||
nodeType={settings.nodeType} | ||
settings={settings} | ||
retrieveLayerData={onRetrieveLayerData} | ||
onChange={(key, value) => onUpdateParams({[key]: value}, realtimeUpdate)}/> | ||
))} | ||
</DockablePanel> | ||
<Portal> | ||
<ResizableModal | ||
fade | ||
show={alertModal} | ||
title={<Message msgId="layerProperties.changedSettings"/>} | ||
size="xs" | ||
onClose={() => onShowAlertModal(false)} | ||
buttons={[ | ||
{ | ||
bsStyle: 'primary', | ||
text: <Message msgId="close"/>, | ||
onClick: () => onClose(true) | ||
}, | ||
{ | ||
bsStyle: 'primary', | ||
text: <Message msgId="save"/>, | ||
onClick: onSave | ||
} | ||
]}> | ||
<div className="ms-alert"> | ||
<div className="ms-alert-center"> | ||
<Message msgId="layerProperties.changedSettingsAlert"/> | ||
</div> | ||
</div> | ||
</ResizableModal> | ||
</Portal> | ||
</span> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,9 @@ const {ButtonGroup, Button, Glyphicon, Tooltip, OverlayTrigger} = require('react | |
const ReactCSSTransitionGroup = require('react-addons-css-transition-group'); | ||
const {head} = require('lodash'); | ||
const ConfirmModal = require('../maps/modals/ConfirmModal'); | ||
const SettingsModal = require('./fragments/SettingsModal'); | ||
const GroupSettingsModal = require('./fragments/GroupSettingsModal'); | ||
// removed from toolbar to avoid conflict with TOCItemsSettings | ||
// const SettingsModal = require('./fragments/SettingsModal'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented code from this file |
||
// const GroupSettingsModal = require('./fragments/GroupSettingsModal'); | ||
const LayerMetadataModal = require('./fragments/LayerMetadataModal'); | ||
|
||
class Toolbar extends React.Component { | ||
|
@@ -135,7 +136,7 @@ class Toolbar extends React.Component { | |
status = this.props.selectedLayers.length > 0 && this.props.selectedLayers.filter(l => l.loadingError === 'Error').length === this.props.selectedLayers.length ? 'LAYERS_LOAD_ERROR' : status; | ||
return status; | ||
} | ||
|
||
/* | ||
getSettingsModal = (status) => { | ||
return status === 'LAYER' ? | ||
(<SettingsModal | ||
|
@@ -164,11 +165,11 @@ class Toolbar extends React.Component { | |
updateNode={this.props.onToolsActions.onUpdate} | ||
updateSettings={this.props.onToolsActions.onUpdateSettings} | ||
hideSettings={this.props.onToolsActions.onHideSettings}/>; | ||
} | ||
}*/ | ||
|
||
render() { | ||
const status = this.getStatus(); | ||
const settingModal = status === 'GROUP' || status === 'LAYER' ? this.getSettingsModal(status) : null; | ||
// const settingModal = status === 'GROUP' || status === 'LAYER' ? this.getSettingsModal(status) : null; | ||
const layerMetadataModal = (<LayerMetadataModal | ||
key="toollayermetadatamodal" | ||
layerMetadata={this.props.layerMetadata} | ||
|
@@ -277,7 +278,7 @@ class Toolbar extends React.Component { | |
confirmText={this.props.text.confirmDeleteText} | ||
cancelText={this.props.text.confirmDeleteCancelText} | ||
body={this.props.text.confirmDeleteMessage} /> | ||
{settingModal} | ||
{/*settingModal*/} | ||
{layerMetadataModal} | ||
</ButtonGroup>) : null; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* 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 expect = require('expect'); | ||
const ReactDOM = require('react-dom'); | ||
const TOCItemsSettings = require('../TOCItemsSettings'); | ||
|
||
|
||
describe("test TOCItemsSettings", () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
|
||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
|
||
it('test with tabs', () => { | ||
ReactDOM.render(<TOCItemsSettings activeTab="general" getTabs={() => [ | ||
{ | ||
id: 'general', | ||
titleId: 'layerProperties.general', | ||
tooltipId: 'layerProperties.general', | ||
glyph: 'wrench', | ||
Component: () => <div id="test-general-body"></div> | ||
}, | ||
{ | ||
id: 'display', | ||
titleId: 'layerProperties.display', | ||
tooltipId: 'layerProperties.display', | ||
glyph: 'eye-open', | ||
Component: () => <div id="test-display-body"></div> | ||
} | ||
]}/>, document.getElementById("container")); | ||
const navBar = document.getElementsByClassName('nav-justified')[0]; | ||
expect(navBar.children.length).toBe(2); | ||
const testGeneralBody = document.getElementById('test-general-body'); | ||
expect(testGeneralBody).toExist(); | ||
const testDisplayBody = document.getElementById('test-display-body'); | ||
expect(testDisplayBody).toNotExist(); | ||
}); | ||
|
||
it('test without tabs', () => { | ||
ReactDOM.render(<TOCItemsSettings activeTab="general" getTabs={() => []}/>, document.getElementById("container")); | ||
const navBar = document.getElementsByClassName('nav-justified')[0]; | ||
expect(navBar).toNotExist(); | ||
}); | ||
|
||
it('test with tabs length 1', () => { | ||
ReactDOM.render(<TOCItemsSettings activeTab="general" getTabs={() => [{ | ||
id: 'general', | ||
titleId: 'layerProperties.general', | ||
tooltipId: 'layerProperties.general', | ||
glyph: 'wrench', | ||
Component: () => <div id="test-general-body"></div> | ||
}]}/>, document.getElementById("container")); | ||
const navBar = document.getElementsByClassName('nav-justified')[0]; | ||
expect(navBar).toNotExist(); | ||
const testGeneralBody = document.getElementById('test-general-body'); | ||
expect(testGeneralBody).toExist(); | ||
}); | ||
|
||
it('test alert modal', () => { | ||
ReactDOM.render(<TOCItemsSettings alertModal/>, document.getElementById("container")); | ||
const alertModal = document.getElementsByClassName('ms-resizable-modal'); | ||
expect(alertModal.length).toBe(1); | ||
}); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please describe what is this component usable for