• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 18968041869

31 Oct 2025 09:13AM UTC coverage: 76.918% (-0.01%) from 76.932%
18968041869

Pull #11611

github

web-flow
Merge 1b2ac4428 into f5928b825
Pull Request #11611: #11577 Doc build fixed for node 22. Build strategy

31983 of 49693 branches covered (64.36%)

39738 of 51663 relevant lines covered (76.92%)

37.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/web/client/components/widgets/builder/wizard/common/WPSWidgetOptions.jsx
1
/*
2
  * Copyright 2017, GeoSolutions Sas.
3
  * All rights reserved.
4
  *
5
  * This source code is licensed under the BSD-style license found in the
6
  * LICENSE file in the root directory of this source tree.
7
  */
8
import React from 'react';
9
import { get } from 'lodash';
10
import { InputGroup, FormGroup, FormControl, ControlLabel, Button as ButtonRB, Glyphicon } from 'react-bootstrap';
11
import PropTypes from 'prop-types';
12
import Select from 'react-select';
13

14
import Message from '../../../../I18N/Message';
15
import CounterAdvancedOptions from './CounterAdvancedOptions';
16
import { getDefaultNullPlaceholderForDataType } from '../../../../../utils/WidgetsUtils';
17
import tooltip from '../../../../misc/enhancers/tooltip';
18

19
const Button = tooltip(ButtonRB);
1✔
20

21
const getLabelMessageId = (field, data = {}) => `widgets.${field}.${data.type || data.widgetType || "default"}`;
22✔
22

23
const placeHolder = <Message msgId={getLabelMessageId("placeHolder")} />;
1✔
24

25
const WPSWidgetOptions = ({
1✔
26
    hasAggregateProcess,
27
    data = { options: {} },
2✔
28
    onChange = () => { },
1✔
29
    options = [],
×
30
    showTitle = true,
5✔
31
    formOptions = {
8✔
32
        showLayer: true,
33
        showGroupBy: true,
34
        showUom: false,
35
        showLegend: true,
36
        advancedOptions: true
37
    },
38
    aggregationOptions = [],
×
39
    sampleChart,
40
    onChangeLayer,
41
    onFilterLayer = () => {},
5✔
42
    error
43
}) => {
44

45
    return (
9✔
46
        <>
47
            {/* this sticky style helps to keep showing chart when scrolling*/}
48
            {sampleChart && <div style={{ position: "sticky", top: 0, zIndex: 1}}>
10✔
49
                <div style={{marginBottom: "30px"}}>
50
                    {sampleChart}
51
                </div>
52
            </div>}
53
            {showTitle && <div className="ms-wizard-form-separator"><Message msgId={`widgets.chartOptionsTitle`} /></div>}
14✔
54
            <div className="chart-options-form">
55
                {formOptions.showLayer && <FormGroup className="form-group-flex">
17✔
56
                    <ControlLabel>Layer</ControlLabel>
57
                    <InputGroup style={{ zIndex: 0 }}>
58
                        <FormControl  value={data?.layer?.title || data?.layer?.name} disabled/>
15✔
59
                        {onChangeLayer && <InputGroup.Button>
8!
60
                            <Button
61
                                bsStyle="primary"
62
                                onClick={() => onChangeLayer()}
×
63
                                tooltipId={'widgets.builder.selectLayer'}
64
                            >
65
                                <Glyphicon glyph="cog" />
66
                            </Button>
67
                        </InputGroup.Button>}
68
                        <InputGroup.Button>
69
                            <Button
70
                                bsStyle={data?.filter ? 'success' : 'primary'}
8!
71
                                onClick={() => onFilterLayer()}
×
72
                                tooltipId={'widgets.builder.filterLayer'}
73
                            >
74
                                <Glyphicon glyph="filter" />
75
                            </Button>
76
                        </InputGroup.Button>
77
                    </InputGroup>
78
                </FormGroup>}
79
                {formOptions.showGroupBy ? (
9✔
80
                    <FormGroup controlId="groupByAttributes" className="form-group-flex"
81
                        validationState={error ? 'error' :  !data?.options?.groupByAttributes ? 'warning' : ''}>
16!
82
                        <ControlLabel>
83
                            <Message msgId={getLabelMessageId("groupByAttributes", data)} />
84
                        </ControlLabel>
85
                        <InputGroup>
86
                            <Select
87
                                value={data.options && data.options.groupByAttributes}
12✔
88
                                options={options}
89
                                placeholder={placeHolder}
90
                                onChange={(val) => {
91
                                    onChange("options.groupByAttributes", val && val.value);
2✔
92
                                    // side Effect of groupByAttributes change, reset default Value of placeHolder
93
                                    setTimeout(() => {
2✔
94
                                        onChange("options.nullHandling.groupByAttributes.placeholder", getDefaultNullPlaceholderForDataType(val?.type));
2✔
95
                                    }, 200);
96
                                }}
97
                            />
98
                        </InputGroup>
99
                    </FormGroup>) : null}
100
                <FormGroup controlId="aggregationAttribute" className="form-group-flex"
101
                    validationState={error ? 'error' :  !data?.options?.aggregationAttribute ? 'warning' : ''}>
18!
102
                    <ControlLabel>
103
                        <Message msgId={getLabelMessageId("aggregationAttribute", data)} />
104
                    </ControlLabel>
105
                    <InputGroup>
106
                        <Select
107
                            value={data.options && data.options.aggregationAttribute}
14✔
108
                            options={options}
109
                            placeholder={placeHolder}
110
                            onChange={(val) => {
111
                                onChange("options.aggregationAttribute", val && val.value);
3✔
112
                            }}
113
                        />
114
                    </InputGroup>
115
                </FormGroup>
116
                {hasAggregateProcess ? <FormGroup controlId="aggregateFunction" className="form-group-flex"
9✔
117
                    validationState={error ? 'error' :  !data?.options?.aggregateFunction ? 'warning' : ''}>
6!
118
                    <ControlLabel>
119
                        <Message msgId={getLabelMessageId("aggregateFunction", data)} />
120
                    </ControlLabel>
121
                    <InputGroup>
122
                        <Select
123
                            value={data.options && data.options.aggregateFunction}
5✔
124
                            options={aggregationOptions}
125
                            placeholder={placeHolder}
126
                            onChange={(val) => { onChange("options.aggregateFunction", val && val.value); }}
2✔
127
                        />
128
                    </InputGroup>
129
                </FormGroup> : null}
130
                {formOptions.showUom ?
9✔
131
                    <FormGroup controlId="uom" className="form-group-flex">
132
                        <ControlLabel>
133
                            <Message msgId={getLabelMessageId("uom", data)} />
134
                        </ControlLabel>
135
                        <InputGroup>
136
                            <FormControl value={get(data, `options.seriesOptions[0].uom`)} type="text" onChange={e => onChange("options.seriesOptions.[0].uom", e.target.value)} />
1✔
137
                        </InputGroup>
138
                    </FormGroup> : null}
139
                {formOptions.advancedOptions && data.widgetType === "counter"
26!
140
                    ? <CounterAdvancedOptions
141
                        data={data}
142
                        onChange={onChange}
143
                    />
144
                    : null}
145
            </div>
146
        </>
147
    );
148
};
149

150
WPSWidgetOptions.propTypes = {
1✔
151
    aggregationOptions: PropTypes.array,
152
    data: PropTypes.object,
153
    formOptions: PropTypes.object,
154
    hasAggregateProcess: PropTypes.bool,
155
    layer: PropTypes.object,
156
    onChange: PropTypes.func,
157
    options: PropTypes.array,
158
    sampleChart: PropTypes.node,
159
    showTitle: PropTypes.bool
160
};
161
export default WPSWidgetOptions;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc