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

geosolutions-it / MapStore2 / 19710972030

26 Nov 2025 03:38PM UTC coverage: 76.665% (-0.3%) from 76.929%
19710972030

Pull #11119

github

web-flow
Fix maven publish (#11739)
Pull Request #11119: Layer Selection Plugin on ArcGIS, WFS & WMS layers

32272 of 50209 branches covered (64.28%)

3 of 3 new or added lines in 2 files covered. (100.0%)

3018 existing lines in 249 files now uncovered.

40157 of 52380 relevant lines covered (76.66%)

37.9 hits per line

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

92.31
/web/client/components/data/query/NumberField.jsx
1
/**
2
 * Copyright 2016, 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

9
import React from 'react';
10

11
import PropTypes from 'prop-types';
12
import { Tooltip } from 'react-bootstrap';
13
import OverlayTrigger from '../../misc/OverlayTrigger';
14
import { getMessageById } from '../../../utils/LocaleUtils';
15
import IntlNumberFormControl from '../../I18N/IntlNumberFormControl';
16

17
class NumberField extends React.Component {
18
    static propTypes = {
1✔
19
        operator: PropTypes.string,
20
        fieldName: PropTypes.string,
21
        fieldRowId: PropTypes.number,
22
        attType: PropTypes.string,
23
        fieldValue: PropTypes.oneOfType([
24
            PropTypes.number,
25
            PropTypes.object]),
26
        fieldException: PropTypes.oneOfType([
27
            PropTypes.object,
28
            PropTypes.bool,
29
            PropTypes.string
30
        ]),
31
        onUpdateField: PropTypes.func,
32
        onUpdateExceptionField: PropTypes.func,
33
        isRequired: PropTypes.bool,
34
        label: PropTypes.string,
35
        lowLabel: PropTypes.string,
36
        upLabel: PropTypes.string,
37
        options: PropTypes.shape({
38
            format: PropTypes.string,
39
            min: PropTypes.number,
40
            max: PropTypes.number,
41
            step: PropTypes.number,
42
            precision: PropTypes.number
43
        }),
44
        style: PropTypes.object
45
    };
46

47
    static contextTypes = {
1✔
48
        messages: PropTypes.object
49
    };
50

51
    static defaultProps = {
1✔
52
        style: { borderColor: "#dedede"},
53
        operator: "=",
54
        fieldName: null,
55
        fieldRowId: null,
56
        attType: "number",
57
        fieldValue: null,
58
        fieldException: null,
59
        isRequired: false,
60
        label: null,
61
        lowLabel: null,
62
        upLabel: null,
63
        options: {},
64
        onUpdateField: () => {},
65
        onUpdateExceptionField: () => {}
66
    };
67

68
    renderPicker = (style) => {
7✔
69
        let label = this.props.label ? <label>{this.props.label}</label> : null;
11!
70
        let lowLabel = this.props.lowLabel ? <label>{this.props.lowLabel}</label> : null;
11!
71
        let upLabel = this.props.upLabel ? <label>{this.props.upLabel}</label> : null;
11!
72
        return this.props.operator === "><" ?
11✔
73
            <div className="query-field">
74
                <div className="query-field-value">
75
                    {lowLabel}
76
                    <IntlNumberFormControl
77
                        disabled={this.props.operator === "isNull"}
78
                        style={style ? {input: style} : {}}
1!
79
                        value={this.props.fieldValue && (this.props.fieldValue.lowBound !== null && this.props.fieldValue.lowBound !== undefined) ? this.props.fieldValue.lowBound : null}
4!
80
                        onChange={(value) => {
UNCOV
81
                            !isNaN(value) && value !== "" && this.changeNumber({lowBound: value, upBound: this.props.fieldValue && (this.props.fieldValue.upBound !== null && this.props.fieldValue.upBound !== undefined ) ? this.props.fieldValue.upBound : null});
×
82
                        }}
83
                        inputClassName="rw-input"
84
                        {...this.props.options}
85
                    />
86
                </div>
87
                <div className="query-field-value">
88
                    {upLabel}
89
                    <IntlNumberFormControl
90
                        disabled={this.props.operator === "isNull"}
91
                        style={style ? {input: style} : {}}
1!
92
                        value={this.props.fieldValue && (this.props.fieldValue.upBound !== null && this.props.fieldValue.upBound !== undefined ) ? this.props.fieldValue.upBound : null}
4!
93
                        onChange={(value) => {
UNCOV
94
                            !isNaN(value) && value !== "" && this.changeNumber({upBound: value, lowBound: this.props.fieldValue && (this.props.fieldValue.lowBound !== null && this.props.fieldValue.lowBound !== undefined) ? this.props.fieldValue.lowBound : null});
×
95
                        }}
96
                        inputClassName="rw-input"
97
                        {...this.props.options}
98
                    />
99
                </div>
100
            </div>
101
            :
102
            <div>
103
                {label}
104
                <IntlNumberFormControl
105
                    disabled={this.props.operator === "isNull"}
106
                    style={style ? {input: style} : {}}
10!
107
                    value={this.props.fieldValue && (this.props.fieldValue.lowBound !== null && this.props.fieldValue.lowBound !== undefined) ? this.props.fieldValue.lowBound : this.props.fieldValue}
32!
108
                    onChange={(value) => {
109
                        !isNaN(value) && value !== "" && this.changeNumber(value);
2✔
110
                    }}
111
                    inputClassName="rw-input"
112
                    {...this.props.options}
113
                />
114
            </div>
115
        ;
116
    };
117

118
    render() {
119
        let style = this.props.style;
11✔
120
        if (this.props.fieldException) {
11✔
121
            style = {...this.props.style, borderColor: "#FF0000"};
2✔
122
        }
123
        return (
11✔
124
            <OverlayTrigger placement="bottom"
125
                overlay={this.props.fieldException ?
11✔
126
                    <Tooltip id={this.props.fieldRowId + "_tooltip"}>
127
                        <strong>
128
                            {this.props.fieldException}
129
                        </strong>
130
                    </Tooltip>
131
                    : <noscript/>}>
132
                {this.renderPicker(style)}
133
            </OverlayTrigger>
134
        );
135
    }
136

137
    changeNumber = (value) => {
7✔
138
        if (this.props.operator === "><") {
5✔
139
            if (value.lowBound !== null && value.lowBound !== undefined && ( value.upBound !== null && value.upBound !== undefined) && value.lowBound >= value.upBound) {
2✔
140
                this.props.onUpdateExceptionField(this.props.fieldRowId, getMessageById(this.context.messages, "queryform.attributefilter.numberfield.wrong_range"));
1✔
141
            } else if (this.props.fieldException) {
1!
142
                this.props.onUpdateExceptionField(this.props.fieldRowId, null);
1✔
143
            }
144
        } else {
145
            if (this.props.isRequired && ( value === null || value === undefined)) {
3✔
146
                this.props.onUpdateExceptionField(this.props.fieldRowId, getMessageById(this.context.messages, "queryform.attributefilter.numberfield.isRequired"));
1✔
147
            } else if (this.props.fieldException) {
2✔
148
                this.props.onUpdateExceptionField(this.props.fieldRowId, null);
1✔
149
            }
150
        }
151

152
        this.props.onUpdateField(this.props.fieldRowId, this.props.fieldName, value, this.props.attType);
5✔
153
    };
154
}
155

156
export default NumberField;
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

© 2025 Coveralls, Inc