• 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

84.62
/web/client/reducers/search.js
1
/*
2
 * Copyright 2015, 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 {
10
    TEXT_SEARCH_ITEM_SELECTED,
11
    TEXT_SEARCH_RESULTS_LOADED,
12
    TEXT_SEARCH_RESULTS_PURGE,
13
    TEXT_SEARCH_RESET,
14
    TEXT_SEARCH_ADD_MARKER,
15
    TEXT_SEARCH_TEXT_CHANGE,
16
    TEXT_SEARCH_LOADING,
17
    TEXT_SEARCH_ERROR,
18
    TEXT_SEARCH_NESTED_SERVICES_SELECTED,
19
    TEXT_SEARCH_CANCEL_ITEM,
20
    TEXT_SEARCH_SET_HIGHLIGHTED_FEATURE,
21
    UPDATE_RESULTS_STYLE,
22
    CHANGE_SEARCH_TOOL,
23
    CHANGE_FORMAT,
24
    CHANGE_COORD,
25
    HIDE_MARKER
26
} from '../actions/search';
27

28
import { RESET_CONTROLS } from '../actions/controls';
29
import { generateTemplateString } from '../utils/TemplateUtils';
30
/**
31
 * Manages the state of the map search with it's results
32
 * The properties represent the shape of the state
33
 * @prop {boolan} loading loading state
34
 * @prop {object} error the last error, if any
35
 * @prop {string} searchText the search text
36
 * @prop {array}  results the results
37
 * @prop {object} markerPosition  the markerPosition
38
 * @prop {object} selectedServicess tores the services currently selected by the user
39
 * @prop {object} selectedItems the selected items
40
 *
41
 * @example
42
 *{
43
 *  search: {
44
 *    searchText: 'test',
45
 *    error: null,
46
 *    loading: false,
47
 *    results: [
48
 *      {
49
 *        properties: {
50
 *          place_id: '130504451',
51
 *          licence: 'Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright',
52
 *          osm_type: 'way',
53
 *          osm_id: '294145572',
54
 *          lat: '6.82439805',
55
 *          lon: '81.0004103985287',
56
 *          display_name: 'test, Bandarawela, Badulla District, Uva, Sri Lanka',
57
 *          'class': 'landuse',
58
 *          type: 'forest',
59
 *          importance: 0.31,
60
 *        },
61
 *        id: '294145572',
62
 *        type: 'Feature',
63
 *        bbox: [
64
 *          81.0001165,
65
 *          6.8238999,
66
 *          81.0008042,
67
 *          6.8248084
68
 *        ],
69
 *        geometry: {
70
 *          type: 'Polygon',
71
 *          coordinates: [
72
 *              [[ 81.0001165, 6.8242576],
73
 *              [81.0001892, 6.8245385],
74
 *              [81.0003879, 6.8248084],
75
 *              [81.0008042, 6.8241984],
76
 *              [81.0003606, 6.8238999],
77
 *              [81.0001165, 6.8242576]
78
 *            ]]
79
 *        },
80
 *        __SERVICE__: {
81
 *          type: 'nominatim'
82
 *        },
83
 *        __PRIORITY__: 0
84
 *      },
85
 *    ]
86
 *  }
87
 *}
88
 * @memberof reducers
89
 */
90
function search(state = null, action) {
2✔
91
    switch (action.type) {
26!
92
    case TEXT_SEARCH_ITEM_SELECTED: {
93
        const { type: serviceType } = action.service || {};
3✔
94
        const displayName = serviceType === 'nominatim' ? action.item.properties?.display_name : serviceType === 'wfs' ?
3✔
95
            generateTemplateString(action.service?.displayName || '')(action.item) : state.searchText;
1!
96
        return {...state, searchText: displayName || state.searchText || '' };
3!
97
    }
98
    case TEXT_SEARCH_LOADING: {
99
        return Object.assign({}, state, {loading: action.loading});
2✔
100
    }
101
    case TEXT_SEARCH_ERROR: {
102
        return Object.assign({}, state, {error: action.error});
1✔
103
    }
104
    case TEXT_SEARCH_TEXT_CHANGE:
UNCOV
105
        return Object.assign({}, state, { searchText: action.searchText, error: null });
×
106
    case TEXT_SEARCH_RESULTS_LOADED:
107
        let results = action.results;
3✔
108
        if (action.append === true && state && state.results) {
3✔
109
            results = [...state.results, ...action.results];
1✔
110
        }
111
        return Object.assign({}, state, { results: results, error: null });
3✔
112
    case TEXT_SEARCH_RESULTS_PURGE:
113
        return Object.assign({}, state, { results: null, error: null});
1✔
114
    case TEXT_SEARCH_ADD_MARKER:
UNCOV
115
        const latlng = action.markerPosition.latlng ? {latlng: action.markerPosition.latlng, lat: action.markerPosition.latlng.lat,  lng: action.markerPosition.latlng.lng} : action.markerPosition;
×
116
        return Object.assign({}, state, { markerPosition: latlng, markerLabel: action.markerLabel });
×
117
    case TEXT_SEARCH_SET_HIGHLIGHTED_FEATURE:
UNCOV
118
        return Object.assign({}, state, {highlightedFeature: action.highlightedFeature});
×
119
    case TEXT_SEARCH_RESET:
120
        return { style: state.style || {} };
2✔
121
    case RESET_CONTROLS:
122
        return null;
1✔
123
    case TEXT_SEARCH_NESTED_SERVICES_SELECTED:
124
        return Object.assign({}, state, {
2✔
125
            selectedServices: action.services,
126
            searchText: action.searchText,
127
            selectedItems: (state.selectedItems || []).concat(action.items)
3✔
128
        });
129
    case TEXT_SEARCH_CANCEL_ITEM:
130
        return state ? Object.assign({}, {
2✔
131
            selectedItems: state.selectedItems && state.selectedItems.filter(item => item !== action.item),
2✔
132
            searchText: state.searchText === "" && action.item && action.item.text ? action.item.text.substring(0, action.item.text.length) : state.searchText
4!
133
        }) : state;
134
    case UPDATE_RESULTS_STYLE:
135
        return Object.assign({}, state, {style: action.style});
1✔
136
    case CHANGE_SEARCH_TOOL:
137
        return {...state, activeSearchTool: action.activeSearchTool};
1✔
138
    case CHANGE_FORMAT:
139
        return {...state, format: action.format};
1✔
140
    case CHANGE_COORD:
141
        return {...state, coordinate: {...state.coordinate, [action.coord]: action.val}};
1✔
142
    case HIDE_MARKER:
143
        return Object.assign({}, state, {markerPosition: state?.markerPosition?.latlng ? {} : state?.markerPosition});
1!
144
    default:
145
        return state;
4✔
146
    }
147
}
148

149
export default search;
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