• 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

81.25
/web/client/components/data/featuregrid/FeatureGrid.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 PropTypes from 'prop-types';
10
import React from 'react';
11

12
import { isProperty, isValidValueForPropertyName } from '../../../utils/FeatureGridUtils';
13
import AdaptiveGrid from '../../misc/AdaptiveGrid';
14
import featuresToGrid from './enhancers/editor';
15
import rowRenderer from './renderers/RowRenderer';
16

17
/**
18
 * A component that gets the describeFeatureType and the features to display
19
 * attributes
20
 * @class
21
 * @name FeatureGrid
22
 * @memberof components.data.featuregrid
23
 * @prop {geojson[]} features array of geojson features
24
 * @prop {object} describeFeatureType the describeFeatureType in json format
25
 * @prop {Component} gridComponent the grid component, if different from AdaptiveGrid
26
 * @prop {object} gridOptions to pass to the grid
27
 * @prop {object} gridEvents an object with events for the grid. Note: onRowsSelected, onRowsDeselected and onRowsToggled will be associated automatically from this object
28
 * to the rowSelection tool. If checkbox are enabled, onRowsSelected and onRowsDeselected will be triggered. If showCheckbox is false, onRowsToggled will be triggered.
29
 * @prop {object[]} tools. a list of tools. the format is the react-data-grid column format but with the following differences:
30
 * - The events are automatically binded to call the related callback with the feature as first parameter, second argument is the same, no original event is passed. describeFeatureType as third
31
 */
32
class FeatureGrid extends React.PureComponent {
33
    static propTypes = {
1✔
34
        autocompleteEnabled: PropTypes.bool,
35
        editingAllowedRoles: PropTypes.array,
36
        gridOpts: PropTypes.object,
37
        changes: PropTypes.object,
38
        selectBy: PropTypes.object,
39
        customEditorsOptions: PropTypes.object,
40
        features: PropTypes.array,
41
        showDragHandle: PropTypes.bool,
42
        gridComponent: PropTypes.func,
43
        describeFeatureType: PropTypes.object,
44
        columnSettings: PropTypes.object,
45
        gridOptions: PropTypes.object,
46
        actionOpts: PropTypes.object,
47
        tools: PropTypes.array,
48
        gridEvents: PropTypes.object,
49
        virtualScroll: PropTypes.bool,
50
        maxStoredPages: PropTypes.number
51
    };
52
    static childContextTypes = {
1✔
53
        isModified: PropTypes.func,
54
        isValid: PropTypes.func,
55
        isProperty: PropTypes.func
56
    };
57
    static defaultProps = {
1✔
58
        editingAllowedRoles: ["ADMIN"],
59
        autocompleteEnabled: false,
60
        gridComponent: AdaptiveGrid,
61
        changes: {},
62
        gridEvents: {},
63
        gridOpts: {},
64
        describeFeatureType: {},
65
        columnSettings: {},
66
        features: [],
67
        tools: [],
68
        showDragHandle: false,
69
        virtualScroll: false,
70
        maxStoredPages: 5
71
    };
72
    constructor(props) {
73
        super(props);
18✔
74
    }
75

76
    getChildContext() {
77
        return {
19✔
78
            isModified: (id, key) => {
79
                return this.props.changes.hasOwnProperty(id) &&
80!
80
                    this.props.changes[id].hasOwnProperty(key);
81
            },
82
            isProperty: (k) => k === "geometry" || isProperty(k, this.props.describeFeatureType),
80✔
83
            isValid: (val, key, rowId) => {
84
                const { errors = [], changed } = (this.props?.validationErrors?.[rowId] || {});
73✔
85
                // Extract field name from instancePath or dataPath (e.g., "/fid" -> "fid")
86
                const error = errors.find((err) => {
73✔
UNCOV
87
                    const path = err.instancePath || err.dataPath || '';
×
UNCOV
88
                    return path.replace(/^[./]/, '') === key;
×
89
                });
90
                if (error) {
73!
UNCOV
91
                    return { valid: false, message: error?.message, changed };
×
92
                }
93
                return { valid: this.props.describeFeatureType ? isValidValueForPropertyName(val, key, this.props.describeFeatureType) :  false };
73!
94
            }
95
        };
96
    }
97
    render() {
98
        const Grid = this.props.gridComponent;
19✔
99
        return (<Grid
19✔
100
            rowRenderer={rowRenderer}
101
            {...this.props}
102
        />);
103
    }
104
}
105
export default featuresToGrid(FeatureGrid);
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