-
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
Merged
offtherailz
merged 8 commits into
geosolutions-it:master
from
allyoucanmap:gfi-mrkdwn-custom
Feb 21, 2018
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5d005f7
Added custom format in get feature info
allyoucanmap 9450b79
Updated icons
allyoucanmap 6de398c
Changed name of enhancer
allyoucanmap 857aaf3
Fixes from review
allyoucanmap 20bd980
Upadted warning modal of identify container
allyoucanmap a0c6e1b
Fixes from review
allyoucanmap 9d9edc3
Updated position absolute style of DockPanel
allyoucanmap 68c0dd4
Updated translations
allyoucanmap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,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 {boolean} dock switch between Dockable Panel and Resizable Modal, default true (DockPanel) | ||
* @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 ( | ||
<div> | ||
<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> | ||
</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
77 changes: 77 additions & 0 deletions
77
web/client/components/TOC/__tests__/TOCItemsSettings-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,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); | ||
}); | ||
|
||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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