diff --git a/bundles/framework/publisher2/resources/locale/en.js b/bundles/framework/publisher2/resources/locale/en.js index 26985c516f..e571721566 100755 --- a/bundles/framework/publisher2/resources/locale/en.js +++ b/bundles/framework/publisher2/resources/locale/en.js @@ -67,7 +67,6 @@ Oskari.registerLocalization( "AnnouncementsPlugin": "Announcements", "TimeseriesControlPlugin": "Time series player", "IndexMapPlugin": "Index map", - "PanButtons": "Move to the original map view", "Portti2Zoombar": "Zoom bar", "ControlsPlugin": "Pan by mouse", "SearchPlugin": "Place search", @@ -122,9 +121,6 @@ Oskari.registerLocalization( "centerMapAutomatically": "Center map on user location at startup" } }, - "panButtonsOptions": { - "showArrows": "Pan tool" - } }, "toollayout": { "label": "Tool Placement", diff --git a/bundles/framework/publisher2/resources/locale/fi.js b/bundles/framework/publisher2/resources/locale/fi.js index 0e1248b421..2952f81f60 100755 --- a/bundles/framework/publisher2/resources/locale/fi.js +++ b/bundles/framework/publisher2/resources/locale/fi.js @@ -67,7 +67,6 @@ Oskari.registerLocalization( "AnnouncementsPlugin": "Ilmoitukset", "TimeseriesControlPlugin": "Aikasarjatoistin", "IndexMapPlugin": "Indeksikartta", - "PanButtons": "Palaa alkutilaan", "Portti2Zoombar": "Mittakaavasäädin", "ControlsPlugin": "Kartan liikuttaminen hiirellä raahaamalla", "SearchPlugin": "Osoite- ja paikannimihaku", @@ -122,9 +121,6 @@ Oskari.registerLocalization( "centerMapAutomatically": "Keskitä käyttäjän sijaintiin automaattisesti kartan käynnistyessä" } }, - "panButtonsOptions": { - "showArrows": "Kartan liikuttaminen nuolipainikkeilla" - } }, "toollayout": { "label": "Työkalujen asettelu kartalla", diff --git a/bundles/framework/publisher2/resources/locale/fr.js b/bundles/framework/publisher2/resources/locale/fr.js index 1e5080fc67..5a11ca61be 100644 --- a/bundles/framework/publisher2/resources/locale/fr.js +++ b/bundles/framework/publisher2/resources/locale/fr.js @@ -64,7 +64,6 @@ Oskari.registerLocalization( "tooltip": "Sélectionner les outils de carte accessibles. Consulter une mise en place dans la prévisualisation de carte.", "TimeseriesControlPlugin": "Lecteur chronologique", "IndexMapPlugin": "Carte-index", - "PanButtons": "Outil pour panoramiser", "Portti2Zoombar": "Barre de zoom", "ControlsPlugin": "Panoramiser avec la souris", "SearchPlugin": "Recherche de lieu", diff --git a/bundles/framework/publisher2/resources/locale/is.js b/bundles/framework/publisher2/resources/locale/is.js index c5ebe210b1..dee18bac0f 100755 --- a/bundles/framework/publisher2/resources/locale/is.js +++ b/bundles/framework/publisher2/resources/locale/is.js @@ -51,7 +51,6 @@ Oskari.registerLocalization( "label": "Tól", "tooltip": "Velja tiltæk kortatól. Athugaðu staðsetningu við forskoðun korts.", "IndexMapPlugin": "Index kort", - "PanButtons": "Hliðrunartól", "Portti2Zoombar": "Þysjunarstika", "ControlsPlugin": "Hliðra með mús", "SearchPlugin": "Leit eftir stað", diff --git a/bundles/framework/publisher2/resources/locale/ru.js b/bundles/framework/publisher2/resources/locale/ru.js index 8c3289d1a1..86820f5ae4 100644 --- a/bundles/framework/publisher2/resources/locale/ru.js +++ b/bundles/framework/publisher2/resources/locale/ru.js @@ -65,7 +65,6 @@ Oskari.registerLocalization( "tooltip": "Выберите доступные инструменты карты. Проверка размещения в окне предварительного просмотра карты.", "TimeseriesControlPlugin": "Временные ряды", "IndexMapPlugin": "Номенклатура карты", - "PanButtons": "Инструмент панорамирования", "Portti2Zoombar": "Панель увеличения", "ControlsPlugin": "Панорамирование мышью", "SearchPlugin": "Поиск места", diff --git a/bundles/framework/publisher2/resources/locale/sv.js b/bundles/framework/publisher2/resources/locale/sv.js index 7d0acc6f96..7e7b241a16 100755 --- a/bundles/framework/publisher2/resources/locale/sv.js +++ b/bundles/framework/publisher2/resources/locale/sv.js @@ -67,7 +67,6 @@ Oskari.registerLocalization( "AnnouncementsPlugin": "Aviseringar", "TimeseriesControlPlugin": "Tidseriespelare", "IndexMapPlugin": "Indexkarta", - "PanButtons": "Gå tillbaka till standardvyn för kartvyn", "Portti2Zoombar": "Skalans glidreglage", "ControlsPlugin": "Flytta kartvyn med musen", "SearchPlugin": "Adress- och ortnamnssökning", @@ -122,9 +121,6 @@ Oskari.registerLocalization( "centerMapAutomatically": "Centrera kartan till användarens plats vid start" } }, - "panButtonsOptions": { - "showArrows": "Panoreringsverktyg" - } }, "toollayout": { "label": "Verktygsplacering", diff --git a/bundles/framework/publisher2/tools/PanButtonsTool.js b/bundles/framework/publisher2/tools/PanButtonsTool.js deleted file mode 100755 index 1bccc47f97..0000000000 --- a/bundles/framework/publisher2/tools/PanButtonsTool.js +++ /dev/null @@ -1,80 +0,0 @@ -Oskari.clazz.define('Oskari.mapframework.publisher.tool.PanButtonsTool', - function () { - }, { - index: 2, - _templates: { - extraOptions: jQuery(` -
-
- -
-
- `) - }, - extraOptions: null, - - /** - * Get tool object. - * @method getTool - * - * @returns {Object} tool description - */ - getTool: function () { - return { - id: 'Oskari.mapframework.bundle.mapmodule.plugin.PanButtons', - title: 'PanButtons', - config: this.state.pluginConfig || {} - }; - }, - /** - * Get values. - * @method getValues - * @public - * - * @returns {Object} tool value object - */ - getValues: function () { - if (!this.isEnabled()) { - return null; - } - return { - configuration: { - mapfull: { - conf: { - plugins: [{ id: this.getTool().id, config: this.getPlugin().getConfig() }] - } - } - } - }; - }, - /** - * Get extra options. - * @method getExtraOptions - * @public - * - * @returns {Object} jQuery element - */ - getExtraOptions: function () { - var me = this; - if (!me._extraOptions) { - const initialConf = this.state.pluginConfig; - const showArrows = initialConf && initialConf.showArrows; - const extraOptions = this._templates.extraOptions.clone(); - extraOptions.find('.arrows-selection label span').append(this.__loc.panButtonsOptions.showArrows); - const arrowsCheckbox = extraOptions.find('.arrows-selection label input') - .on('change', function () { - const isChecked = jQuery(this).is(':checked'); - me.__plugin.setShowArrows(isChecked); - }); - if (showArrows) { - arrowsCheckbox.prop('checked', true).change(); - this.__plugin.setShowArrows(true); - } - this._extraOptions = extraOptions; - } - return this._extraOptions; - } - }, { - 'extend': ['Oskari.mapframework.publisher.tool.AbstractPluginTool'], - 'protocol': ['Oskari.mapframework.publisher.Tool'] - }); diff --git a/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsComponent.jsx b/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsComponent.jsx new file mode 100644 index 0000000000..369132166b --- /dev/null +++ b/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsComponent.jsx @@ -0,0 +1,21 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Message, Checkbox } from 'oskari-ui'; + +export const PanButtonsComponent = ({ state, controller }) => { + const onSelectionChange = (checked) => { + controller.setShowArrows(checked); + }; + + const { showArrows } = state; + return ( + onSelectionChange(evt.target.checked)}> + + + ); +}; + +PanButtonsComponent.propTypes = { + state: PropTypes.object, + controller: PropTypes.object +}; diff --git a/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsHandler.js b/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsHandler.js new file mode 100644 index 0000000000..e1e4ff3982 --- /dev/null +++ b/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsHandler.js @@ -0,0 +1,31 @@ +import { StateHandler, controllerMixin } from 'oskari-ui/util'; + +class UIHandler extends StateHandler { + constructor (tool) { + super(); + this.tool = tool; + this.sandbox = tool.getSandbox(); + this.setState({ + showArrows: false + }); + }; + + init (pluginConfig) { + this.updateState({ + ...pluginConfig + }); + } + + setShowArrows (value) { + this.updateState({ + showArrows: value + }); + this.tool.getPlugin().setShowArrows(value); + } +} + +const wrapped = controllerMixin(UIHandler, [ + 'setShowArrows' +]); + +export { wrapped as PanButtonsHandler }; diff --git a/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsTool.js b/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsTool.js new file mode 100644 index 0000000000..132ece0ebb --- /dev/null +++ b/bundles/mapping/mapmodule/plugin/panbuttons/publisher/PanButtonsTool.js @@ -0,0 +1,78 @@ +import { AbstractPublisherTool } from '../../../../../framework/publisher2/tools/AbstractPublisherTool'; +import { PanButtonsComponent } from './PanButtonsComponent'; +import { PanButtonsHandler } from './PanButtonsHandler'; +class PanButtonsTool extends AbstractPublisherTool { + constructor (...args) { + super(...args); + this.index = 1; + this.group = 'additional'; + this.config = null; + this.handler = new PanButtonsHandler(this); + }; + + init (data) { + const plugin = this.findPluginFromInitData(data); + // restore state to handler -> passing init data to it + this.setEnabled(!!plugin); + + if (plugin?.config) { + this.handler.init(plugin.config); + } + } + + getComponent () { + return { + component: PanButtonsComponent, + handler: this.handler + }; + } + + /** + * Get tool object. + * @method getTool + * + * @returns {Object} tool description + */ + getTool () { + return { + id: 'Oskari.mapframework.bundle.mapmodule.plugin.PanButtons', + title: Oskari.getMsg('MapModule', 'publisherTools.PanButtons.toolLabel'), + config: this.handler?.getState() || {} + }; + } + + getValues () { + if (!this.isEnabled()) { + return null; + } + + const pluginConfig = this.getPlugin().config || {}; + // add selected extraoptions to conf + const state = this.handler.getState(); + for (const key in state) { + if (state.hasOwnProperty(key)) { + pluginConfig[key] = state[key]; + } + } + + return { + configuration: { + mapfull: { + conf: { + plugins: [{ id: this.getTool().id, config: pluginConfig }] + } + } + } + }; + } +} + +// Attach protocol to make this discoverable by Oskari publisher +Oskari.clazz.defineES('Oskari.publisher.PanButtonsTool', + PanButtonsTool, + { + protocol: ['Oskari.mapframework.publisher.Tool'] + } +); + +export { PanButtonsTool }; diff --git a/bundles/mapping/mapmodule/publisher/tools.js b/bundles/mapping/mapmodule/publisher/tools.js index 71f14c8724..39d0fa8398 100644 --- a/bundles/mapping/mapmodule/publisher/tools.js +++ b/bundles/mapping/mapmodule/publisher/tools.js @@ -4,5 +4,6 @@ import { LogoTool } from '../plugin/logo/publisher/LogoTool'; import { ScaleBarTool } from '../plugin/scalebar/publisher/ScalebarTool'; import { MyLocationTool } from '../plugin/mylocation/publisher/MyLocationTool'; +import { PanButtonsTool } from '../plugin/panbuttons/publisher/PanButtonsTool'; -export { LogoTool, ScaleBarTool, MyLocationTool }; +export { LogoTool, ScaleBarTool, MyLocationTool, PanButtonsTool }; diff --git a/bundles/mapping/mapmodule/resources/locale/en.js b/bundles/mapping/mapmodule/resources/locale/en.js index 53d6907ff0..537211f80e 100755 --- a/bundles/mapping/mapmodule/resources/locale/en.js +++ b/bundles/mapping/mapmodule/resources/locale/en.js @@ -172,6 +172,12 @@ Oskari.registerLocalization( "mobileOnly": "Enable functionality only for mobile devices", "centerMapAutomatically": "Center map on user location at startup" } + }, + "PanButtons": { + "toolLabel": "Move to the original map view", + "titles": { + "showArrows": "Pan tool" + } } } } diff --git a/bundles/mapping/mapmodule/resources/locale/fi.js b/bundles/mapping/mapmodule/resources/locale/fi.js index c5dd0cb99e..39e738ad96 100755 --- a/bundles/mapping/mapmodule/resources/locale/fi.js +++ b/bundles/mapping/mapmodule/resources/locale/fi.js @@ -171,6 +171,12 @@ Oskari.registerLocalization( "mobileOnly": "Käytä toimintoja vain mobiililaitteissa", "centerMapAutomatically": "Keskitä käyttäjän sijaintiin automaattisesti kartan käynnistyessä" } + }, + "PanButtons": { + "toolLabel": "Palaa alkutilaan", + "titles": { + "showArrows": "Kartan liikuttaminen nuolipainikkeilla" + } } } } diff --git a/bundles/mapping/mapmodule/resources/locale/fr.js b/bundles/mapping/mapmodule/resources/locale/fr.js index 98323f62b8..6d76f40b12 100755 --- a/bundles/mapping/mapmodule/resources/locale/fr.js +++ b/bundles/mapping/mapmodule/resources/locale/fr.js @@ -142,6 +142,9 @@ Oskari.registerLocalization( "ScaleBarPlugin": "Barre d'échelle", "MyLocationPlugin": { "toolLabel": "Centre par rapport au lieu" + }, + "PanButtons": { + "toolLabel": "Outil pour panoramiser" } } } diff --git a/bundles/mapping/mapmodule/resources/locale/is.js b/bundles/mapping/mapmodule/resources/locale/is.js index 6b58b96fa1..f892bc8769 100755 --- a/bundles/mapping/mapmodule/resources/locale/is.js +++ b/bundles/mapping/mapmodule/resources/locale/is.js @@ -136,8 +136,10 @@ Oskari.registerLocalization( "ScaleBarPlugin": "Mælikvarðastika", "MyLocationPlugin": { "toolLabel": "Miðja" + }, + "PanButtons": { + "toolLabel": "Hliðrunartól" } } - } }); diff --git a/bundles/mapping/mapmodule/resources/locale/ru.js b/bundles/mapping/mapmodule/resources/locale/ru.js index 8d1b6919ec..67975684bd 100644 --- a/bundles/mapping/mapmodule/resources/locale/ru.js +++ b/bundles/mapping/mapmodule/resources/locale/ru.js @@ -137,6 +137,9 @@ Oskari.registerLocalization( "ScaleBarPlugin": "Масштабная линейка", "MyLocationPlugin": { "toolLabel": "Центровать к месту" + }, + "PanButtons": { + "toolLabel": "Инструмент панорамирования" } } } diff --git a/bundles/mapping/mapmodule/resources/locale/sv.js b/bundles/mapping/mapmodule/resources/locale/sv.js index 92634ece47..ffc624d2ba 100755 --- a/bundles/mapping/mapmodule/resources/locale/sv.js +++ b/bundles/mapping/mapmodule/resources/locale/sv.js @@ -167,7 +167,13 @@ Oskari.registerLocalization( "mobileOnly": "Tillåt funktionen endast för mobilapparater", "centerMapAutomatically": "Centrera kartan till användarens plats vid start" } - } + }, + "PanButtons": { + "toolLabel": "Gå tillbaka till standardvyn för kartvyn", + "titles": { + "showArrows": "Panoreringsverktyg" + } + } } } }); \ No newline at end of file diff --git a/packages/framework/bundle/publisher2/bundle.js b/packages/framework/bundle/publisher2/bundle.js index 158c0c42d7..0a88d5a0d6 100755 --- a/packages/framework/bundle/publisher2/bundle.js +++ b/packages/framework/bundle/publisher2/bundle.js @@ -101,10 +101,6 @@ Oskari.clazz.define("Oskari.mapframework.bundle.publisher2.PublisherBundle", fun "type": "text/javascript", "src": "../../../../bundles/framework/publisher2/tools/IndexMapTool.js" }, - { - "type": "text/javascript", - "src": "../../../../bundles/framework/publisher2/tools/PanButtonsTool.js" - }, { "type": "text/javascript", "src": "../../../../bundles/framework/publisher2/tools/ZoombarTool.js"