@eeacms/volto-eea-map 0.1.1

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.
Files changed (31) hide show
  1. package/.coverage.babel.config.js +9 -0
  2. package/.project.eslintrc.js +46 -0
  3. package/.release-it.json +17 -0
  4. package/CHANGELOG.md +40 -0
  5. package/DEVELOP.md +51 -0
  6. package/LICENSE.md +9 -0
  7. package/README.md +103 -0
  8. package/RELEASE.md +74 -0
  9. package/babel.config.js +17 -0
  10. package/bootstrap +41 -0
  11. package/cypress.json +17 -0
  12. package/jest-addon.config.js +36 -0
  13. package/locales/volto.pot +0 -0
  14. package/package.json +44 -0
  15. package/src/components/Blocks/EEAMap/Edit.jsx +37 -0
  16. package/src/components/Blocks/EEAMap/Schema.js +32 -0
  17. package/src/components/Blocks/EEAMap/View.jsx +20 -0
  18. package/src/components/Blocks/EEAMap/components/TextView.jsx +7 -0
  19. package/src/components/Blocks/EEAMap/components/Webmap.jsx +194 -0
  20. package/src/components/Blocks/EEAMap/components/widgets/ExtraViews.jsx +53 -0
  21. package/src/components/Blocks/EEAMap/components/widgets/LayerSelectWidget.jsx +113 -0
  22. package/src/components/Blocks/EEAMap/components/widgets/LayersPanel.jsx +56 -0
  23. package/src/components/Blocks/EEAMap/components/widgets/LegendWidget.jsx +63 -0
  24. package/src/components/Blocks/EEAMap/components/widgets/MapEditorWidget.jsx +81 -0
  25. package/src/components/Blocks/EEAMap/components/widgets/ObjectTypesWidget.jsx +53 -0
  26. package/src/components/Blocks/EEAMap/components/widgets/panelsSchema.js +190 -0
  27. package/src/components/Blocks/EEAMap/constants.js +29 -0
  28. package/src/components/Blocks/EEAMap/styles/map.css +22 -0
  29. package/src/components/Blocks/EEAMap/utils.js +17 -0
  30. package/src/components/index.js +4 -0
  31. package/src/index.js +41 -0
@@ -0,0 +1,190 @@
1
+ import { base_layers } from '../../constants';
2
+
3
+ const BaseLayerSchema = {
4
+ title: 'Base Layer',
5
+ fieldsets: [
6
+ {
7
+ id: 'base',
8
+ title: 'Base Layer',
9
+ fields: ['base_layer'],
10
+ },
11
+ ],
12
+ properties: {
13
+ base_layer: {
14
+ title: 'Base Layer',
15
+ choices: base_layers,
16
+ },
17
+ },
18
+ required: [],
19
+ };
20
+
21
+ const LayerSchema = {
22
+ title: 'Layer',
23
+ fieldsets: [
24
+ {
25
+ id: 'default',
26
+ title: 'Layer',
27
+ fields: ['map_layer'],
28
+ },
29
+ ],
30
+ properties: {
31
+ map_layer: {
32
+ title: 'Map layer configuration',
33
+ widget: 'map_layers_widget',
34
+ },
35
+ },
36
+ required: [],
37
+ };
38
+
39
+ const MapLayersSchema = {
40
+ title: 'Map Layers',
41
+ fieldsets: [
42
+ {
43
+ id: 'default',
44
+ title: 'Map Data',
45
+ fields: ['map_layers'],
46
+ },
47
+ ],
48
+ properties: {
49
+ map_layers: {
50
+ title: 'Map Layers',
51
+ description: 'Add/Edit Map Layers',
52
+ widget: 'object_list',
53
+ schema: LayerSchema,
54
+ },
55
+ },
56
+ required: [],
57
+ };
58
+ const PrintSchema = {
59
+ title: 'Print',
60
+ fieldsets: [
61
+ {
62
+ id: 'default',
63
+ title: 'Print',
64
+ fields: ['show_print', 'position'],
65
+ },
66
+ ],
67
+ properties: {
68
+ show_print: {
69
+ title: 'Show print',
70
+ type: 'boolean',
71
+ },
72
+ position: {
73
+ title: 'Print position',
74
+ choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
75
+ (n) => {
76
+ return [n, n];
77
+ },
78
+ ),
79
+ },
80
+ },
81
+ required: [],
82
+ };
83
+
84
+ const ZoomSchema = {
85
+ title: 'Zoom',
86
+ fieldsets: [
87
+ {
88
+ id: 'default',
89
+ title: 'Zoom',
90
+ fields: ['show_zoom', 'position', 'zoom_level', 'long', 'lat'],
91
+ },
92
+ ],
93
+ properties: {
94
+ show_zoom: {
95
+ title: 'Show zoom',
96
+ type: 'boolean',
97
+ },
98
+ position: {
99
+ title: 'Zoom position',
100
+ choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
101
+ (n) => {
102
+ return [n, n];
103
+ },
104
+ ),
105
+ },
106
+ zoom_level: {
107
+ title: 'Zoom level',
108
+ type: 'number',
109
+ },
110
+ long: {
111
+ title: 'Longitude',
112
+ type: 'number',
113
+ },
114
+ lat: {
115
+ title: 'Latitude',
116
+ type: 'number',
117
+ },
118
+ },
119
+ required: [],
120
+ };
121
+
122
+ const GeneralSchema = {
123
+ title: 'General',
124
+ fieldsets: [
125
+ {
126
+ id: 'default',
127
+ title: 'General',
128
+ fields: ['show_sources', 'show_legend', 'show_download', 'show_viewer'],
129
+ },
130
+ ],
131
+ properties: {
132
+ show_sources: {
133
+ title: 'Show sources',
134
+ type: 'boolean',
135
+ },
136
+ show_legend: {
137
+ title: 'Show legend',
138
+ type: 'boolean',
139
+ },
140
+ show_download: {
141
+ title: 'Show download',
142
+ type: 'boolean',
143
+ },
144
+ show_viewer: {
145
+ title: 'Show web viewer',
146
+ type: 'boolean',
147
+ },
148
+ },
149
+ required: [],
150
+ };
151
+
152
+ export const panelsSchema = {
153
+ title: 'Map Editor',
154
+ fieldsets: [
155
+ {
156
+ id: 'default',
157
+ title: 'Map Editor Sections',
158
+ fields: ['map_data'],
159
+ },
160
+ ],
161
+ properties: {
162
+ map_data: {
163
+ title: 'Panels',
164
+ widget: 'object_types_widget',
165
+ schemas: [
166
+ {
167
+ id: 'general',
168
+ schema: GeneralSchema,
169
+ },
170
+ {
171
+ id: 'base',
172
+ schema: BaseLayerSchema,
173
+ },
174
+ {
175
+ id: 'layers',
176
+ schema: MapLayersSchema,
177
+ },
178
+ {
179
+ id: 'print',
180
+ schema: PrintSchema,
181
+ },
182
+ {
183
+ id: 'zoom',
184
+ schema: ZoomSchema,
185
+ },
186
+ ],
187
+ },
188
+ },
189
+ required: [],
190
+ };
@@ -0,0 +1,29 @@
1
+ const positions = ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
2
+ (n) => {
3
+ return { key: n, value: n, text: n };
4
+ },
5
+ );
6
+
7
+ const base_layers = [
8
+ 'dark-gray',
9
+ 'dark-gray-vector',
10
+ 'gray',
11
+ 'gray-vector',
12
+ 'hybrid',
13
+ 'national-geographic',
14
+ 'oceans',
15
+ 'osm',
16
+ 'satellite',
17
+ 'streets',
18
+ 'streets-navigation-vector',
19
+ 'streets-night-vector',
20
+ 'streets-relief-vector',
21
+ 'streets-vector',
22
+ 'terrain',
23
+ 'topo',
24
+ 'topo-vector',
25
+ ].map((n) => {
26
+ return [n, n];
27
+ });
28
+
29
+ export { positions, base_layers };
@@ -0,0 +1,22 @@
1
+ .map-edit-container {
2
+ display: flex;
3
+ }
4
+
5
+ .map-modal-trigger-button {
6
+ margin-bottom: 10px !important;
7
+ }
8
+
9
+ #map-editor-modal {
10
+ top: auto;
11
+ left: auto !important;
12
+ width: 95% !important;
13
+ }
14
+
15
+ #map-widget-toggle {
16
+ color: blue !important;
17
+ }
18
+
19
+ .map-text-view {
20
+ display: flex;
21
+ padding: 1rem 0;
22
+ }
@@ -0,0 +1,17 @@
1
+ /* eslint-disable no-throw-literal */
2
+ import { getBaseUrl } from '@plone/volto/helpers';
3
+
4
+ const fetchArcgisData = async (url) => {
5
+ const res = await fetch(`${getBaseUrl('')}/cors-proxy/${url}?f=json`);
6
+ if (res.status !== 200) {
7
+ const error = await res.json();
8
+ throw { message: error.message, status: error.cod };
9
+ }
10
+ const data = await res.json();
11
+ if (data.error && data.error.code === 400) {
12
+ throw { message: data.error.message.message, status: data.status };
13
+ }
14
+ return data;
15
+ };
16
+
17
+ export { fetchArcgisData };
@@ -0,0 +1,4 @@
1
+ import EEAMapView from './Blocks/EEAMap/View';
2
+ import EEAMapEdit from './Blocks/EEAMap/Edit';
3
+
4
+ export { EEAMapEdit, EEAMapView };
package/src/index.js ADDED
@@ -0,0 +1,41 @@
1
+ import { EEAMapEdit, EEAMapView } from '@eeacms/volto-eea-map/components';
2
+ import world from '@plone/volto/icons/world.svg';
3
+ import LayerSelectWidget from './components/Blocks/EEAMap/components/widgets/LayerSelectWidget';
4
+ import MapEditorWidget from './components/Blocks/EEAMap/components/widgets/MapEditorWidget';
5
+ import ObjectTypesWidget from './components/Blocks/EEAMap/components/widgets/ObjectTypesWidget';
6
+
7
+ export default (config) => {
8
+ config.blocks.blocksConfig.eea_map_block = {
9
+ id: 'eea_map_block', // The name (id) of the block
10
+ title: 'EEA Map', // The display name of the block
11
+ icon: world, // The icon used in the block chooser
12
+ group: 'common', // The group (blocks can be grouped, displayed in the chooser)
13
+ view: EEAMapView, // The view mode component
14
+ edit: EEAMapEdit, // The edit mode component
15
+ sidebarTab: 1, // The sidebar tab you want to be selected when selecting the block
16
+ security: {
17
+ addPermission: [], // Future proof (not implemented yet) add user permission role(s)
18
+ view: [], // Future proof (not implemented yet) view user role(s)
19
+ },
20
+ variations: [
21
+ {
22
+ id: 'default',
23
+ title: 'EEA Map (default)',
24
+ isDefault: true,
25
+ view: EEAMapView,
26
+ },
27
+ {
28
+ id: 'extra',
29
+ title: 'Extra variation (expand if needed)',
30
+ isDefault: true,
31
+ view: EEAMapView,
32
+ },
33
+ ],
34
+ };
35
+
36
+ config.widgets.widget.map_edit_widget = MapEditorWidget;
37
+ config.widgets.widget.map_layers_widget = LayerSelectWidget;
38
+ config.widgets.widget.object_types_widget = ObjectTypesWidget;
39
+
40
+ return config;
41
+ };