Skip to content
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

Publisher tools reactification panbuttons #2704

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions bundles/framework/publisher2/resources/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -122,9 +121,6 @@ Oskari.registerLocalization(
"centerMapAutomatically": "Center map on user location at startup"
}
},
"panButtonsOptions": {
"showArrows": "Pan tool"
}
},
"toollayout": {
"label": "Tool Placement",
Expand Down
4 changes: 0 additions & 4 deletions bundles/framework/publisher2/resources/locale/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion bundles/framework/publisher2/resources/locale/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion bundles/framework/publisher2/resources/locale/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -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ð",
Expand Down
1 change: 0 additions & 1 deletion bundles/framework/publisher2/resources/locale/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Oskari.registerLocalization(
"tooltip": "Выберите доступные инструменты карты. Проверка размещения в окне предварительного просмотра карты.",
"TimeseriesControlPlugin": "Временные ряды",
"IndexMapPlugin": "Номенклатура карты",
"PanButtons": "Инструмент панорамирования",
"Portti2Zoombar": "Панель увеличения",
"ControlsPlugin": "Панорамирование мышью",
"SearchPlugin": "Поиск места",
Expand Down
4 changes: 0 additions & 4 deletions bundles/framework/publisher2/resources/locale/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -122,9 +121,6 @@ Oskari.registerLocalization(
"centerMapAutomatically": "Centrera kartan till användarens plats vid start"
}
},
"panButtonsOptions": {
"showArrows": "Panoreringsverktyg"
}
},
"toollayout": {
"label": "Verktygsplacering",
Expand Down
80 changes: 0 additions & 80 deletions bundles/framework/publisher2/tools/PanButtonsTool.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 (
<Checkbox checked={showArrows} onChange={evt => onSelectionChange(evt.target.checked)}>
<Message bundleKey={'MapModule'} messageKey={'publisherTools.PanButtons.titles.showArrows'}/>
</Checkbox>
);
};

PanButtonsComponent.propTypes = {
state: PropTypes.object,
controller: PropTypes.object
};
Original file line number Diff line number Diff line change
@@ -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 };
Original file line number Diff line number Diff line change
@@ -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 };
3 changes: 2 additions & 1 deletion bundles/mapping/mapmodule/publisher/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
6 changes: 6 additions & 0 deletions bundles/mapping/mapmodule/resources/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions bundles/mapping/mapmodule/resources/locale/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions bundles/mapping/mapmodule/resources/locale/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ Oskari.registerLocalization(
"ScaleBarPlugin": "Barre d'échelle",
"MyLocationPlugin": {
"toolLabel": "Centre par rapport au lieu"
},
"PanButtons": {
"toolLabel": "Outil pour panoramiser"
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion bundles/mapping/mapmodule/resources/locale/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ Oskari.registerLocalization(
"ScaleBarPlugin": "Mælikvarðastika",
"MyLocationPlugin": {
"toolLabel": "Miðja"
},
"PanButtons": {
"toolLabel": "Hliðrunartól"
}
}

}
});
3 changes: 3 additions & 0 deletions bundles/mapping/mapmodule/resources/locale/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ Oskari.registerLocalization(
"ScaleBarPlugin": "Масштабная линейка",
"MyLocationPlugin": {
"toolLabel": "Центровать к месту"
},
"PanButtons": {
"toolLabel": "Инструмент панорамирования"
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion bundles/mapping/mapmodule/resources/locale/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
});
4 changes: 0 additions & 4 deletions packages/framework/bundle/publisher2/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading