modified checks for Format.WFST should use not equal to undefined instead of truthy to deal properly with initial null values, r=ahocevar (closes #3436)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12188 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -183,12 +183,12 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
* transaction:
|
||||
* - *modified* is not set at all: The geometry and all attributes will be
|
||||
* included.
|
||||
* - *modified.geometry* is truthy: The geometry will be
|
||||
* - *modified.geometry* is set (null or a geometry): The geometry will be
|
||||
* included. If *modified.attributes* is not set, all attributes will
|
||||
* be included.
|
||||
* - *modified.attributes* is set: Only the attributes with a truthy value
|
||||
* in *modified.attributes* will be included. If *modified.geometry*
|
||||
* is not set, the geometry will not be included.
|
||||
* - *modified.attributes* is set: Only the attributes set (i.e. to null or
|
||||
* a value) in *modified.attributes* will be included.
|
||||
* If *modified.geometry* is not set, the geometry will not be included.
|
||||
*
|
||||
* Valid options include:
|
||||
* - *multi* {Boolean} If set to true, geometries will be casted to
|
||||
@@ -323,7 +323,7 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
// add in geometry
|
||||
var modified = feature.modified;
|
||||
if (this.geometryName !== null && (!modified || modified.geometry)) {
|
||||
if (this.geometryName !== null && (!modified || modified.geometry !== undefined)) {
|
||||
this.srsName = this.getSrsName(feature);
|
||||
this.writeNode(
|
||||
"Property", {name: this.geometryName, value: feature.geometry}, node
|
||||
@@ -334,7 +334,7 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
for(var key in feature.attributes) {
|
||||
if(feature.attributes[key] !== undefined &&
|
||||
(!modified || !modified.attributes ||
|
||||
(modified.attributes && modified.attributes[key]))) {
|
||||
(modified.attributes && modified.attributes[key] !== undefined))) {
|
||||
this.writeNode(
|
||||
"Property", {name: key, value: feature.attributes[key]}, node
|
||||
);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
deleteFeature.state = OpenLayers.State.DELETE;
|
||||
deleteFeature.fid = "fid.37";
|
||||
|
||||
t.plan(7);
|
||||
t.plan(8);
|
||||
var snippets = {
|
||||
"GetFeature": {handle: "handle_g", maxFeatures: 1, outputFormat: 'json'},
|
||||
"Transaction": {handle: "handle_t"},
|
||||
@@ -74,6 +74,14 @@
|
||||
var expected = readXML("UpdateModifiedNoGeometry");
|
||||
var got = format.writers["wfs"]["Update"].apply(format, [{feature: updateFeature}]);
|
||||
t.xml_eq(got, expected, "Update request for feature with no modified geometry but modified attributes created correctly");
|
||||
|
||||
// test for a feature that originally had a null geometry and a null value for the attribute
|
||||
updateFeature.modified = {attributes: {foo: null, nul: "nul"}, geometry: null};
|
||||
updateFeature.attributes.foo = "bar";
|
||||
updateFeature.geometry = new OpenLayers.Geometry.Point(2,3);
|
||||
var expected = readXML("UpdateModified");
|
||||
var got = format.writers["wfs"]["Update"].apply(format, [{feature: updateFeature}]);
|
||||
t.xml_eq(got, expected, "Update request for feature with modified geometry created correctly even if original geometry was null");
|
||||
}
|
||||
|
||||
function test_writeNative(t) {
|
||||
|
||||
Reference in New Issue
Block a user