forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommonAdvancedSettings.jsx
104 lines (101 loc) · 4.53 KB
/
CommonAdvancedSettings.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2020, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import { isNil } from 'lodash';
import ReactQuill from "react-quill";
import { FormGroup, Checkbox, Col } from "react-bootstrap";
import Message from "../../../I18N/Message";
import InfoPopover from '../../../widgets/widget/InfoPopover';
import CSWFilters from "./CSWFilters";
/**
* Common Advanced settings form, used by WMS/CSW/WMTS
*/
export default ({
children,
service,
isLocalizedLayerStylesEnabled,
onChangeMetadataTemplate = () => { },
onChangeServiceProperty = () => { },
onToggleTemplate = () => { },
onToggleThumbnail = () => { }
}) => (
<div>
<FormGroup controlId="autoload" key="autoload">
<Col xs={12}>
{service.autoload !== undefined && <Checkbox value="autoload" onChange={(e) => onChangeServiceProperty("autoload", e.target.checked)}
checked={!isNil(service.autoload) ? service.autoload : false}>
<Message msgId="catalog.autoload" />
</Checkbox>}
</Col>
</FormGroup>
<FormGroup controlId="thumbnail" key="thumbnail">
<Col xs={12}>
<Checkbox
onChange={() => onToggleThumbnail()}
checked={!isNil(service.hideThumbnail) ? !service.hideThumbnail : true}>
<Message msgId="catalog.showPreview" />
</Checkbox>
</Col>
</FormGroup>
{(isLocalizedLayerStylesEnabled && !isNil(service.type) ? service.type === "wms" : false) && (<FormGroup controlId="localized-styles" key="localized-styles">
<Col xs={12}>
<Checkbox data-qa="service-lacalized-layer-styles-option"
onChange={(e) => onChangeServiceProperty("localizedLayerStyles", e.target.checked)}
checked={!isNil(service.localizedLayerStyles) ? service.localizedLayerStyles : false}>
<Message msgId="catalog.enableLocalizedLayerStyles.label" /> <InfoPopover text={<Message msgId="catalog.enableLocalizedLayerStyles.tooltip" />} />
</Checkbox>
</Col>
</FormGroup>)}
{(!isNil(service.type) ? (service.type === "csw" && !service.excludeShowTemplate) : false) && (<FormGroup controlId="metadata-template" key="metadata-template" className="metadata-template-editor">
<Col xs={12}>
<Checkbox
onChange={() => onToggleTemplate()}
checked={service && service.showTemplate}>
<Message msgId="catalog.showTemplate" />
</Checkbox>
<br />
</Col>
{service && service.showTemplate &&
(<Col xs={12}>
<span>
<p>
<Message msgId="layerProperties.templateFormatInfoAlert2" msgParams={{ attribute: "{ }" }} />
</p>
<pre>
<Message msgId="catalog.templateFormatDescriptionExample" />{" ${ description }"}
</pre>
</span>
</Col>)}
<Col xs={12}>
{service && service.showTemplate && <ReactQuill
modules={{
toolbar: [
[{ "size": ["small", false, "large", "huge"] }, "bold", "italic", "underline", "blockquote"],
[{ "list": "bullet" }, { "align": [] }],
[{ "color": [] }, { "background": [] }, "clean"], ["link"]
]
}}
value={service.metadataTemplate || ""}
onChange={(metadataTemplate) => {
if (metadataTemplate && metadataTemplate !== "<p><br></p>") {
onChangeMetadataTemplate(metadataTemplate);
} else {
// TODO think about this
onChangeMetadataTemplate("");
}
}} />
}
</Col>
</FormGroup>)}
{children}
{!isNil(service.type) && service.type === "csw" &&
<CSWFilters filter={service?.filter} onChangeServiceProperty={onChangeServiceProperty}/>
}
</div>
);