@eeacms/volto-eea-map 0.1.32 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.i18n.babel.config.js +1 -0
- package/.project.eslintrc.js +5 -4
- package/CHANGELOG.md +29 -0
- package/babel.config.js +1 -1
- package/cypress.config.js +6 -15
- package/jest-addon.config.js +3 -1
- package/package.json +12 -5
- package/src/components/Blocks/EmbedEEAMap/Edit.jsx +2 -17
- package/src/components/Blocks/EmbedEEAMap/View.jsx +17 -32
- package/src/components/Webmap.jsx +44 -50
- package/src/components/visualization/panelsSchema.js +43 -1
- package/src/components/widgets/LayerSelectWidget.jsx +48 -0
- package/src/components/widgets/SimpleColorPickerWidget.jsx +62 -0
- package/src/index.js +2 -38
- package/src/components/widgets/ObjectTypesWidget.jsx +0 -69
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@plone/volto/babel');
|
package/.project.eslintrc.js
CHANGED
|
@@ -5,14 +5,13 @@ const projectRootPath = fs.existsSync('./project')
|
|
|
5
5
|
? fs.realpathSync('./project')
|
|
6
6
|
: fs.realpathSync('./../../../');
|
|
7
7
|
const packageJson = require(path.join(projectRootPath, 'package.json'));
|
|
8
|
-
const jsConfig = require(path.join(projectRootPath, 'jsconfig.json'))
|
|
9
|
-
.compilerOptions;
|
|
8
|
+
const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
|
|
10
9
|
|
|
11
10
|
const pathsConfig = jsConfig.paths;
|
|
12
11
|
|
|
13
12
|
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
14
13
|
|
|
15
|
-
Object.keys(pathsConfig).forEach(
|
|
14
|
+
Object.keys(pathsConfig).forEach(pkg => {
|
|
16
15
|
if (pkg === '@plone/volto') {
|
|
17
16
|
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
|
|
18
17
|
}
|
|
@@ -21,11 +20,12 @@ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
|
21
20
|
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
22
21
|
|
|
23
22
|
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
|
|
24
|
-
const addonAliases = Object.keys(reg.packages).map(
|
|
23
|
+
const addonAliases = Object.keys(reg.packages).map(o => [
|
|
25
24
|
o,
|
|
26
25
|
reg.packages[o].modulePath,
|
|
27
26
|
]);
|
|
28
27
|
|
|
28
|
+
|
|
29
29
|
module.exports = {
|
|
30
30
|
extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
|
|
31
31
|
settings: {
|
|
@@ -45,3 +45,4 @@ module.exports = {
|
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,35 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [0.1.34](https://github.com/eea/volto-eea-map/compare/0.1.33...0.1.34) - 12 June 2023
|
|
8
|
+
|
|
9
|
+
#### :house: Internal changes
|
|
10
|
+
|
|
11
|
+
- chore: enable alpha [Andrei Grigore - [`e016e46`](https://github.com/eea/volto-eea-map/commit/e016e4631a4332f07895f6077308235c41a6702c)]
|
|
12
|
+
|
|
13
|
+
### [0.1.33](https://github.com/eea/volto-eea-map/compare/0.1.32...0.1.33) - 12 June 2023
|
|
14
|
+
|
|
15
|
+
#### :bug: Bug Fixes
|
|
16
|
+
|
|
17
|
+
- fix: tests #254131 [andreiggr - [`a72841c`](https://github.com/eea/volto-eea-map/commit/a72841ca6bf4ccbd57331dd8353fb25f1597174f)]
|
|
18
|
+
- fix: tests #254131 [andreiggr - [`9e54ab1`](https://github.com/eea/volto-eea-map/commit/9e54ab13be0cc58481808c99b5bb90536acd6643)]
|
|
19
|
+
- fix: resolution countup.js [Andrei Grigore - [`a7a55a1`](https://github.com/eea/volto-eea-map/commit/a7a55a1ec8a325f536d01965a84367a49095f00a)]
|
|
20
|
+
|
|
21
|
+
#### :house: Internal changes
|
|
22
|
+
|
|
23
|
+
- chore: clear unused #254131 [andreiggr - [`ccec2ea`](https://github.com/eea/volto-eea-map/commit/ccec2eaab173c905cd4ea0190a9c6cfd630250f9)]
|
|
24
|
+
- chore: clear block style #254131 [andreiggr - [`af500bc`](https://github.com/eea/volto-eea-map/commit/af500bc10a5f280eff0335f45bae1596d66a7e6b)]
|
|
25
|
+
- chore: [JENKINS] Remove alpha testing version [valentinab25 - [`76b29e5`](https://github.com/eea/volto-eea-map/commit/76b29e510f5156590723831a524bc39dfba6deba)]
|
|
26
|
+
|
|
27
|
+
#### :hammer_and_wrench: Others
|
|
28
|
+
|
|
29
|
+
- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`58f37dd`](https://github.com/eea/volto-eea-map/commit/58f37dd0154290fd801604ec972ff45563fe9970)]
|
|
30
|
+
- test: Fix test config, coverage Refs #253277 [valentinab25 - [`80d1348`](https://github.com/eea/volto-eea-map/commit/80d134809ca2f7d1cbad7bc5c780f1c4b43ca544)]
|
|
31
|
+
- tests: set configuration from template [valentinab25 - [`9588e21`](https://github.com/eea/volto-eea-map/commit/9588e2193091b766c74b2dc4da7f51c0b998ac17)]
|
|
32
|
+
- * versions [andreiggr - [`6d9ff2b`](https://github.com/eea/volto-eea-map/commit/6d9ff2b26a236b6445678e3d84698d1c3c0826f4)]
|
|
33
|
+
- add razzle-plugin-scss dep [andreiggr - [`d74cee5`](https://github.com/eea/volto-eea-map/commit/d74cee51d30c866afe55730e5b25e0bf11d2caea)]
|
|
34
|
+
- volto-object-widget [andreiggr - [`18d0ed7`](https://github.com/eea/volto-eea-map/commit/18d0ed72c1ba7b0f7159a0eefc09ccea9acee5cb)]
|
|
35
|
+
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`5911d01`](https://github.com/eea/volto-eea-map/commit/5911d01f7f3bc79a2c834fab75a9a4ac05d2d042)]
|
|
7
36
|
### [0.1.32](https://github.com/eea/volto-eea-map/compare/0.1.31...0.1.32) - 20 February 2023
|
|
8
37
|
|
|
9
38
|
#### :hammer_and_wrench: Others
|
package/babel.config.js
CHANGED
package/cypress.config.js
CHANGED
|
@@ -6,31 +6,22 @@ module.exports = defineConfig({
|
|
|
6
6
|
chromeWebSecurity: false,
|
|
7
7
|
reporter: 'junit',
|
|
8
8
|
video: true,
|
|
9
|
-
|
|
10
9
|
retries: {
|
|
11
10
|
runMode: 8,
|
|
12
11
|
openMode: 0,
|
|
13
12
|
},
|
|
14
|
-
|
|
15
13
|
reporterOptions: {
|
|
16
14
|
mochaFile: 'cypress/reports/cypress-[hash].xml',
|
|
17
15
|
jenkinsMode: true,
|
|
18
16
|
toConsole: true,
|
|
19
17
|
},
|
|
20
|
-
|
|
21
18
|
e2e: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
baseUrl: 'http://localhost:3000',
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
component: {
|
|
31
|
-
devServer: {
|
|
32
|
-
framework: 'react',
|
|
33
|
-
bundler: 'webpack',
|
|
19
|
+
setupNodeEvents(on, config) {
|
|
20
|
+
// e2e testing node events setup code
|
|
21
|
+
require('@cypress/code-coverage/task')(on, config);
|
|
22
|
+
require('cypress-fail-fast/plugin')(on, config);
|
|
23
|
+
return config;
|
|
34
24
|
},
|
|
25
|
+
baseUrl: 'http://localhost:3000',
|
|
35
26
|
},
|
|
36
27
|
});
|
package/jest-addon.config.js
CHANGED
|
@@ -5,12 +5,14 @@ module.exports = {
|
|
|
5
5
|
'!src/**/*.d.ts',
|
|
6
6
|
],
|
|
7
7
|
moduleNameMapper: {
|
|
8
|
+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
8
9
|
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
|
|
9
10
|
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
|
|
10
11
|
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
11
12
|
'@package/(.*)$': '<rootDir>/src/$1',
|
|
13
|
+
'@root/(.*)$': '<rootDir>/src/$1',
|
|
12
14
|
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
|
|
13
|
-
'@eeacms/(.*?)/(.*)$': '<rootDir>/
|
|
15
|
+
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
|
|
14
16
|
'@plone/volto-slate':
|
|
15
17
|
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
|
|
16
18
|
'~/(.*)$': '<rootDir>/src/$1',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-eea-map",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "@eeacms/volto-eea-map: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -18,22 +18,29 @@
|
|
|
18
18
|
},
|
|
19
19
|
"addons": [
|
|
20
20
|
"@eeacms/volto-embed",
|
|
21
|
-
"@eeacms/volto-
|
|
21
|
+
"@eeacms/volto-object-widget"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@eeacms/volto-
|
|
25
|
-
"@eeacms/volto-
|
|
24
|
+
"@eeacms/volto-embed": "*",
|
|
25
|
+
"@eeacms/volto-object-widget": "*",
|
|
26
26
|
"@plone/scripts": "*",
|
|
27
27
|
"esri-loader": "3.6.0",
|
|
28
28
|
"lodash": "4.17.21",
|
|
29
|
+
"razzle-plugin-scss": "4.2.18",
|
|
30
|
+
"react-color": "~2.19.3",
|
|
29
31
|
"react-querybuilder": "4.2.3"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
|
-
"@cypress/code-coverage": "^3.
|
|
34
|
+
"@cypress/code-coverage": "^3.10.0",
|
|
35
|
+
"@plone/scripts": "*",
|
|
33
36
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
34
37
|
"cypress": "10.3.1",
|
|
38
|
+
"cypress-fail-fast": "^5.0.1",
|
|
35
39
|
"md5": "^2.3.0"
|
|
36
40
|
},
|
|
41
|
+
"resolutions": {
|
|
42
|
+
"react-countup/countup.js": "2.5.0"
|
|
43
|
+
},
|
|
37
44
|
"scripts": {
|
|
38
45
|
"release": "release-it",
|
|
39
46
|
"bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
|
|
@@ -4,8 +4,6 @@ import { SidebarPortal } from '@plone/volto/components';
|
|
|
4
4
|
import { connect } from 'react-redux';
|
|
5
5
|
import { compose } from 'redux';
|
|
6
6
|
|
|
7
|
-
import { BlockStyleWrapperEdit } from '@eeacms/volto-block-style/BlockStyleWrapper';
|
|
8
|
-
import cx from 'classnames';
|
|
9
7
|
import { getContent } from '@plone/volto/actions';
|
|
10
8
|
|
|
11
9
|
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
@@ -60,20 +58,7 @@ const Edit = (props) => {
|
|
|
60
58
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
59
|
}, [props.block, props.data_query, data.data_query_params]);
|
|
62
60
|
return (
|
|
63
|
-
|
|
64
|
-
{...props}
|
|
65
|
-
role="presentation"
|
|
66
|
-
data={{
|
|
67
|
-
...(props.data || {}),
|
|
68
|
-
styles: {
|
|
69
|
-
...(props.data?.styles || {}),
|
|
70
|
-
customClass: cx(
|
|
71
|
-
props.data?.styles?.customClass || '',
|
|
72
|
-
'custom-map-class',
|
|
73
|
-
),
|
|
74
|
-
},
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
61
|
+
<>
|
|
77
62
|
<View data={data} id={id} isEdit={true} />
|
|
78
63
|
<SidebarPortal selected={selected}>
|
|
79
64
|
<BlockDataForm
|
|
@@ -89,7 +74,7 @@ const Edit = (props) => {
|
|
|
89
74
|
formData={data}
|
|
90
75
|
/>
|
|
91
76
|
</SidebarPortal>
|
|
92
|
-
|
|
77
|
+
</>
|
|
93
78
|
);
|
|
94
79
|
};
|
|
95
80
|
|
|
@@ -9,9 +9,6 @@ import { getContent } from '@plone/volto/actions';
|
|
|
9
9
|
import Webmap from '../../Webmap';
|
|
10
10
|
import ExtraViews from '../../ExtraViews';
|
|
11
11
|
|
|
12
|
-
import { StyleWrapperView } from '@eeacms/volto-block-style/StyleWrapper';
|
|
13
|
-
import cx from 'classnames';
|
|
14
|
-
|
|
15
12
|
const View = (props) => {
|
|
16
13
|
const { data, id, isEdit, map_visualization = '', data_provenance = {} } =
|
|
17
14
|
props || {};
|
|
@@ -77,35 +74,23 @@ const View = (props) => {
|
|
|
77
74
|
}, [map_visualization, props.data, props.data_query, isEdit, enable_queries]);
|
|
78
75
|
|
|
79
76
|
return (
|
|
80
|
-
<
|
|
81
|
-
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
...data,
|
|
98
|
-
data_provenance,
|
|
99
|
-
map_data: map_visualization,
|
|
100
|
-
}}
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
103
|
-
)}
|
|
104
|
-
{!mapData && (
|
|
105
|
-
<p>No map view to show. Set visualization in block configuration.</p>
|
|
106
|
-
)}
|
|
107
|
-
</PrivacyProtection>
|
|
108
|
-
</StyleWrapperView>
|
|
77
|
+
<PrivacyProtection data={data} height={height} {...props}>
|
|
78
|
+
{mapData && (
|
|
79
|
+
<div>
|
|
80
|
+
<Webmap data={mapData} height={height} />
|
|
81
|
+
<ExtraViews
|
|
82
|
+
data={{
|
|
83
|
+
...data,
|
|
84
|
+
data_provenance,
|
|
85
|
+
map_data: map_visualization,
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
{!mapData && (
|
|
91
|
+
<p>No map view to show. Set visualization in block configuration.</p>
|
|
92
|
+
)}
|
|
93
|
+
</PrivacyProtection>
|
|
109
94
|
);
|
|
110
95
|
};
|
|
111
96
|
|
|
@@ -19,57 +19,19 @@ const MODULES = [
|
|
|
19
19
|
'esri/widgets/ScaleBar',
|
|
20
20
|
];
|
|
21
21
|
|
|
22
|
-
//TODO: set group layers sublayers, for direct group import.
|
|
23
|
-
// const setGroupLayers = async (ids, data, modules) => {
|
|
24
|
-
// const { map_service_url, sublayerDatalayer, fullLayer, query = '' } =
|
|
25
|
-
// data || {};
|
|
26
|
-
// const { FeatureLayer, MapImageLayer, GroupLayer } = modules;
|
|
27
|
-
|
|
28
|
-
// const glLayers = await Promise.all(
|
|
29
|
-
// ids.map(async (id) => {
|
|
30
|
-
// const sublayerUrl = `${map_service_url}/${id}`;
|
|
31
|
-
// let sublayerData = await fetchArcGISData(sublayerUrl);
|
|
32
|
-
// let sublayer;
|
|
33
|
-
// switch (sublayerData.type) {
|
|
34
|
-
// case 'Raster Layer':
|
|
35
|
-
// sublayer = new MapImageLayer({
|
|
36
|
-
// url: map_service_url,
|
|
37
|
-
// minScale: sublayerData?.minScale,
|
|
38
|
-
// maxScale: sublayerData?.maxScale,
|
|
39
|
-
// sublayers: [
|
|
40
|
-
// {
|
|
41
|
-
// id: sublayerData.id,
|
|
42
|
-
// visible: true,
|
|
43
|
-
// definitionExpression: query ? formatQuery(query, 'sql') : '',
|
|
44
|
-
// },
|
|
45
|
-
// ],
|
|
46
|
-
// });
|
|
47
|
-
// break;
|
|
48
|
-
// case 'Feature Layer':
|
|
49
|
-
// sublayer = new FeatureLayer({
|
|
50
|
-
// layerId: sublayerData.id,
|
|
51
|
-
// url: `${map_service_url}/${sublayerData.id}`,
|
|
52
|
-
// definitionExpression: query ? formatQuery(query, 'sql') : '',
|
|
53
|
-
// minScale: sublayerData?.minScale,
|
|
54
|
-
// maxScale: sublayerData?.maxScale,
|
|
55
|
-
// });
|
|
56
|
-
// break;
|
|
57
|
-
// default:
|
|
58
|
-
// break;
|
|
59
|
-
// }
|
|
60
|
-
// return sublayer;
|
|
61
|
-
// }),
|
|
62
|
-
// );
|
|
63
|
-
// return glLayers;
|
|
64
|
-
// };
|
|
65
|
-
|
|
66
22
|
const Webmap = (props) => {
|
|
67
23
|
const { editMode, height, id } = props;
|
|
68
24
|
|
|
69
25
|
const data = React.useMemo(() => props.data || {}, [props.data]);
|
|
70
26
|
|
|
71
27
|
const device = React.useMemo(() => props.device || {}, [props.device]);
|
|
72
|
-
const {
|
|
28
|
+
const {
|
|
29
|
+
base = {},
|
|
30
|
+
layers = {},
|
|
31
|
+
legend = {},
|
|
32
|
+
general = {},
|
|
33
|
+
styles = {},
|
|
34
|
+
} = data;
|
|
73
35
|
|
|
74
36
|
const { base_layer = '' } = base;
|
|
75
37
|
|
|
@@ -125,6 +87,19 @@ const Webmap = (props) => {
|
|
|
125
87
|
}
|
|
126
88
|
}, [setModules, options]);
|
|
127
89
|
|
|
90
|
+
var customFeatureLayerRenderer = {
|
|
91
|
+
type: 'simple', // autocasts as new SimpleRenderer()
|
|
92
|
+
symbol: {
|
|
93
|
+
type: 'simple-fill', // autocasts as new SimpleFillSymbol()
|
|
94
|
+
color: styles?.symbol_color ? styles?.symbol_color : 'black',
|
|
95
|
+
style: 'solid',
|
|
96
|
+
outline: {
|
|
97
|
+
// autocasts as new SimpleLineSymbol()
|
|
98
|
+
color: styles?.outline_color ? styles?.outline_color : 'white',
|
|
99
|
+
width: styles?.outline_width ? styles?.outline_width : 1,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
128
103
|
//eslint-disable-next-line no-unused-vars
|
|
129
104
|
const esri = React.useMemo(() => {
|
|
130
105
|
if (Object.keys(modules).length === 0) return {};
|
|
@@ -148,7 +123,15 @@ const Webmap = (props) => {
|
|
|
148
123
|
.filter(({ map_service_url, layer }) => map_service_url && layer)
|
|
149
124
|
.map(
|
|
150
125
|
(
|
|
151
|
-
{
|
|
126
|
+
{
|
|
127
|
+
map_service_url,
|
|
128
|
+
layer,
|
|
129
|
+
fullLayer,
|
|
130
|
+
query = '',
|
|
131
|
+
opacity = 1,
|
|
132
|
+
maxScaleOverride = '',
|
|
133
|
+
minScaleOverride = '',
|
|
134
|
+
},
|
|
152
135
|
index,
|
|
153
136
|
) => {
|
|
154
137
|
const url = `${map_service_url}/${layer?.id}`;
|
|
@@ -160,8 +143,12 @@ const Webmap = (props) => {
|
|
|
160
143
|
sublayers: [
|
|
161
144
|
{
|
|
162
145
|
id: layer.id,
|
|
163
|
-
minScale:
|
|
164
|
-
|
|
146
|
+
minScale: minScaleOverride
|
|
147
|
+
? minScaleOverride
|
|
148
|
+
: layer?.minScale,
|
|
149
|
+
maxScale: maxScaleOverride
|
|
150
|
+
? maxScaleOverride
|
|
151
|
+
: layer?.maxScale,
|
|
165
152
|
opacity: opacity ? parseFloat(opacity) : 1,
|
|
166
153
|
definitionExpression: query
|
|
167
154
|
? formatQuery(query, 'sql')
|
|
@@ -177,9 +164,16 @@ const Webmap = (props) => {
|
|
|
177
164
|
definitionExpression: query
|
|
178
165
|
? formatQuery(query, 'sql')
|
|
179
166
|
: '',
|
|
180
|
-
minScale:
|
|
181
|
-
|
|
167
|
+
minScale: minScaleOverride
|
|
168
|
+
? minScaleOverride
|
|
169
|
+
: layer?.minScale,
|
|
170
|
+
maxScale: maxScaleOverride
|
|
171
|
+
? maxScaleOverride
|
|
172
|
+
: layer?.maxScale,
|
|
182
173
|
opacity: opacity ? parseFloat(opacity) : 1,
|
|
174
|
+
...(styles?.override_styles && {
|
|
175
|
+
renderer: customFeatureLayerRenderer,
|
|
176
|
+
}),
|
|
183
177
|
});
|
|
184
178
|
break;
|
|
185
179
|
default:
|
|
@@ -78,6 +78,44 @@ const MapLayersSchema = {
|
|
|
78
78
|
required: [],
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
const StylesLayersSchema = ({ data = {} }) => {
|
|
82
|
+
return {
|
|
83
|
+
title: 'Styles Layers',
|
|
84
|
+
fieldsets: [
|
|
85
|
+
{
|
|
86
|
+
id: 'default',
|
|
87
|
+
title: 'Map Data',
|
|
88
|
+
fields: [
|
|
89
|
+
'override_styles',
|
|
90
|
+
...(data?.map_data?.styles?.override_styles
|
|
91
|
+
? ['symbol_color', 'outline_color', 'outline_width']
|
|
92
|
+
: []),
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
properties: {
|
|
97
|
+
override_styles: {
|
|
98
|
+
title: 'Override layers style',
|
|
99
|
+
description: 'Will override imported layers styling',
|
|
100
|
+
type: 'boolean',
|
|
101
|
+
},
|
|
102
|
+
symbol_color: {
|
|
103
|
+
title: 'Fill color',
|
|
104
|
+
widget: 'simple_color_picker_widget',
|
|
105
|
+
},
|
|
106
|
+
outline_color: {
|
|
107
|
+
title: 'Outline color',
|
|
108
|
+
widget: 'simple_color_picker_widget',
|
|
109
|
+
},
|
|
110
|
+
outline_width: {
|
|
111
|
+
title: 'Outline width',
|
|
112
|
+
type: 'number',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: [],
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
81
119
|
const GeneralSchema = ({ data = {} }) => {
|
|
82
120
|
const centerOnExtent = data?.map_data?.general?.centerOnExtent;
|
|
83
121
|
|
|
@@ -148,7 +186,7 @@ const GeneralSchema = ({ data = {} }) => {
|
|
|
148
186
|
export default ({ data = {} }) => {
|
|
149
187
|
const generalSchema = GeneralSchema({ data });
|
|
150
188
|
const baseLayerSchema = BaseLayerSchema({ data });
|
|
151
|
-
|
|
189
|
+
const stylesLayerSchema = StylesLayersSchema({ data });
|
|
152
190
|
return {
|
|
153
191
|
title: 'Map Editor',
|
|
154
192
|
fieldsets: [
|
|
@@ -175,6 +213,10 @@ export default ({ data = {} }) => {
|
|
|
175
213
|
id: 'layers',
|
|
176
214
|
schema: MapLayersSchema,
|
|
177
215
|
},
|
|
216
|
+
{
|
|
217
|
+
id: 'styles',
|
|
218
|
+
schema: stylesLayerSchema,
|
|
219
|
+
},
|
|
178
220
|
],
|
|
179
221
|
},
|
|
180
222
|
},
|
|
@@ -190,6 +190,20 @@ const LayerSelectWidget = (props) => {
|
|
|
190
190
|
setServiceUrl(value);
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
+
const handleMinScaleChange = (minScaleOverride) => {
|
|
194
|
+
onChange(id, {
|
|
195
|
+
...value,
|
|
196
|
+
minScaleOverride,
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const handleMaxScaleChange = (maxScaleOverride) => {
|
|
201
|
+
onChange(id, {
|
|
202
|
+
...value,
|
|
203
|
+
maxScaleOverride,
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
|
|
193
207
|
const handleReset = () => {
|
|
194
208
|
setServiceUrlError('');
|
|
195
209
|
setServiceUrl(map_service_url);
|
|
@@ -313,6 +327,40 @@ const LayerSelectWidget = (props) => {
|
|
|
313
327
|
onChange={(e) => handleOpacityChange(e.target.value)}
|
|
314
328
|
/>
|
|
315
329
|
</Grid.Row>
|
|
330
|
+
<Grid.Row stretched>
|
|
331
|
+
<h5 style={{ padding: '0', margin: '15px 0px 5px 0px' }}>
|
|
332
|
+
Min scale:
|
|
333
|
+
</h5>
|
|
334
|
+
<input
|
|
335
|
+
className="map-number-input"
|
|
336
|
+
type="number"
|
|
337
|
+
min={0}
|
|
338
|
+
step={1}
|
|
339
|
+
value={
|
|
340
|
+
value?.minScaleOverride
|
|
341
|
+
? value?.minScaleOverride
|
|
342
|
+
: value?.layer?.minScale
|
|
343
|
+
}
|
|
344
|
+
onChange={(e) => handleMinScaleChange(e.target.value)}
|
|
345
|
+
/>
|
|
346
|
+
</Grid.Row>
|
|
347
|
+
<Grid.Row stretched>
|
|
348
|
+
<h5 style={{ padding: '0', margin: '15px 0px 5px 0px' }}>
|
|
349
|
+
Max scale:
|
|
350
|
+
</h5>
|
|
351
|
+
<input
|
|
352
|
+
className="map-number-input"
|
|
353
|
+
type="number"
|
|
354
|
+
min={0}
|
|
355
|
+
step={1}
|
|
356
|
+
value={
|
|
357
|
+
value?.maxScaleOverride
|
|
358
|
+
? value?.maxScaleOverride
|
|
359
|
+
: value?.layer?.maxScale
|
|
360
|
+
}
|
|
361
|
+
onChange={(e) => handleMaxScaleChange(e.target.value)}
|
|
362
|
+
/>
|
|
363
|
+
</Grid.Row>
|
|
316
364
|
<Grid.Row stretched>
|
|
317
365
|
<h5 style={{ padding: '0', margin: '15px 0px 5px 0px' }}>
|
|
318
366
|
Description
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormFieldWrapper, Icon } from '@plone/volto/components';
|
|
3
|
+
import { Button } from 'semantic-ui-react';
|
|
4
|
+
import loadable from '@loadable/component';
|
|
5
|
+
import clearSVG from '@plone/volto/icons/clear.svg';
|
|
6
|
+
|
|
7
|
+
const ReactColor = loadable.lib(() => import('react-color'));
|
|
8
|
+
|
|
9
|
+
export default (props) => {
|
|
10
|
+
const { id, value, onChange, available_colors } = props;
|
|
11
|
+
const [showPicker, setShowPicker] = React.useState(false);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<FormFieldWrapper
|
|
15
|
+
{...props}
|
|
16
|
+
draggable={false}
|
|
17
|
+
className="simple-color-picker-widget"
|
|
18
|
+
>
|
|
19
|
+
<div>
|
|
20
|
+
<Button.Group fluid>
|
|
21
|
+
<Button
|
|
22
|
+
color={value}
|
|
23
|
+
style={{ backgroundColor: value }}
|
|
24
|
+
onClick={() => setShowPicker(true)}
|
|
25
|
+
size="small"
|
|
26
|
+
fluid
|
|
27
|
+
title="Pick color"
|
|
28
|
+
>
|
|
29
|
+
{''}
|
|
30
|
+
</Button>
|
|
31
|
+
<Button
|
|
32
|
+
compact
|
|
33
|
+
style={{ paddingLeft: '8px', paddingRight: '0px' }}
|
|
34
|
+
onClick={() => onChange(id, null)}
|
|
35
|
+
>
|
|
36
|
+
<Icon name={clearSVG} size="18px" color="red" />
|
|
37
|
+
</Button>
|
|
38
|
+
</Button.Group>
|
|
39
|
+
|
|
40
|
+
{showPicker ? (
|
|
41
|
+
<ReactColor>
|
|
42
|
+
{({ SketchPicker }) => {
|
|
43
|
+
return (
|
|
44
|
+
<SketchPicker
|
|
45
|
+
width="180px"
|
|
46
|
+
colors={available_colors}
|
|
47
|
+
color={value || '#000'}
|
|
48
|
+
onChangeComplete={(value) => {
|
|
49
|
+
setShowPicker(false);
|
|
50
|
+
onChange(id, value.hex);
|
|
51
|
+
}}
|
|
52
|
+
></SketchPicker>
|
|
53
|
+
);
|
|
54
|
+
}}
|
|
55
|
+
</ReactColor>
|
|
56
|
+
) : (
|
|
57
|
+
''
|
|
58
|
+
)}
|
|
59
|
+
</div>
|
|
60
|
+
</FormFieldWrapper>
|
|
61
|
+
);
|
|
62
|
+
};
|
package/src/index.js
CHANGED
|
@@ -5,9 +5,9 @@ import world from '@plone/volto/icons/world.svg';
|
|
|
5
5
|
import DataQueryWidget from './components/widgets/DataQueryWidget';
|
|
6
6
|
import LayerSelectWidget from './components/widgets/LayerSelectWidget';
|
|
7
7
|
import MapEditorWidget from './components/widgets/MapEditorWidget';
|
|
8
|
-
import ObjectTypesWidget from './components/widgets/ObjectTypesWidget';
|
|
9
8
|
import VisualizationEditorWidget from './components/visualization/VisualizationEditorWidget';
|
|
10
9
|
import VisualizationView from './components/visualization/VisualizationView';
|
|
10
|
+
import SimpleColorPickerWidget from './components/widgets/SimpleColorPickerWidget';
|
|
11
11
|
|
|
12
12
|
import { data_visualizations } from './middlewares';
|
|
13
13
|
import * as addonReducers from './reducers';
|
|
@@ -29,36 +29,6 @@ export default (config) => {
|
|
|
29
29
|
'copernicus.discomap.eea.europa.eu',
|
|
30
30
|
];
|
|
31
31
|
|
|
32
|
-
// EEA MAP BLOCK
|
|
33
|
-
|
|
34
|
-
// config.blocks.blocksConfig.eea_map_block = {
|
|
35
|
-
// id: 'eea_map_block', // The name (id) of the block
|
|
36
|
-
// title: 'EEA Map', // The display name of the block
|
|
37
|
-
// icon: world, // The icon used in the block chooser
|
|
38
|
-
// group: 'common', //The group (blocks can be grouped, displayed in the chooser)
|
|
39
|
-
// view: EEAMapView, //The view mode component
|
|
40
|
-
// edit: EEAMapEdit, // The edit mode component
|
|
41
|
-
// sidebarTab: 1, // The sidebar tab you want to be selected when selecting the block
|
|
42
|
-
// security: {
|
|
43
|
-
// addPermission: [], // Future proof (not implemented yet) add user permission role(s)
|
|
44
|
-
// view: [], //Future proof (not implemented yet) view user role(s)
|
|
45
|
-
// },
|
|
46
|
-
// variations: [
|
|
47
|
-
// {
|
|
48
|
-
// id: 'default',
|
|
49
|
-
// title: 'EEA Map (default)',
|
|
50
|
-
// isDefault: true,
|
|
51
|
-
// view: EEAMapView,
|
|
52
|
-
// },
|
|
53
|
-
// {
|
|
54
|
-
// id: 'extra',
|
|
55
|
-
// title: 'Extra variation (expand if needed)',
|
|
56
|
-
// isDefault: true,
|
|
57
|
-
// view: EEAMapView,
|
|
58
|
-
// },
|
|
59
|
-
// ],
|
|
60
|
-
// };
|
|
61
|
-
|
|
62
32
|
config.blocks.blocksConfig.embed_eea_map_block = {
|
|
63
33
|
id: 'embed_eea_map_block', // The name (id) of the block
|
|
64
34
|
title: 'Embed EEA Map', // The display name of the block
|
|
@@ -78,19 +48,13 @@ export default (config) => {
|
|
|
78
48
|
isDefault: true,
|
|
79
49
|
view: EmbedMapView,
|
|
80
50
|
},
|
|
81
|
-
{
|
|
82
|
-
id: 'extra',
|
|
83
|
-
title: 'Extra variation (expand if needed)',
|
|
84
|
-
isDefault: true,
|
|
85
|
-
view: EmbedMapView,
|
|
86
|
-
},
|
|
87
51
|
],
|
|
88
52
|
};
|
|
89
53
|
|
|
90
54
|
config.widgets.widget.map_edit_widget = MapEditorWidget;
|
|
91
55
|
config.widgets.widget.map_layers_widget = LayerSelectWidget;
|
|
92
|
-
config.widgets.widget.object_types_widget = ObjectTypesWidget;
|
|
93
56
|
config.widgets.widget.data_query_widget = DataQueryWidget;
|
|
57
|
+
config.widgets.widget.simple_color_picker_widget = SimpleColorPickerWidget;
|
|
94
58
|
|
|
95
59
|
//map editor for the visualization(content-type)
|
|
96
60
|
config.widgets.id.map_visualization_data = VisualizationEditorWidget;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Menu, Tab } from 'semantic-ui-react';
|
|
3
|
-
import { ObjectWidget } from '@plone/volto/components';
|
|
4
|
-
import { withDeviceSize } from '../../hocs';
|
|
5
|
-
|
|
6
|
-
export const ObjectTypesWidget = (props) => {
|
|
7
|
-
const {
|
|
8
|
-
schemas,
|
|
9
|
-
value = {},
|
|
10
|
-
onChange,
|
|
11
|
-
errors = {},
|
|
12
|
-
id,
|
|
13
|
-
device,
|
|
14
|
-
block,
|
|
15
|
-
} = props;
|
|
16
|
-
const objectId = id;
|
|
17
|
-
|
|
18
|
-
const defaultActiveTab = 0;
|
|
19
|
-
|
|
20
|
-
const [activeTab, setActiveTab] = React.useState(
|
|
21
|
-
defaultActiveTab > -1 ? defaultActiveTab : 0,
|
|
22
|
-
);
|
|
23
|
-
const createTab = ({ schema, id, icon }, index) => {
|
|
24
|
-
return {
|
|
25
|
-
menuItem: () => (
|
|
26
|
-
<Menu.Item
|
|
27
|
-
onClick={() => setActiveTab(index)}
|
|
28
|
-
active={activeTab === index}
|
|
29
|
-
key={id}
|
|
30
|
-
>
|
|
31
|
-
<p style={{ fontSize: '14px', fontWeight: 'bold' }}>{schema.title}</p>
|
|
32
|
-
</Menu.Item>
|
|
33
|
-
),
|
|
34
|
-
render: () => {
|
|
35
|
-
return (
|
|
36
|
-
<Tab.Pane style={{ padding: '0' }}>
|
|
37
|
-
<ObjectWidget
|
|
38
|
-
schema={schema}
|
|
39
|
-
id={id}
|
|
40
|
-
block={block}
|
|
41
|
-
errors={errors}
|
|
42
|
-
value={value[id] || {}}
|
|
43
|
-
onChange={(schemaId, v) => {
|
|
44
|
-
onChange(objectId, { ...value, [schemaId]: v });
|
|
45
|
-
}}
|
|
46
|
-
/>
|
|
47
|
-
</Tab.Pane>
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<Tab
|
|
55
|
-
menu={{
|
|
56
|
-
vertical:
|
|
57
|
-
device === 'computer' || device === 'tablet' || device === 'mobile'
|
|
58
|
-
? false
|
|
59
|
-
: true,
|
|
60
|
-
tabular: true,
|
|
61
|
-
}}
|
|
62
|
-
panes={schemas.map(createTab)}
|
|
63
|
-
activeIndex={activeTab}
|
|
64
|
-
grid={{ paneWidth: 9, tabWidth: 3 }}
|
|
65
|
-
/>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export default withDeviceSize(ObjectTypesWidget);
|