• 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

74.42
/web/client/components/data/query/AutocompleteFieldHOC.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

9

10
import PropTypes from 'prop-types';
11

12
import React from 'react';
13
import AutocompleteListItem from './AutocompleteListItem';
14
import PagedCombobox from '../../misc/combobox/PagedCombobox';
15
import { isLikeOrIlike } from '../../../utils/FilterUtils';
16
import HTML from '../../../components/I18N/HTML';
17

18
class AutocompleteFieldHOC extends React.Component {
19
    static propTypes = {
1✔
20
        dropUp: PropTypes.bool,
21
        disabled: PropTypes.bool,
22
        filterField: PropTypes.object,
23
        label: PropTypes.string,
24
        itemComponent: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
25
        maxFeaturesWPS: PropTypes.number,
26
        onUpdateField: PropTypes.func,
27
        pagination: PropTypes.object,
28
        textField: PropTypes.string,
29
        tooltip: PropTypes.object,
30
        toggleMenu: PropTypes.func,
31
        valueField: PropTypes.string
32
    };
33

34
    static contextTypes = {
1✔
35
        messages: PropTypes.object
36
    };
37

38
    static defaultProps = {
1✔
39
        label: null,
40
        onUpdateField: () => {},
41
        pagination: {
42
            paginated: true,
43
            nextPageIcon: "chevron-right",
44
            prevPageIcon: "chevron-left"
45
        },
46
        itemComponent: AutocompleteListItem,
47
        toggleMenu: () => {},
48
        filterField: {
49
            fieldOptions: {}
50
        }
51
    };
52

53
    getOptions = () => {
4✔
54
        return this.props.filterField &&
7✔
55
        this.props.filterField.options &&
56
        this.props.filterField.options[this.props.filterField.attribute] &&
57
        this.props.filterField.options[this.props.filterField.attribute].map(o => {
58
            return { value: o, label: o };
16✔
59
        });
60
    };
61

62
    getPagination = (options) => {
4✔
63
        if (!this.props.filterField.options) {
4✔
64
            return {};
1✔
65
        }
66

67
        const numberOfPages = Math.ceil(this.props.filterField.fieldOptions.valuesCount / this.props.maxFeaturesWPS);
3✔
68
        const firstPage = this.props.filterField.fieldOptions.currentPage === 1 || !this.props.filterField.fieldOptions.currentPage;
3✔
69
        const lastPage = this.props.filterField.fieldOptions.currentPage === numberOfPages || !this.props.filterField.fieldOptions.currentPage;
3✔
70
        return Object.assign({}, this.props.pagination, {
3✔
71
            paginated: options.length !== 0 && !(firstPage && options.length === 1),
12✔
72
            firstPage,
73
            lastPage,
UNCOV
74
            loadPrevPage: () => this.props.onUpdateField(this.props.filterField.rowId, "value", this.props.filterField.value, "string", {currentPage: this.props.filterField.fieldOptions.currentPage - 1, delayDebounce: 0}),
×
75
            loadNextPage: () => this.props.onUpdateField(this.props.filterField.rowId, "value", this.props.filterField.value, "string", {currentPage: this.props.filterField.fieldOptions.currentPage + 1, delayDebounce: 0})
×
76
        });
77
    };
78

79
    getTooltip = () => {
4✔
80
        return Object.assign({}, this.props.tooltip, {
4✔
81
            enabled: isLikeOrIlike(this.props.filterField.operator),
82
            id: "autocompleteField-tooltip" + this.props.filterField && this.props.filterField.rowId,
8✔
83
            message: (<HTML msgId="queryform.attributefilter.tooltipTextField"/>),
84
            overlayTriggerKey: "autocompleteField-overlay" + this.props.filterField && this.props.filterField.rowId,
8✔
85
            placement: "top"
86
        });
87
    };
88
    renderField = () => {
4✔
89
        let selectedValue;
90
        // CHECK this.props.filterField.value AS ""
91
        if (this.props.filterField && this.props.filterField.value && this.props.filterField.value !== "*") {
4✔
92
            selectedValue = {
1✔
93
                'value': this.props.filterField.value,
94
                'label': this.props.filterField.value
95
            };
96
        }
97
        let options = this.getOptions() ? this.getOptions().slice(0) : [];
4✔
98

99
        return (<PagedCombobox
4✔
100
            dropUp={this.props.dropUp}
101
            busy={this.props.filterField.loading}
102
            data={this.props.filterField.loading ? [] : options}
4!
103
            disabled={this.props.filterField.operator === "isNull"}
104
            itemComponent={this.props.itemComponent}
105
            open={this.props.filterField.openAutocompleteMenu}
UNCOV
106
            onChange={(value) => this.handleChange(value)}
×
107
            onFocus={() => this.handleFocus(options)}
2✔
UNCOV
108
            onSelect={() => this.handleSelect()}
×
109
            onToggle={() => this.handleToggle(options)}
2✔
110
            pagination={this.getPagination(options)}
111
            selectedValue={selectedValue && selectedValue.value}
5✔
112
            tooltip={this.getTooltip()}
113
        />);
114
    }
115
    render() {
116
        let label = this.props.label ? (<label>{this.props.label}</label>) : (<span/>);
4!
117
        return (
4✔
118
            <div className="autocompleteField">
119
                {label}
120
                {this.renderField()}
121
            </div>);
122
    }
123

124
    // called before onChange
125
    handleSelect = () => {
4✔
UNCOV
126
        this.selected = true;
×
127
    };
128

129
    handleChange = (input) => {
4✔
UNCOV
130
        if (this.selected) {
×
131
            this.selected = false;
×
132
            if (input && input.value !== "") {
×
133
                this.props.onUpdateField(this.props.filterField.rowId, "value", input.value, "string", {currentPage: 1, selected: "selected", delayDebounce: 0});
×
134
            }
135
        } else {
UNCOV
136
            this.props.onUpdateField(this.props.filterField.rowId, "value", typeof input === "string" ? input : input.value, "string", {currentPage: 1, delayDebounce: 1000});
×
137
        }
138
    };
139

140
    // called before onToggle
141
    handleFocus = (options) => {
4✔
142
        this.loadWithoutfilter(options);
2✔
143
    };
144

145
    handleToggle = () => {
4✔
146
        this.props.toggleMenu(this.props.filterField.rowId, !this.props.filterField.openAutocompleteMenu);
2✔
147
    };
148

149
    loadWithoutfilter = (options) => {
4✔
150
        if (options.length === 0 && !this.props.filterField.value) {
2!
UNCOV
151
            this.props.onUpdateField(this.props.filterField.rowId, "value", "", "string", {currentPage: 1, delayDebounce: 0});
×
152
        }
153
    };
154
}
155

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