• 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

80.77
/web/client/components/data/query/FilterField.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
import React from 'react';
9

10
import PropTypes from 'prop-types';
11
import ComboField from './ComboField';
12

13
import localizedProps from '../../misc/enhancers/localizedProps';
14

15
// support for localized attribute names and placeholder
16
export const AttributeNameField = localizedProps('placeholder')(localizedProps('fieldOptions', 'label', 'object')(ComboField));
1✔
17

18
class FilterField extends React.Component {
19
    static propTypes = {
1✔
20
        dropUp: PropTypes.bool,
21
        attributes: PropTypes.array,
22
        filterField: PropTypes.object,
23
        operatorOptions: PropTypes.array,
24
        onUpdateField: PropTypes.func,
25
        maxFeaturesWPS: PropTypes.number,
26
        toggleMenu: PropTypes.func,
27
        deleteButton: PropTypes.node,
28
        onUpdateExceptionField: PropTypes.func,
29
        onChangeCascadingValue: PropTypes.func
30
    };
31

32
    static contextTypes = {
1✔
33
        messages: PropTypes.object
34
    };
35

36
    static defaultProps = {
1✔
37
        attributes: [],
38
        filterField: null,
39
        operatorOptions: ["=", ">", "<", ">=", "<=", "<>", "><"],
40
        onUpdateField: () => {},
41
        toggleMenu: () => {},
42
        onUpdateExceptionField: () => {},
43
        onChangeCascadingValue: () => {}
44
    };
45

46
    renderOperatorField = () => {
13✔
47
        return (
9✔
48
            <ComboField
49
                dropUp={this.props.dropUp}
50
                fieldOptions= {this.props.operatorOptions}
51
                fieldName="operator"
52
                fieldRowId={this.props.filterField.rowId}
53
                fieldValue={this.props.filterField.operator}
54
                onUpdateField={this.updateFieldElement}/>
55
        );
56
    };
57

58
    renderValueField = (selectedAttribute) => {
13✔
59
        const valueElement = React.cloneElement(
9✔
60
            React.Children.toArray(this.props.children).filter((node) => node.props.attType === selectedAttribute.type)[0],
36✔
61
            Object.assign({
62
                fieldName: "value",
63
                fieldRowId: this.props.filterField.rowId,
64
                fieldValue: this.props.filterField.value,
65
                fieldException: this.props.filterField.exception,
66
                onUpdateField: this.updateFieldElement,
67
                toggleMenu: this.props.toggleMenu,
68
                maxFeaturesWPS: this.props.maxFeaturesWPS,
69
                onUpdateExceptionField: this.updateExceptionFieldElement
70
            }, selectedAttribute.fieldOptions || {})
17✔
71
        );
72

73
        return (
9✔
74
            valueElement
75
        );
76
    };
77

78
    render() {
79
        let selectedAttribute = this.props.attributes.filter((attribute) => attribute.attribute === this.props.filterField.attribute)[0];
16✔
80

81
        return (
13✔
82
            <div className="filter-field-row">
83
                <div className="filter-field-attribute">
84
                    <AttributeNameField
85
                        dropUp={this.props.dropUp}
86
                        valueField={'attribute'}
87
                        textField={'label'}
88
                        fieldOptions={this.props.attributes}
89
                        placeholder="queryform.attributefilter.combo_placeholder"
90
                        fieldValue={this.props.filterField.attribute}
91
                        attType={selectedAttribute && selectedAttribute.type}
22✔
92
                        fieldName="attribute"
93
                        fieldRowId={this.props.filterField.rowId}
94
                        onUpdateField={this.updateFieldElement}
95
                        comboFilter={"contains"}/>
96
                </div>
97
                <div className="filter-field-operator">{selectedAttribute ? this.renderOperatorField() : null}</div>
13✔
98
                <div className="filter-field-value">{selectedAttribute && this.props.filterField.operator ? this.renderValueField(selectedAttribute) : null}</div>
35✔
99
                {this.props.deleteButton ? <div className="filter-field-tools">{this.props.deleteButton}</div> : null}
13✔
100
            </div>
101
        );
102
    }
103

104
    updateExceptionFieldElement = (rowId, message) => {
13✔
105
        this.props.onUpdateExceptionField(rowId, message);
2✔
106
    };
107

108
    updateFieldElement = (rowId, name, value, type, fieldOptions) => {
13✔
109
        let selectedAttribute;
110
        if (name === "attribute") {
4!
UNCOV
111
            selectedAttribute = this.props.attributes.filter((attribute) => attribute.attribute === value)[0];
×
112
            const fieldType = selectedAttribute && selectedAttribute.type || type;
×
113
            this.props.onUpdateField(rowId, name, value, fieldType, fieldOptions);
×
114

UNCOV
115
            if (fieldType === "array") {
×
116
                this.props.onUpdateField(rowId, "operator", "contains", fieldType, fieldOptions);
×
117
            }
118
        } else {
119
            this.props.onUpdateField(rowId, name, value, type === 'boolean' ? 'string' : type, fieldOptions);
4✔
120

121
        }
122

123
        if (name === "value") {
4✔
124
            // For cascading: filter the attributes that depends on
125
            let dependsOnAttributes = this.props.attributes.filter((attribute) => attribute.dependson && attribute.dependson.field === this.props.filterField.attribute);
4✔
126
            if (dependsOnAttributes.length > 0) {
3✔
127
                // Perhaps There is some filterFields that need to reset their value
128
                this.props.onChangeCascadingValue(dependsOnAttributes);
2✔
129
            }
130
        }
131
    };
132
}
133

134
export default FilterField;
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