@eeacms/volto-eea-map 4.1.0 → 5.0.0
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/CHANGELOG.md +29 -0
- package/package.json +5 -2
- package/src/Arcgis/Editor/Editor.jsx +130 -0
- package/src/Arcgis/Editor/EditorContext.jsx +2 -0
- package/src/Arcgis/Editor/Fold/Fold.jsx +56 -0
- package/src/Arcgis/Editor/Panels/Panel.jsx +8 -0
- package/src/Arcgis/Editor/Panels/SettingsGeneralPanel.jsx +217 -0
- package/src/Arcgis/Editor/Panels/SettingsLayersPanel.jsx +216 -0
- package/src/Arcgis/Editor/Panels/StructureBaseLayerPanel.jsx +60 -0
- package/src/Arcgis/Editor/Panels/StructureLayersPanel.jsx +394 -0
- package/src/Arcgis/Editor/Panels/StructureWidgetsPanel.jsx +181 -0
- package/src/Arcgis/Editor/Panels/index.js +6 -0
- package/src/Arcgis/Editor/SidebarGroup.jsx +62 -0
- package/src/Arcgis/Layer/Layer.jsx +247 -0
- package/src/Arcgis/Map/Map.jsx +287 -0
- package/src/Arcgis/Map/MapBuilder.jsx +111 -0
- package/src/Arcgis/Map/MapContext.jsx +3 -0
- package/src/Arcgis/Widget/Widget.jsx +170 -0
- package/src/Arcgis/helpers.js +140 -0
- package/src/Blocks/EmbedEEAMap/Edit.jsx +40 -0
- package/src/Blocks/EmbedEEAMap/View.jsx +122 -0
- package/src/Blocks/EmbedEEAMap/helpers.js +12 -0
- package/src/Blocks/EmbedEEAMap/schema.js +126 -0
- package/src/{components → Toolbar}/Share.jsx +1 -1
- package/src/{components/ExtraViews.jsx → Toolbar/Toolbar.jsx} +14 -16
- package/src/{components/visualization → Views}/VisualizationView.jsx +8 -9
- package/src/Widgets/ArcgisColorPickerWidget.jsx +95 -0
- package/src/Widgets/ArcgisRendererWidget/ArcgisRendererWidget.jsx +106 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/ClassBreaks.jsx +8 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/Dictionary.jsx +8 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/DotDensity.jsx +8 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/Heatmap.jsx +8 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/PieChart.jsx +8 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/Simple.jsx +109 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/UniqueValue.jsx +8 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/_Editor.jsx +29 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/_EditorModal.jsx +88 -0
- package/src/Widgets/ArcgisRendererWidget/RendererEditor/_defaults.js +30 -0
- package/src/Widgets/ArcgisSliderWidget.jsx +79 -0
- package/src/Widgets/ArcgisViewpointWidget.jsx +112 -0
- package/src/{components/visualization → Widgets}/VisualizationViewWidget.jsx +9 -10
- package/src/Widgets/VisualizationWidget.jsx +200 -0
- package/src/arcgis.js +48 -0
- package/src/constants.js +225 -7
- package/src/hocs/withArcgis.jsx +27 -0
- package/src/hooks/useChangedProps.jsx +24 -0
- package/src/hooks/useClass.jsx +17 -0
- package/src/hooks/useCopyToClipboard.jsx +25 -0
- package/src/index.js +16 -16
- package/src/jsoneditor.js +72 -0
- package/src/styles/editor.less +446 -0
- package/src/styles/map.less +3 -0
- package/src/components/Blocks/EmbedEEAMap/Edit.jsx +0 -161
- package/src/components/Blocks/EmbedEEAMap/Schema.js +0 -161
- package/src/components/Blocks/EmbedEEAMap/View.jsx +0 -79
- package/src/components/Blocks/EmbedEEAMap/helpers.js +0 -45
- package/src/components/LegendView.jsx +0 -150
- package/src/components/Webmap.jsx +0 -371
- package/src/components/index.js +0 -6
- package/src/components/visualization/VisualizationEditorWidget.jsx +0 -122
- package/src/components/visualization/panelsSchema.js +0 -229
- package/src/components/widgets/DataQueryWidget.jsx +0 -51
- package/src/components/widgets/LayerSelectWidget.jsx +0 -463
- package/src/components/widgets/LayersPanelWidget.jsx +0 -59
- package/src/components/widgets/SimpleColorPickerWidget.jsx +0 -121
- package/src/hocs/index.js +0 -3
- package/src/hocs/withDeviceSize.jsx +0 -45
- package/src/less/global.less +0 -253
- package/src/less/variables.less +0 -5
- package/src/utils.js +0 -151
- /package/src/{components → Toolbar}/FigureNote.jsx +0 -0
- /package/src/{components → Toolbar}/MoreInfoLink.jsx +0 -0
- /package/src/{components → Toolbar}/Sources.jsx +0 -0
|
@@ -2,13 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { hasBlocksData } from '@plone/volto/helpers';
|
|
3
3
|
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
4
4
|
import { pickMetadata } from '@eeacms/volto-embed/helpers';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import MapBuilder from '@eeacms/volto-eea-map/Arcgis/Map/MapBuilder';
|
|
6
|
+
import Toolbar from '../Toolbar/Toolbar';
|
|
7
7
|
|
|
8
8
|
const VisualizationView = (props) => {
|
|
9
9
|
const content = props && props.content ? props.content : {};
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const mapData =
|
|
12
12
|
content && content.map_visualization_data
|
|
13
13
|
? content.map_visualization_data
|
|
14
14
|
: {};
|
|
@@ -19,17 +19,16 @@ const VisualizationView = (props) => {
|
|
|
19
19
|
<RenderBlocks {...props} />
|
|
20
20
|
) : (
|
|
21
21
|
<>
|
|
22
|
-
<
|
|
23
|
-
<
|
|
22
|
+
<MapBuilder data={mapData} />
|
|
23
|
+
<Toolbar
|
|
24
|
+
style={{ marginTop: '1rem' }}
|
|
24
25
|
data={{
|
|
25
|
-
show_viewer: true,
|
|
26
|
-
show_legend: true,
|
|
27
26
|
show_note: false,
|
|
28
27
|
show_sources: false,
|
|
29
28
|
show_more_info: false,
|
|
30
29
|
show_share: true,
|
|
31
|
-
|
|
32
|
-
...
|
|
30
|
+
mapData: {
|
|
31
|
+
...mapData,
|
|
33
32
|
...pickMetadata(content),
|
|
34
33
|
},
|
|
35
34
|
}}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useEffect, useState, useRef } 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
|
+
function colorToRGBA(color) {
|
|
10
|
+
const r = color.r;
|
|
11
|
+
const g = color.g;
|
|
12
|
+
const b = color.b;
|
|
13
|
+
const a = color.a;
|
|
14
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function ArcgisColorPickerWidget(props) {
|
|
18
|
+
const el = useRef(null);
|
|
19
|
+
const colorPickerEl = useRef(null);
|
|
20
|
+
const { $map, id, value, onChange, available_colors } = props;
|
|
21
|
+
const [showColorPicker, setShowColorPicker] = useState(false);
|
|
22
|
+
|
|
23
|
+
const color = new $map.current.modules.AgColor(value);
|
|
24
|
+
|
|
25
|
+
function onClickOutside(e) {
|
|
26
|
+
if (el.current && !el.current.contains(e.target)) {
|
|
27
|
+
setShowColorPicker(false);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
window.addEventListener('click', onClickOutside);
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
window.removeEventListener('click', onClickOutside);
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<FormFieldWrapper {...props}>
|
|
41
|
+
<div ref={el} style={{ display: 'flex', alignItems: 'center' }}>
|
|
42
|
+
<Button
|
|
43
|
+
style={{
|
|
44
|
+
margin: 0,
|
|
45
|
+
backgroundColor: colorToRGBA(color),
|
|
46
|
+
}}
|
|
47
|
+
onClick={() =>
|
|
48
|
+
setShowColorPicker((showColorPicker) => !showColorPicker)
|
|
49
|
+
}
|
|
50
|
+
size="small"
|
|
51
|
+
fluid
|
|
52
|
+
title="Show color picker"
|
|
53
|
+
/>
|
|
54
|
+
<Button
|
|
55
|
+
compact
|
|
56
|
+
style={{ margin: 0, padding: '8px' }}
|
|
57
|
+
onClick={() => onChange(id, null)}
|
|
58
|
+
>
|
|
59
|
+
<Icon name={clearSVG} size="18px" color="red" style={{ margin: 0 }} />
|
|
60
|
+
</Button>
|
|
61
|
+
{showColorPicker && (
|
|
62
|
+
<div
|
|
63
|
+
ref={colorPickerEl}
|
|
64
|
+
style={{
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
bottom: '100%',
|
|
67
|
+
left: '50%',
|
|
68
|
+
transform: 'translateX(-50%)',
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<ReactColor>
|
|
72
|
+
{({ SketchPicker }) => {
|
|
73
|
+
return (
|
|
74
|
+
<SketchPicker
|
|
75
|
+
width="180px"
|
|
76
|
+
style={{
|
|
77
|
+
borderBottomLeftRadius: 0,
|
|
78
|
+
borderBottomRightRadius: 0,
|
|
79
|
+
}}
|
|
80
|
+
colors={available_colors}
|
|
81
|
+
color={color}
|
|
82
|
+
onChangeComplete={(color) => {
|
|
83
|
+
const { r, g, b, a } = color.rgb;
|
|
84
|
+
onChange(id, [r, g, b, a]);
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}}
|
|
89
|
+
</ReactColor>
|
|
90
|
+
</div>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
</FormFieldWrapper>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { compose } from 'redux';
|
|
3
|
+
import { injectIntl } from 'react-intl';
|
|
4
|
+
import { FormFieldWrapper, Icon } from '@plone/volto/components';
|
|
5
|
+
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
6
|
+
import {
|
|
7
|
+
customSelectStyles,
|
|
8
|
+
DropdownIndicator,
|
|
9
|
+
ClearIndicator,
|
|
10
|
+
Option,
|
|
11
|
+
selectTheme,
|
|
12
|
+
MultiValueContainer,
|
|
13
|
+
} from '@plone/volto/components/manage/Widgets/SelectStyling';
|
|
14
|
+
import { normalizeValue } from '@plone/volto/components/manage/Widgets/SelectUtils';
|
|
15
|
+
import {
|
|
16
|
+
rendererTypes,
|
|
17
|
+
renderersMapping,
|
|
18
|
+
} from '@eeacms/volto-eea-map/constants';
|
|
19
|
+
import RendererEditor from './RendererEditor/_Editor';
|
|
20
|
+
import RendererEditorModal from './RendererEditor/_EditorModal';
|
|
21
|
+
import { simpleFillSymbol } from './RendererEditor/_defaults';
|
|
22
|
+
|
|
23
|
+
import editSVG from '@plone/volto/icons/editing.svg';
|
|
24
|
+
|
|
25
|
+
function ArcgisRendererWidget(props) {
|
|
26
|
+
const [open, setOpen] = useState(false);
|
|
27
|
+
const { value, id, intl, onChange } = props;
|
|
28
|
+
const $type = renderersMapping[value?.type] || value?.type;
|
|
29
|
+
const type = normalizeValue(rendererTypes, $type, intl);
|
|
30
|
+
|
|
31
|
+
const Select = props.reactSelect.default;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<FormFieldWrapper
|
|
36
|
+
{...props}
|
|
37
|
+
title={
|
|
38
|
+
<button
|
|
39
|
+
className="btn-primary"
|
|
40
|
+
style={{ fontSize: 'var(--font-size-small)' }}
|
|
41
|
+
onClick={() => {
|
|
42
|
+
setOpen(true);
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<Icon name={editSVG} size="20px" />
|
|
46
|
+
Renderer
|
|
47
|
+
</button>
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
<Select
|
|
51
|
+
id={`field-${id}`}
|
|
52
|
+
name={id}
|
|
53
|
+
menuShouldScrollIntoView={false}
|
|
54
|
+
isDisabled={false}
|
|
55
|
+
isSearchable={true}
|
|
56
|
+
className="react-select-container"
|
|
57
|
+
classNamePrefix="react-select"
|
|
58
|
+
isMulti={false}
|
|
59
|
+
options={rendererTypes}
|
|
60
|
+
styles={customSelectStyles}
|
|
61
|
+
theme={selectTheme}
|
|
62
|
+
components={{
|
|
63
|
+
MultiValueContainer,
|
|
64
|
+
DropdownIndicator,
|
|
65
|
+
ClearIndicator,
|
|
66
|
+
Option: props.customOptionStyling || Option,
|
|
67
|
+
}}
|
|
68
|
+
value={type}
|
|
69
|
+
placeholder="Select a renderer type..."
|
|
70
|
+
onChange={(selectedOption) => {
|
|
71
|
+
return onChange(id, {
|
|
72
|
+
autocast: true,
|
|
73
|
+
type:
|
|
74
|
+
selectedOption && selectedOption.value !== 'no-value'
|
|
75
|
+
? selectedOption.value
|
|
76
|
+
: undefined,
|
|
77
|
+
...(selectedOption.value === 'simple'
|
|
78
|
+
? { symbol: simpleFillSymbol }
|
|
79
|
+
: {}),
|
|
80
|
+
});
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
</FormFieldWrapper>
|
|
84
|
+
<div className="arcgis-renderer-editor">
|
|
85
|
+
<RendererEditor {...props} type={$type} />
|
|
86
|
+
{open && (
|
|
87
|
+
<RendererEditorModal
|
|
88
|
+
value={value}
|
|
89
|
+
onChange={(newValue) => {
|
|
90
|
+
onChange(id, newValue);
|
|
91
|
+
}}
|
|
92
|
+
onClose={() => {
|
|
93
|
+
setOpen(false);
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const ArcgisRendererWidgetComponent = injectIntl(ArcgisRendererWidget);
|
|
103
|
+
|
|
104
|
+
export default compose(injectLazyLibs(['reactSelect']))(
|
|
105
|
+
ArcgisRendererWidgetComponent,
|
|
106
|
+
);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { toNumber } from 'lodash';
|
|
2
|
+
|
|
3
|
+
import { InlineForm } from '@plone/volto/components';
|
|
4
|
+
|
|
5
|
+
import { simpleSymbols as simpleSymbolsOptions } from '@eeacms/volto-eea-map/constants';
|
|
6
|
+
|
|
7
|
+
import { simpleSymbols } from '../RendererEditor/_defaults';
|
|
8
|
+
|
|
9
|
+
export default function Simple(props) {
|
|
10
|
+
const { $map, value, id, onChange } = props;
|
|
11
|
+
|
|
12
|
+
const symbol = value?.symbol || {};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<InlineForm
|
|
16
|
+
schema={{
|
|
17
|
+
title: 'Symbol',
|
|
18
|
+
fieldsets: [
|
|
19
|
+
{
|
|
20
|
+
id: 'default',
|
|
21
|
+
title: 'Default',
|
|
22
|
+
fields: [],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'symbol',
|
|
26
|
+
title: 'Symbol',
|
|
27
|
+
fields: [
|
|
28
|
+
'type',
|
|
29
|
+
...(['simple-fill', 'simple-marker', 'simple-line'].includes(
|
|
30
|
+
symbol.type,
|
|
31
|
+
)
|
|
32
|
+
? ['color']
|
|
33
|
+
: []),
|
|
34
|
+
...(['simple-fill', 'simple-marker'].includes(symbol.type)
|
|
35
|
+
? ['outline_color', 'outline_width']
|
|
36
|
+
: []),
|
|
37
|
+
...(symbol.type === 'simple-marker' ? ['size'] : []),
|
|
38
|
+
...(symbol.type === 'simple-line' ? ['width'] : []),
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
properties: {
|
|
43
|
+
type: {
|
|
44
|
+
title: 'Type',
|
|
45
|
+
choices: simpleSymbolsOptions,
|
|
46
|
+
},
|
|
47
|
+
color: {
|
|
48
|
+
title: 'Color',
|
|
49
|
+
widget: 'arcgis_color_picker',
|
|
50
|
+
$map,
|
|
51
|
+
},
|
|
52
|
+
outline_color: {
|
|
53
|
+
title: 'Outline color',
|
|
54
|
+
widget: 'arcgis_color_picker',
|
|
55
|
+
$map,
|
|
56
|
+
},
|
|
57
|
+
outline_width: {
|
|
58
|
+
title: 'Outline width',
|
|
59
|
+
type: 'number',
|
|
60
|
+
minimum: 0,
|
|
61
|
+
step: 0.1,
|
|
62
|
+
},
|
|
63
|
+
size: {
|
|
64
|
+
title: 'Size',
|
|
65
|
+
type: 'number',
|
|
66
|
+
minimum: 0,
|
|
67
|
+
step: 0.1,
|
|
68
|
+
},
|
|
69
|
+
width: {
|
|
70
|
+
title: 'Width',
|
|
71
|
+
type: 'number',
|
|
72
|
+
minimum: 0,
|
|
73
|
+
step: 0.1,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: [],
|
|
77
|
+
}}
|
|
78
|
+
formData={{
|
|
79
|
+
...symbol,
|
|
80
|
+
outline_color: symbol.outline?.color,
|
|
81
|
+
outline_width: symbol.outline?.width,
|
|
82
|
+
}}
|
|
83
|
+
onChangeField={(symbolId, fieldValue) => {
|
|
84
|
+
let $fieldValue = fieldValue;
|
|
85
|
+
|
|
86
|
+
if (['outline_width', 'size', 'width'].includes(symbolId)) {
|
|
87
|
+
$fieldValue = Math.max(toNumber(fieldValue) || 0, 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onChange(id, {
|
|
91
|
+
...(value || {}),
|
|
92
|
+
...(symbolId === 'type' ? { autocast: true } : {}),
|
|
93
|
+
symbol: {
|
|
94
|
+
...(symbolId !== 'type' ? symbol : {}),
|
|
95
|
+
...(symbolId === 'type' ? simpleSymbols[fieldValue] || {} : {}),
|
|
96
|
+
...(['outline_color', 'outline_width'].includes(symbolId)
|
|
97
|
+
? {
|
|
98
|
+
outline: {
|
|
99
|
+
...(symbol.outline || {}),
|
|
100
|
+
[symbolId.replace('outline_', '')]: $fieldValue,
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
: { [symbolId]: $fieldValue }),
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import Simple from './Simple';
|
|
4
|
+
import UniqueValue from './UniqueValue';
|
|
5
|
+
import Heatmap from './Heatmap';
|
|
6
|
+
import ClassBreaks from './ClassBreaks';
|
|
7
|
+
import Dictionary from './Dictionary';
|
|
8
|
+
import DotDensity from './DotDensity';
|
|
9
|
+
import PieChart from './PieChart';
|
|
10
|
+
|
|
11
|
+
const types = {
|
|
12
|
+
simle: Simple,
|
|
13
|
+
'unique-value': UniqueValue,
|
|
14
|
+
heatmap: Heatmap,
|
|
15
|
+
'class-breaks': ClassBreaks,
|
|
16
|
+
dictionary: Dictionary,
|
|
17
|
+
'dot-density': DotDensity,
|
|
18
|
+
'pie-chart': PieChart,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function getRendererByType(type) {
|
|
22
|
+
return types[type] || Simple;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default function Editor(props) {
|
|
26
|
+
const Renderer = useMemo(() => getRendererByType(props.type), [props.type]);
|
|
27
|
+
|
|
28
|
+
return <Renderer {...props} />;
|
|
29
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Modal, Button } from 'semantic-ui-react';
|
|
3
|
+
import { toast } from 'react-toastify';
|
|
4
|
+
import { Toast } from '@plone/volto/components';
|
|
5
|
+
import {
|
|
6
|
+
initEditor,
|
|
7
|
+
destroyEditor,
|
|
8
|
+
validateEditor,
|
|
9
|
+
onPasteEditor,
|
|
10
|
+
} from '@eeacms/volto-eea-map/jsoneditor';
|
|
11
|
+
|
|
12
|
+
export default function EditorModal(props) {
|
|
13
|
+
const { value, onClose, onChange } = props;
|
|
14
|
+
const editor = useRef();
|
|
15
|
+
const initailValue = useRef(props.value);
|
|
16
|
+
|
|
17
|
+
async function getValue() {
|
|
18
|
+
const valid = await validateEditor(editor);
|
|
19
|
+
if (!valid) {
|
|
20
|
+
throw new Error('Invalid JSON');
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
return editor.current.get();
|
|
24
|
+
} catch {
|
|
25
|
+
throw new Error('Invalid JSON');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
initEditor({
|
|
31
|
+
el: 'jsoneditor-plotlyjson',
|
|
32
|
+
editor,
|
|
33
|
+
options: {
|
|
34
|
+
schema: undefined,
|
|
35
|
+
},
|
|
36
|
+
dflt: initailValue.current,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const editorCurr = editor.current;
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
destroyEditor(editorCurr);
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Modal size="fullscreen" open={true} className="plotly-json-modal">
|
|
48
|
+
<Modal.Content scrolling>
|
|
49
|
+
<div
|
|
50
|
+
id="jsoneditor-plotlyjson"
|
|
51
|
+
style={{ width: '100%', height: '100%' }}
|
|
52
|
+
onPaste={(e) => {
|
|
53
|
+
onPasteEditor(editor);
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
</Modal.Content>
|
|
57
|
+
<Modal.Actions>
|
|
58
|
+
<Button
|
|
59
|
+
onClick={() => {
|
|
60
|
+
onChange(initailValue.current);
|
|
61
|
+
onClose();
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
Close
|
|
65
|
+
</Button>
|
|
66
|
+
<Button
|
|
67
|
+
primary
|
|
68
|
+
onClick={async () => {
|
|
69
|
+
try {
|
|
70
|
+
const newValue = {
|
|
71
|
+
...value,
|
|
72
|
+
...(await getValue()),
|
|
73
|
+
};
|
|
74
|
+
onChange(newValue);
|
|
75
|
+
onClose();
|
|
76
|
+
} catch (error) {
|
|
77
|
+
toast.error(
|
|
78
|
+
<Toast error title={'JSON error'} content={error.message} />,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
Apply
|
|
84
|
+
</Button>
|
|
85
|
+
</Modal.Actions>
|
|
86
|
+
</Modal>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const simpleFillSymbol = {
|
|
2
|
+
type: 'simple-fill',
|
|
3
|
+
color: [17, 157, 255, 0.5],
|
|
4
|
+
outline: {
|
|
5
|
+
color: [17, 157, 255, 0.6],
|
|
6
|
+
width: 0.5,
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const simpleMarkerSymbol = {
|
|
11
|
+
type: 'simple-marker',
|
|
12
|
+
size: 8,
|
|
13
|
+
color: [17, 157, 255, 0.2],
|
|
14
|
+
outline: {
|
|
15
|
+
color: [17, 157, 255, 0.8],
|
|
16
|
+
width: 0.5,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const simpleLineSymbol = {
|
|
21
|
+
type: 'simple-line',
|
|
22
|
+
color: [17, 157, 255, 0.5],
|
|
23
|
+
width: 1,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const simpleSymbols = {
|
|
27
|
+
'simple-fill': simpleFillSymbol,
|
|
28
|
+
'simple-line': simpleLineSymbol,
|
|
29
|
+
'simple-marker': simpleMarkerSymbol,
|
|
30
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArcgisSliderWidget component.
|
|
3
|
+
* @module components/manage/Widgets/ArcgisSliderWidget
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { Component } from 'react';
|
|
7
|
+
|
|
8
|
+
import { FormFieldWrapper } from '@plone/volto/components';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The simple slider widget.
|
|
12
|
+
*
|
|
13
|
+
* It is the default fallback widget, so if no other widget is found based on
|
|
14
|
+
* passed field properties, it will be used.
|
|
15
|
+
*/
|
|
16
|
+
class ArcgisSliderWidget extends Component {
|
|
17
|
+
/**
|
|
18
|
+
* Component did mount lifecycle method
|
|
19
|
+
* @method componentDidMount
|
|
20
|
+
* @returns {undefined}
|
|
21
|
+
*/
|
|
22
|
+
componentDidMount() {
|
|
23
|
+
if (this.props.focus) {
|
|
24
|
+
this.node.focus();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Render method.
|
|
30
|
+
* @method render
|
|
31
|
+
* @returns {string} Markup for the component.
|
|
32
|
+
*/
|
|
33
|
+
render() {
|
|
34
|
+
const { id, value, onChange, min = 0, max = 1, step = 0.1 } = this.props;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<FormFieldWrapper {...this.props} className="text">
|
|
38
|
+
<div style={{ display: 'flex', flexFlow: 'column', marginTop: '1rem' }}>
|
|
39
|
+
<input
|
|
40
|
+
className="map-number-input"
|
|
41
|
+
type="number"
|
|
42
|
+
min={min}
|
|
43
|
+
max={max}
|
|
44
|
+
step={step}
|
|
45
|
+
value={value}
|
|
46
|
+
onChange={({ target }) => {
|
|
47
|
+
if (target.value < min) {
|
|
48
|
+
target.value = min;
|
|
49
|
+
}
|
|
50
|
+
if (target.value > max) {
|
|
51
|
+
target.value = max;
|
|
52
|
+
}
|
|
53
|
+
onChange(id, target.value === '' ? undefined : target.value);
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
<input
|
|
57
|
+
className="map-range-input"
|
|
58
|
+
type="range"
|
|
59
|
+
min={min}
|
|
60
|
+
max={max}
|
|
61
|
+
step={step}
|
|
62
|
+
value={value}
|
|
63
|
+
onChange={({ target }) => {
|
|
64
|
+
if (target.value < min) {
|
|
65
|
+
target.value = min;
|
|
66
|
+
}
|
|
67
|
+
if (target.value > max) {
|
|
68
|
+
target.value = max;
|
|
69
|
+
}
|
|
70
|
+
onChange(id, target.value === '' ? undefined : target.value);
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
</FormFieldWrapper>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default ArcgisSliderWidget;
|