-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
585f1e5
commit 8725daa
Showing
18 changed files
with
220 additions
and
196 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
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
This file was deleted.
Oops, something went wrong.
109 changes: 109 additions & 0 deletions
109
bundles/mapping/mapmodule/publisher/toolbar/ToolbarTool.js
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,109 @@ | ||
import { AbstractPublisherTool } from '../../../../framework/publisher2/tools/AbstractPublisherTool'; | ||
import { ToolbarToolComponent } from './ToolbarToolComponent'; | ||
import { ToolbarToolHandler } from './ToolbarToolHandler'; | ||
class ToolbarTool extends AbstractPublisherTool { | ||
constructor (...args) { | ||
super(...args); | ||
this.index = 1; | ||
this.group = 'additional'; | ||
this.handler = new ToolbarToolHandler(this); | ||
} | ||
|
||
init (data) { | ||
super.init(data); | ||
const buttons = this.state?.pluginConfig?.buttons; | ||
if (!buttons) { | ||
return; | ||
} | ||
|
||
const handlerConfig = { | ||
history_forward: false, | ||
history_back: false, | ||
measureline: false, | ||
measurearea: false | ||
}; | ||
|
||
const plugin = this.getPlugin(); | ||
buttons.forEach((key) => { handlerConfig[key] = true; plugin.addToolButton(key); }); | ||
this.handler.init(handlerConfig); | ||
} | ||
|
||
getTool () { | ||
const state = this.handler.getState(); | ||
const buttons = Object.keys(state).filter((key) => !!state[key]); | ||
return { | ||
id: 'Oskari.mapframework.bundle.mapmodule.plugin.PublisherToolbarPlugin', | ||
title: Oskari.getMsg('MapModule', 'publisherTools.PublisherToolbarPlugin.toolLabel'), | ||
config: { | ||
...(this.state.pluginConfig || {}), | ||
toolbarId: 'PublisherToolbar', | ||
buttons: buttons || {} | ||
} | ||
}; | ||
} | ||
|
||
getComponent () { | ||
return { | ||
component: ToolbarToolComponent, | ||
handler: this.handler | ||
}; | ||
} | ||
|
||
/** | ||
* Get values. | ||
* @method getValues | ||
* @public | ||
* | ||
* @returns {Object} tool value object | ||
*/ | ||
getValues () { | ||
if (!this.isEnabled()) { | ||
return null; | ||
} | ||
|
||
const buttons = []; | ||
const state = this.handler.getState(); | ||
for (const toolName in state) { | ||
if (state[toolName]) { | ||
buttons.push(toolName); | ||
} | ||
} | ||
|
||
const pluginConfig = this.getPlugin().getConfig(); | ||
pluginConfig.buttons = buttons; | ||
|
||
const retValue = { | ||
configuration: { | ||
mapfull: { | ||
conf: { | ||
plugins: [{ id: this.getTool().id, config: pluginConfig }] | ||
} | ||
}, | ||
toolbar: { | ||
conf: { | ||
history: false, | ||
basictools: false, | ||
viewtools: false | ||
} | ||
} | ||
} | ||
}; | ||
return retValue; | ||
} | ||
|
||
hasActiveTools () { | ||
const state = this.handler.getState(); | ||
return Object.keys(state) | ||
.some(toolName => state[toolName] === true); | ||
} | ||
} | ||
|
||
// Attach protocol to make this discoverable by Oskari publisher | ||
Oskari.clazz.defineES('Oskari.publisher.ToolbarTool', | ||
ToolbarTool, | ||
{ | ||
protocol: ['Oskari.mapframework.publisher.Tool'] | ||
} | ||
); | ||
|
||
export { ToolbarTool }; |
32 changes: 32 additions & 0 deletions
32
bundles/mapping/mapmodule/publisher/toolbar/ToolbarToolComponent.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,32 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Message, Checkbox } from 'oskari-ui'; | ||
import styled from 'styled-components'; | ||
|
||
const Col = styled('div')` | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
export const ToolbarToolComponent = ({ state, controller }) => { | ||
// eslint-disable-next-line camelcase | ||
const { history_forward, history_back, measureline, measurearea } = state; | ||
// eslint-disable-next-line camelcase | ||
const history = (history_back || history_forward); | ||
return <Col> | ||
<Checkbox checked={history} onChange={evt => controller.historySelectionChanged(evt.target.checked)}> | ||
<Message bundleKey={'Publisher2'} messageKey={'BasicView.maptools.toolbarToolNames.history'}/> | ||
</Checkbox> | ||
<Checkbox checked={measureline} onChange={evt => controller.selectionChanged('measureline', evt.target.checked)}> | ||
<Message bundleKey={'Publisher2'} messageKey={'BasicView.maptools.toolbarToolNames.measureline'}/> | ||
</Checkbox> | ||
<Checkbox checked={measurearea} onChange={evt => controller.selectionChanged('measurearea', evt.target.checked)}> | ||
<Message bundleKey={'Publisher2'} messageKey={'BasicView.maptools.toolbarToolNames.measurearea'}/> | ||
</Checkbox> | ||
</Col>; | ||
}; | ||
|
||
ToolbarToolComponent.propTypes = { | ||
state: PropTypes.object, | ||
controller: PropTypes.object | ||
}; |
Oops, something went wrong.