• 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

87.8
/web/client/components/mapcontrols/search/SearchResultList.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
import React from 'react';
10
import PropTypes from 'prop-types';
11
import { find } from 'lodash';
12

13
import SearchResult from './SearchResult';
14
import I18N from '../../I18N/I18N';
15

16
import { showGFIForService, layerIsVisibleForGFI } from '../../../utils/SearchUtils';
17

18
export default class SearchResultList extends React.Component {
19
    static propTypes = {
1✔
20
        results: PropTypes.array,
21
        layers: PropTypes.array,
22
        searchOptions: PropTypes.object,
23
        mapConfig: PropTypes.object,
24
        fitToMapSize: PropTypes.bool,
25
        containerStyle: PropTypes.object,
26
        sizeAdjustment: PropTypes.object,
27
        onItemClick: PropTypes.func,
28
        addMarker: PropTypes.func,
29
        afterItemClick: PropTypes.func,
30
        showGFI: PropTypes.func,
31
        notFoundMessage: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
32
    };
33

34
    static defaultProps = {
1✔
35
        layers: [],
36
        sizeAdjustment: {
37
            width: 0,
38
            height: 110
39
        },
40
        containerStyle: {
41
            zIndex: 1000
42
        },
43
        onItemClick: () => {},
44
        addMarker: () => {},
45
        afterItemClick: () => {},
46
        showGFI: () => {}
47
    };
48

49
    onItemClick = (item, service) => {
12✔
50
        this.props.onItemClick(item, this.props.mapConfig, service);
1✔
51
    };
52

53
    renderResults = () => {
12✔
54
        return this.props.results.map((item, idx)=> {
10✔
55
            const service = this.findService(item) || {};
109✔
56
            const searchLayerObj = find(this.props.layers, {name: service.options?.typeName});
109✔
57
            const visible = showGFIForService(service);
109✔
58
            const disabled = !layerIsVisibleForGFI(searchLayerObj, service);
109✔
59
            return (<SearchResult
109✔
60
                subTitle={service.subTitle}
61
                idField={service.idField}
62
                displayName={service.displayName}
63
                key={item.osm_id || item.id || "res_" + idx}
218✔
64
                item={item}
65
                onItemClick={() => this.onItemClick(item, service)}
1✔
66
                tools={[{
67
                    id: 'open-gfi',
68
                    keyProp: 'open-gfi',
69
                    visible,
70
                    disabled,
71
                    glyph: 'info-sign',
72
                    tooltipId: visible && disabled ? 'search.layerMustBeVisible' : 'search.showGFI',
220✔
73
                    onClick: e => {
UNCOV
74
                        e.stopPropagation();
×
75
                        this.props.showGFI(item);
×
76
                    }
77
                }]}/>);
78
        });
79
    };
80

81
    render() {
82
        var notFoundMessage = this.props.notFoundMessage;
12✔
83
        if (!notFoundMessage) {
12✔
84
            notFoundMessage = <I18N.Message msgId="noresultfound" />;
3✔
85
        }
86
        let containerStyle = this.props.containerStyle;
12✔
87
        let mapSize = this.props.mapConfig && this.props.mapConfig.size;
12✔
88
        if (this.props.fitToMapSize && mapSize) {
12✔
89
            let maxWidth = mapSize.width - this.props.sizeAdjustment.width;
1✔
90
            let maxHeight = mapSize.height - this.props.sizeAdjustment.height;
1✔
91
            containerStyle = Object.assign({}, this.props.containerStyle, {
1✔
92
                maxWidth,
93
                maxHeight
94
            });
95
        }
96
        if (!this.props.results) {
12✔
97
            return null;
1✔
98
        } else if (this.props.results.length === 0) {
11✔
99
            return <div className="search-result-list" style={Object.assign({padding: "10px", textAlign: "center"}, containerStyle)}>{notFoundMessage}</div>;
1✔
100
        }
101
        return (
10✔
102
            <div className="search-result-list" style={containerStyle}>
103
                {this.renderResults()}
104
            </div>
105
        );
106
    }
107

108
    findService = (item) => {
12✔
109
        const services = this.props.searchOptions && this.props.searchOptions.services;
109✔
110
        if (item.__SERVICE__ !== null) {
109!
111
            if (services && typeof item.__SERVICE__ === "string" ) {
109✔
112
                for (let i = 0; i < services.length; i++) {
2✔
113
                    if (services[i] && services[i].id === item.__SERVICE__) {
2!
114
                        return services[i];
2✔
115
                    }
116
                }
UNCOV
117
                for (let i = 0; i < services.length; i++) {
×
118
                    if (services[i] && services[i].type === item.__SERVICE__) {
×
119
                        return services[i];
×
120
                    }
121
                }
122

123
            } else if (typeof item.__SERVICE__ === "object") {
107✔
124
                return item.__SERVICE__;
7✔
125
            }
126
        }
127
        return null;
100✔
128
    };
129
}
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