Skip to content

Commit

Permalink
Properly toggle urbanisme tool when another drawing tool is activated (
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-fedorenko authored May 17, 2022
1 parent 5550e81 commit 438fd11
Show file tree
Hide file tree
Showing 19 changed files with 114 additions and 153 deletions.
2 changes: 1 addition & 1 deletion MapStore2
Submodule MapStore2 updated 1666 files
8 changes: 7 additions & 1 deletion build/extension/commons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const path = require("path");
const NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin");


// common configuration between production and development for webpack
module.exports = {
Expand All @@ -10,7 +12,11 @@ module.exports = {
destination: path.join(__dirname, '..', '..', "dist"),
// to compile properly also mapstore dependencies
alias: {
"@mapstore/patcher": path.resolve(__dirname, '..', '..', "node_modules", "@mapstore", "patcher"),
"@mapstore": path.resolve(__dirname, '..', '..', "MapStore2", "web", "client"),
"@js": path.resolve(__dirname, '..', '..', "js")
}
},
plugins: [
new NormalModuleReplacementPlugin(/^cesium\/index\.css$/, path.join(__dirname, "..", "..", "node_modules", "cesium/Build/Cesium/Widgets/widgets.css"))
]
};
10 changes: 5 additions & 5 deletions build/extension/module.app.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ const webpackConfig = require("../../webpack.config");
const { name } = require('../../config');

// emulate the extension root directory
webpackConfig.devServer.proxy["/extension/"] = {
webpackConfig.devServer.proxy["/extensions/"] = {
target: "http://localhost:8082"
};
// emulate the extensions.json
webpackConfig.devServer.before = function(app) {
app.get("/extensions.json", function(req, res) {
app.get("/extensions/extensions.json", function(req, res) {
res.json({
[name]: {
"bundle": "extension/index.js",
"translations": "extension/translations"
"bundle": "index.js",
"translations": "translations"
}
});
});
},
};
module.exports = webpackConfig;
5 changes: 3 additions & 2 deletions build/extension/prod-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const createExtensionWebpackConfig = require('../../MapStore2/build/createExtens
const CopyPlugin = require('copy-webpack-plugin');
const ZipPlugin = require('zip-webpack-plugin');
const {name} = require('../../config');
const commons = require('./commons');
const { plugins: commonsPlugins, ...commons} = require('./commons');

// the build configuration for production allow to create the final zip file, compressed accordingly
const plugins = [
Expand All @@ -22,7 +22,8 @@ const plugins = [
// other files have to be placed in the root, with the same name
return path.basename(assetPath);
}
})
}),
...commonsPlugins
];

// Temporary TODO: Has to be updated in createExtensionWebpackConfig
Expand Down
9 changes: 5 additions & 4 deletions build/extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
const createExtensionWebpackConfig = require('../../MapStore2/build/createExtensionWebpackConfig');

const { name } = require('../../config');
const commons = require('./commons');
const { plugins: commonsPlugins, ...commons } = require('./commons');
const webpackConfig = createExtensionWebpackConfig({
prod: false,
name,
...commons,
overrides: {
// serve translations (and index.json)
devServer: {
publicPath: "/extension/",
publicPath: "/extensions/",
contentBase: './assets',
contentBasePublicPath: '/extension/'
contentBasePublicPath: '/extensions/'
}
}
},
plugins: [ ...commonsPlugins ]
});

module.exports = webpackConfig;
File renamed without changes.
2 changes: 1 addition & 1 deletion localConfig.json → configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"declineUrl" : "http://www.google.com"
}
},
"OmniBar", "Login", "Save", "SaveAs", "BurgerMenu", "Expander", "Undo", "Redo", "FullScreen", "GlobeViewSwitcher", "SearchServicesConfig", "SearchByBookmark", "WidgetsBuilder", "Widgets",
"OmniBar", "Login", "Save", "SaveAs", "SidebarMenu", "Expander", "Undo", "Redo", "FullScreen", "GlobeViewSwitcher", "SearchServicesConfig", "SearchByBookmark", "WidgetsBuilder", "Widgets",
"WidgetsTray",
"Timeline",
"Playback",
Expand Down
6 changes: 1 addition & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
left: 0;
bottom: 0;
right: 0;
overflow: show;
overflow: visible;
margin: auto;
display: flex;
align-items: center;
Expand Down Expand Up @@ -92,10 +92,6 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js"></script>
<!--<script src="https://www.mapquestapi.com/sdk/leaflet/v2.2/mq-map.js?key=__API_KEY_MAPQUEST__"></script>-->
<script src="https://cesiumjs.org/releases/1.17/Build/Cesium/Cesium.js"></script>
<link rel="stylesheet" href="https://cesiumjs.org/releases/1.17/Build/Cesium/Widgets/widgets.css" />
<script src="MapStore2/web/client/libs/cesium-navigation/cesium-navigation.js"></script>
<link rel="stylesheet" href="MapStore2/web/client/libs/cesium-navigation/cesium-navigation.css" />

</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion js/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ConfigUtils.setConfigProp('themePrefix', 'MapStoreExtension');
*
* ConfigUtils.setLocalConfigurationFile('localConfig.json');
*/
ConfigUtils.setLocalConfigurationFile('localConfig.json');

/**
* Use a custom application configuration file with:
Expand Down
64 changes: 21 additions & 43 deletions js/extension/epics/__tests__/urbanisme-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
import expect from 'expect';

import { testEpic, addTimeoutEpic } from '@mapstore/epics/__tests__/epicTestUtils';
import { toggleControl, TOGGLE_CONTROL, setControlProperty } from '@mapstore/actions/controls';
import { clickOnMap } from '@mapstore/actions/map';
import { toggleControl, TOGGLE_CONTROL } from '@mapstore/actions/controls';
import {clickOnMap, registerEventListener} from '@mapstore/actions/map';
import { PURGE_MAPINFO_RESULTS, TOGGLE_MAPINFO_STATE, loadFeatureInfo } from '@mapstore/actions/mapInfo';

import {
setUpPluginEpic,
toggleLandPlanningEpic,
cleanUpUrbanismeEpic,
clickOnMapEventEpic,
deactivateOnMeasureEnabledEpic,
getFeatureInfoEpic,
onClosePanelEpic,
onToogleToolEpic,
updateAdditionalLayerEpic, highlightFeatureEpic
updateAdditionalLayerEpic,
highlightFeatureEpic,
tearDownUrbanismeOnDrawToolActive
} from '../urbanisme';
import {
setUp,
Expand Down Expand Up @@ -99,16 +100,16 @@ describe('Urbanisme EPICS', () => {

it('toggleLandPlanningEpic when Urbanisme tool enabled', (done) => {
const state = {
controls: { urbanisme: { enabled: true }, measure: {enabled: true}},
controls: { urbanisme: { enabled: true }},
urbanisme: { config: { cadastreWMSURL: "/cadastreWMSURL"}},
mapInfo: {enabled: true}
};
testEpic(
toggleLandPlanningEpic,
4,
3,
toggleControl('urbanisme', null),
actions => {
expect(actions.length).toBe(4);
expect(actions.length).toBe(3);
actions.map(action=> {
switch (action.type) {
case UPDATE_ADDITIONAL_LAYER:
Expand Down Expand Up @@ -226,35 +227,17 @@ describe('Urbanisme EPICS', () => {
state);
});

it('cleanUpUrbanismeEpic opening annotation when urbanisme plugin is opened', (done) => {
const state = { controls: { urbanisme: { enabled: true}, annotations: { enabled: true}}};
testEpic(
cleanUpUrbanismeEpic,
1,
toggleControl("annotations"),
actions => {
expect(actions.length).toBe(1);
actions.map(action=>{
switch (action.type) {
case TOGGLE_CONTROL:
break;
default:
expect(true).toBe(false);
}
});
done();
},
state);
});

it('closeOnMeasureEnabledEpic close when urbanisme plugin when measurement is opened', (done) => {
const state = { controls: { measure: { enabled: true}, urbanisme: { enabled: true}}};
it('tearDownUrbanismeOnDrawToolActive toggle off urbanisme tool when measurement is opened', (done) => {
const state = {
controls: { measure: { enabled: true}, urbanisme: { enabled: true}},
urbanisme: { activeTool: "ADS"}
};
testEpic(
deactivateOnMeasureEnabledEpic,
3,
setControlProperty("measure", "enabled", true),
tearDownUrbanismeOnDrawToolActive,
2,
registerEventListener('click', 'measure'),
actions => {
expect(actions.length).toBe(3);
expect(actions.length).toBe(2);
actions.map(action=>{
switch (action.type) {
case TOGGLE_TOOL:
Expand All @@ -263,8 +246,6 @@ describe('Urbanisme EPICS', () => {
case TOGGLE_VIEWER_PANEL:
expect(action.enabled).toBe(false);
break;
case PURGE_MAPINFO_RESULTS:
break;
default:
expect(true).toBe(false);
}
Expand Down Expand Up @@ -300,7 +281,7 @@ describe('Urbanisme EPICS', () => {
mockAxios.onGet(`${CADASTRAPP_URL}/getParcelle`).reply(200, [{parcelle: "parcelle", ccopre: "ccopre",
ccosec: "ccosec", dnupla: "dnupla", dnvoiri: "dnvoiri", cconvo: "cconvo", dvoilib: "dvoilib", dcntpa: "dcntpa"}]);
mockAxios.onGet(`${URBANISMEAPP_URL}/renseignUrba`).reply(200, {libelles: [{libelle: "Test"}]});
mockAxios.onGet(`${CADASTRAPP_URL}/getFIC`, ).reply((config)=>{
mockAxios.onGet(`${CADASTRAPP_URL}/getFIC` ).reply((config)=>{
if (config.params.onglet === 0) return [200, [{surfc: "surfc"}]];
return [200, [{comptecommunal: "codeProprio"}]];
});
Expand Down Expand Up @@ -347,7 +328,7 @@ describe('Urbanisme EPICS', () => {
mockAxios.onGet(`${CADASTRAPP_URL}/getCommune`).reply(200, []);
mockAxios.onGet(`${CADASTRAPP_URL}/getParcelle`).reply(200, []);
mockAxios.onGet(`${URBANISMEAPP_URL}/renseignUrba`).reply(200, {});
mockAxios.onGet(`${CADASTRAPP_URL}/getFIC`, ).reply((config)=>{
mockAxios.onGet(`${CADASTRAPP_URL}/getFIC` ).reply((config)=>{
if (config.params.onglet === 0) return [200, []];
return [200, []];
});
Expand Down Expand Up @@ -440,10 +421,10 @@ describe('Urbanisme EPICS', () => {
};
testEpic(
onToogleToolEpic,
4,
3,
toggleUrbanismeTool('NRU'),
actions => {
expect(actions.length).toBe(4);
expect(actions.length).toBe(3);
actions.map(action=>{
switch (action.type) {
case URBANISME_RESET_FEATURE_HIGHLIGHT:
Expand All @@ -454,9 +435,6 @@ describe('Urbanisme EPICS', () => {
case TOGGLE_VIEWER_PANEL:
expect(action.enabled).toBe(false);
break;
case TOGGLE_CONTROL:
expect(action.control).toBe("measure");
break;
default:
expect(true).toBe(false);
}
Expand Down
Loading

0 comments on commit 438fd11

Please sign in to comment.