diff --git a/CHANGELOG.md b/CHANGELOG.md index 15cdaf765..099d2a90a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [4.1.5] - 2022-07-05 + +### Fixed +- Saving of groups with empty group shapes + ## [4.1.4] - 2022-06-20 ### Fixed diff --git a/api/models/Group.js b/api/models/Group.js index d4066bb06..430bbe879 100644 --- a/api/models/Group.js +++ b/api/models/Group.js @@ -30,18 +30,6 @@ module.exports = bookshelf.Model.extend(merge({ requireFetch: false, hasTimestamps: true, - format(attributes) { - const st = knexPostgis(bookshelf.knex) - - // Make sure geometry column goes into the database correctly, converting from GeoJSON - const { geo_shape } = attributes - if (geo_shape) { - attributes.geo_shape = st.geomFromGeoJSON(geo_shape) - } - - return attributes - }, - parse(response) { const st = knexPostgis(bookshelf.knex) @@ -393,6 +381,14 @@ module.exports = bookshelf.Model.extend(merge({ saneAttrs.location_id = isEmpty(saneAttrs.location_id) ? null : saneAttrs.location_id + // Make sure geometry column goes into the database correctly, converting from GeoJSON + if (!isEmpty(attributes.geo_shape)) { + const st = knexPostgis(bookshelf.knex) + saneAttrs.geo_shape = st.geomFromGeoJSON(attributes.geo_shape) + } else { + saneAttrs.geo_shape = null + } + // If a new location is being passed in but not a new location_id then we geocode on the server if (changes.location && changes.location !== this.get('location') && !changes.location_id) { await Queue.classMethod('Group', 'geocodeLocation', { groupId: this.id }) diff --git a/package.json b/package.json index 9b50b8234..5f3df1c84 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Tibet Sprague ", "license": "GNU AFFERO GENERAL PUBLIC LICENSE v3", "private": true, - "version": "4.1.4", + "version": "4.1.5", "repository": { "type": "git", "url": "git://github.com/Hylozoic/hylo-node.git"