fulcrum-core
Advanced tools
Comparing version 1.3.4 to 1.3.5
@@ -26,2 +26,3 @@ export default class Record extends Feature { | ||
get hasCoordinate(): boolean; | ||
get hasLocation(): boolean; | ||
set geometry(arg: any); | ||
@@ -28,0 +29,0 @@ get geometry(): any; |
@@ -68,4 +68,7 @@ "use strict"; | ||
get hasCoordinate() { | ||
return (this._latitude != null && this._longitude != null) || this.geometry != null; | ||
return this._latitude != null && this._longitude != null; | ||
} | ||
get hasLocation() { | ||
return this.hasCoordinate || this.geometry != null; | ||
} | ||
get geometry() { | ||
@@ -80,6 +83,2 @@ return this._geometry; | ||
} | ||
else { | ||
this._latitude = null; | ||
this._longitude = null; | ||
} | ||
} | ||
@@ -86,0 +85,0 @@ get changeset() { |
@@ -42,3 +42,3 @@ "use strict"; | ||
if (record.form.isGeometryRequired) { | ||
if (!record.hasCoordinate) { | ||
if (!record.hasLocation) { | ||
errors.push(new geometry_required_validation_error_1.default()); | ||
@@ -57,3 +57,3 @@ } | ||
if (repeatableItem.element.isGeometryRequired) { | ||
if (!repeatableItem.hasCoordinate) { | ||
if (!repeatableItem.hasLocation) { | ||
errors.push(new geometry_required_validation_error_1.default()); | ||
@@ -60,0 +60,0 @@ } |
@@ -25,2 +25,3 @@ export default class RepeatableItemValue extends Feature { | ||
get hasCoordinate(): boolean; | ||
get hasLocation(): boolean; | ||
updateFromAPIAttributes(attrs: any): void; | ||
@@ -27,0 +28,0 @@ _id: any; |
@@ -69,10 +69,9 @@ "use strict"; | ||
} | ||
else { | ||
this._latitude = null; | ||
this._longitude = null; | ||
} | ||
} | ||
get hasCoordinate() { | ||
return (this._latitude != null && this._longitude != null) || this.geometry != null; | ||
return this._latitude != null && this._longitude != null; | ||
} | ||
get hasLocation() { | ||
return this.hasCoordinate || this.geometry != null; | ||
} | ||
updateFromAPIAttributes(attrs) { | ||
@@ -79,0 +78,0 @@ var _a; |
{ | ||
"name": "fulcrum-core", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "Fulcrum Core", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/fulcrumapp/fulcrum-core", |
@@ -83,5 +83,9 @@ import Feature from './feature'; | ||
get hasCoordinate() { | ||
return (this._latitude != null && this._longitude != null) || this.geometry != null; | ||
return this._latitude != null && this._longitude != null; | ||
} | ||
get hasLocation() { | ||
return this.hasCoordinate || this.geometry != null; | ||
} | ||
get geometry() { | ||
@@ -97,5 +101,2 @@ return this._geometry; | ||
this._longitude = geometry.coordinates[0]; | ||
} else { | ||
this._latitude = null; | ||
this._longitude = null; | ||
} | ||
@@ -102,0 +103,0 @@ } |
@@ -41,3 +41,3 @@ import RepeatableItemValue from '../values/repeatable-item-value'; | ||
if (record.form.isGeometryRequired) { | ||
if (!record.hasCoordinate) { | ||
if (!record.hasLocation) { | ||
errors.push(new GeometryRequiredValidationError()); | ||
@@ -62,3 +62,3 @@ } | ||
if (repeatableItem.element.isGeometryRequired) { | ||
if (!repeatableItem.hasCoordinate) { | ||
if (!repeatableItem.hasLocation) { | ||
errors.push(new GeometryRequiredValidationError()); | ||
@@ -65,0 +65,0 @@ } |
@@ -83,5 +83,2 @@ import Feature from '../feature'; | ||
this._longitude = geometry.coordinates[0]; | ||
} else { | ||
this._latitude = null; | ||
this._longitude = null; | ||
} | ||
@@ -91,5 +88,9 @@ } | ||
get hasCoordinate() { | ||
return (this._latitude != null && this._longitude != null) || this.geometry != null; | ||
return this._latitude != null && this._longitude != null; | ||
} | ||
get hasLocation() { | ||
return this.hasCoordinate || this.geometry != null; | ||
} | ||
updateFromAPIAttributes(attrs) { | ||
@@ -96,0 +97,0 @@ this._id = attrs.id; |
@@ -65,2 +65,3 @@ import fs from 'fs'; | ||
record.hasCoordinate.should.eql(true); | ||
record.hasLocation.should.eql(true); | ||
record.geometryAsGeoJSON.should.eql({ | ||
@@ -80,4 +81,7 @@ type: 'Point', | ||
}; | ||
record.latitude = null; | ||
record.longitude = null; | ||
record.hasCoordinate.should.eql(true); | ||
record.hasCoordinate.should.eql(false); | ||
record.hasLocation.should.eql(true); | ||
record.geometryAsGeoJSON.should.eql({ | ||
@@ -98,2 +102,3 @@ type: "LineString", | ||
record.hasCoordinate.should.eql(false); | ||
record.hasLocation.should.eql(false); | ||
shouldBeNull(record.geometryAsGeoJSON); | ||
@@ -110,2 +115,3 @@ }); | ||
child.hasCoordinate.should.eql(true); | ||
child.hasLocation.should.eql(true); | ||
child.geometryAsGeoJSON.should.eql({ | ||
@@ -127,4 +133,7 @@ type: 'Point', | ||
}; | ||
child.latitude = null; | ||
child.longitude = null; | ||
child.hasCoordinate.should.eql(true); | ||
child.hasCoordinate.should.eql(false); | ||
child.hasLocation.should.eql(true); | ||
child.geometryAsGeoJSON.should.eql({ | ||
@@ -139,15 +148,4 @@ type: "LineString", | ||
it('update the latitude and longitude when updating the geometry', () => { | ||
it('update the latitude and longitude when updating Point geometry', () => { | ||
record.geometry = { | ||
type: "LineString", | ||
coordinates: [ | ||
[-82.47576689405734, 27.977757676187323], | ||
[-82.47699950483403, 27.974250052144896], | ||
] | ||
}; | ||
shouldBeNull(record.latitude); | ||
shouldBeNull(record.longitude); | ||
record.geometry = { | ||
type: "Point", | ||
@@ -165,13 +163,2 @@ coordinates: [-82.47576689405734, 27.977757676187323] | ||
child.geometry = { | ||
type: "LineString", | ||
coordinates: [ | ||
[-82.47576689405734, 27.977757676187323], | ||
[-82.47699950483403, 27.974250052144896], | ||
] | ||
}; | ||
shouldBeNull(child.latitude); | ||
shouldBeNull(child.longitude); | ||
child.geometry = { | ||
type: "Point", | ||
@@ -192,2 +179,3 @@ coordinates: [-82.47576689405734, 27.977757676187323] | ||
child.hasCoordinate.should.eql(false); | ||
child.hasLocation.should.eql(false); | ||
shouldBeNull(child.geometryAsGeoJSON); | ||
@@ -256,2 +244,4 @@ }); | ||
record.geometry = null; | ||
record.latitude = null; | ||
record.longitude = null; | ||
@@ -265,6 +255,5 @@ const [ error ] = FeatureValidator.validateRecord(record, record.formValues); | ||
it('does not return an error when there is a latitude and longitude', () => { | ||
record.geometry = { | ||
type: "Point", | ||
coordinates: [1, 2] | ||
}; | ||
record.latitude = 27.977757676187323; | ||
record.longitude = -82.47576689405734; | ||
record.geometry = null; | ||
@@ -284,2 +273,4 @@ const errors = FeatureValidator.validateRecord(record, record.formValues); | ||
}; | ||
record.longitude = null; | ||
record.latitude = null; | ||
@@ -295,2 +286,4 @@ const errors = FeatureValidator.validateRecord(record, record.formValues); | ||
child.geometry = null; | ||
child.latitude = null; | ||
child.longitude = null; | ||
@@ -306,6 +299,5 @@ const [ error ] = FeatureValidator.validateFeature(child, record, child.formValues); | ||
child.geometry = { | ||
type: "Point", | ||
coordinates: [1, 2] | ||
}; | ||
child.latitude = 27.977757676187323; | ||
child.longitude = -82.47576689405734; | ||
child.geometry = null; | ||
@@ -327,2 +319,4 @@ const errors = FeatureValidator.validateFeature(child, record, child.formValues); | ||
}; | ||
child.latitude = null; | ||
child.longitude = null; | ||
@@ -329,0 +323,0 @@ const errors = FeatureValidator.validateFeature(child, record, child.formValues); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1854633
507
21339