From 6b10807115ab4bd14285a5d880124fd91252a5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Pereira?= Date: Tue, 11 Aug 2020 18:09:31 -0300 Subject: [PATCH] Fix #1645 --- .../components/geography/elevation.vue | 2 +- .../digitize/store/actions/saveCollectionEvent.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/javascript/vue/tasks/digitize/components/collectionEvent/components/geography/elevation.vue b/app/javascript/vue/tasks/digitize/components/collectionEvent/components/geography/elevation.vue index f7708d9305..1858401c3f 100644 --- a/app/javascript/vue/tasks/digitize/components/collectionEvent/components/geography/elevation.vue +++ b/app/javascript/vue/tasks/digitize/components/collectionEvent/components/geography/elevation.vue @@ -27,7 +27,7 @@ Meters diff --git a/app/javascript/vue/tasks/digitize/store/actions/saveCollectionEvent.js b/app/javascript/vue/tasks/digitize/store/actions/saveCollectionEvent.js index 55581fce1e..93d4e312d6 100644 --- a/app/javascript/vue/tasks/digitize/store/actions/saveCollectionEvent.js +++ b/app/javascript/vue/tasks/digitize/store/actions/saveCollectionEvent.js @@ -8,14 +8,19 @@ export default function ({ commit, state }) { let collection_event = state.collection_event let identifier = state.collectingEventIdentifier commit(MutationNames.SetCollectionEventIdentifier, identifierCE()) - if(identifier.namespace_id && identifier.identifier) { + if (identifier.namespace_id && identifier.identifier) { collection_event.identifiers_attributes = [identifier] } - if(JSON.stringify(CollectingEvent()) == JSON.stringify(collection_event)) { + if (JSON.stringify(CollectingEvent()) == JSON.stringify(collection_event)) { return resolve(true) - } - else { - if(collection_event.id) { + } else { + if (collection_event.units === 'ft') { + ['minimum_elevation', 'maximum_elevation', 'elevation_precision'].forEach(key => { + const elevationValue = Number(collection_event[key]) + collection_event[key] = elevationValue > 0 ? elevationValue * 3.281 : undefined + }) + } + if (collection_event.id) { UpdateCollectionEvent(collection_event).then(response => { commit(MutationNames.SetCollectionEvent, response.body) if(state.collection_event.hasOwnProperty('identifiers') && state.collection_event.identifiers.length) {