diff --git a/web/client/components/data/featuregrid/FeatureGrid.jsx b/web/client/components/data/featuregrid/FeatureGrid.jsx index cb5e5d9652..a2c683d707 100644 --- a/web/client/components/data/featuregrid/FeatureGrid.jsx +++ b/web/client/components/data/featuregrid/FeatureGrid.jsx @@ -70,7 +70,7 @@ class FeatureGrid extends React.PureComponent { this.props.changes[id].hasOwnProperty(key); }, isProperty: (k) => k === "geometry" || isProperty(k, this.props.describeFeatureType), - isValid: (val, key) => isValidValueForPropertyName(val, key, this.props.describeFeatureType) + isValid: (val, key) => this.props.describeFeatureType ? isValidValueForPropertyName(val, key, this.props.describeFeatureType) : true }; } render() { diff --git a/web/client/epics/featuregrid.js b/web/client/epics/featuregrid.js index ed6fe20e86..9abea8b72d 100644 --- a/web/client/epics/featuregrid.js +++ b/web/client/epics/featuregrid.js @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. */ const Rx = require('rxjs'); -const {get, head, isEmpty} = require('lodash'); +const {get, head, isEmpty, find} = require('lodash'); const { LOCATION_CHANGE } = require('react-router-redux'); const axios = require('../libs/ajax'); const {fidFilter} = require('../utils/ogc/Filter/filter'); @@ -69,6 +69,13 @@ const setupDrawSupport = (state, original) => { if (changes[feature.id] && (changes[feature.id].geometry || changes[feature.id].geometry === null)) { feature.geometry = changes[feature.id].geometry; } + if (feature._new && !feature.geometry) { + const stateNewFeature = find(newFeaturesSelector(state), {id: feature.id}); + if (stateNewFeature && stateNewFeature.geometry ) { + feature.geometry = stateNewFeature.geometry; + } + + } if (original) { feature.geometry = getFeatureById(state, feature.id) ? getFeatureById(state, feature.id).geometry : null; } diff --git a/web/client/utils/FeatureGridUtils.js b/web/client/utils/FeatureGridUtils.js index 59a6219310..762eb3bedd 100644 --- a/web/client/utils/FeatureGridUtils.js +++ b/web/client/utils/FeatureGridUtils.js @@ -1,5 +1,7 @@ +const get = require('lodash'); + const {getFeatureTypeProperties, isGeometryType, isValid, isValidValueForPropertyName, findGeometryProperty, getPropertyDesciptor} = require('./ogc/WFS/base'); -const getGeometryName = (describe) => findGeometryProperty(describe).name; +const getGeometryName = (describe) => get(findGeometryProperty(describe), "name"); const getPropertyName = (name, describe) => name === "geometry" ? getGeometryName(describe) : name; const getRow = (i, rows) => rows[i]; diff --git a/web/client/utils/ogc/WFS/base.js b/web/client/utils/ogc/WFS/base.js index 94851427f8..47e095ca80 100644 --- a/web/client/utils/ogc/WFS/base.js +++ b/web/client/utils/ogc/WFS/base.js @@ -47,7 +47,7 @@ const findGeometryProperty = (describeFeatureType) => head((getFeatureTypeProper */ const getPropertyDesciptor = (propName, describeFeatureType) => head( - getFeatureTypeProperties(describeFeatureType).filter(d => d.name === propName) + (getFeatureTypeProperties(describeFeatureType) || []).filter(d => d.name === propName) ); /** * @name schemaLocation @@ -57,7 +57,11 @@ const getPropertyDesciptor = (propName, describeFeatureType) => */ const schemaLocation = (d) => d.targetNamespace; const isGeometryType = (pd) => pd.type.indexOf("gml:") === 0; -const isValidValue = (v, pd) => pd.nillable || (v !== undefined && v !== null); // TODO validate type +const isValidValue = (v, pd) => + pd === undefined + || pd === null + || pd && pd.nillable === true + || pd && pd.nillable === false && v !== undefined && v !== null; // TODO validate type const isValidProperty = ({geom, properties} = {}, pd) => isValidValue(isGeometryType(pd) ? geom : properties[pd.name], pd); /** * Base utilities for WFS.