From f9ba95fe0d753e56e392c95ccc24b5520efedd88 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Fri, 27 May 2022 13:35:14 +0200 Subject: [PATCH] Added cloning button for observations --- src/components/Observation.vue | 21 ++++++++++++++++++--- src/components/ObservationList.vue | 12 +++++++++++- src/locales/en.json | 4 +++- src/locales/nb.json | 4 +++- src/main.js | 3 +++ 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/components/Observation.vue b/src/components/Observation.vue index 6a6b62f..e5700b8 100644 --- a/src/components/Observation.vue +++ b/src/components/Observation.vue @@ -151,7 +151,7 @@ export default { name: 'Observation', - props: ['observationId', 'paramGeoinfo', 'locationPointOfInterestId', 'paramObservation'], + props: ['observationId', 'paramGeoinfo', 'locationPointOfInterestId', 'paramObservation', 'createClone'], components: {MapObservation, Quantification, Sync, ObservationIllustrationBoard}, data() { return { @@ -575,7 +575,7 @@ /** Whether record to be updated */ let isRecordAvailable = null; if (lstObservations) { - isRecordAvailable = lstObservations.find(({observationId}) => observationId === this.observationId); + isRecordAvailable = lstObservations.find(({observationId}) => observationId === this.observation.observationId); } this.observationForStore.cropOrganismId = this.crop.cropId; @@ -742,9 +742,24 @@ /* Get details of existing Observation */ if (this.observationId) { + var nowStrDateObservation = this.strDateObservation; this.getObservationFromStore(this.observationId); - this.observation.observationId = this.observationId; + if(this.createClone != undefined && this.createClone) + { + // Set id to null + this.observation.observationId = null; + // Set timestamp to "now" + this.strDateObservation = nowStrDateObservation; + this.observation.timeOfObservation = this.strDateObservation; + // Remove image collection + this.observation.observationIllustrationSet = []; + // Remove quantification + this.observation.observationData = ""; + // Change header to Header + "KOPI" + this.observation.observationHeading = this.observation.observationHeading + " " + this.$i18n.t("copy").toUpperCase() + " " + maxDate; + } + } else { let isCropIdsAvailable = false; diff --git a/src/components/ObservationList.vue b/src/components/ObservationList.vue index 48f420e..4037958 100644 --- a/src/components/ObservationList.vue +++ b/src/components/ObservationList.vue @@ -39,8 +39,18 @@ <div v-if="obs.isDeleted"> <strike> {{ obs.timeOfObservation | dateFormat }} <b>{{obs.observationHeading}}</b> </strike> </div> - <div v-else> + <div v-else class="row"> + <div class="col-10"> {{ obs.timeOfObservation | dateFormat }} <b>{{obs.observationHeading}}</b> + </div> + <div class="col-2"> + <router-link + :to="{name: 'Observation', params: {observationId:obs.observationId,createClone:true}}" + class="addobs-btn"> + <font-awesome-icon style="font-size: x-large; color: #3d8052; " + icon="fa-solid fa-clone" /></i> + </router-link> + </div> </div> </router-link> diff --git a/src/locales/en.json b/src/locales/en.json index d1a260d..4e3bb87 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -70,5 +70,7 @@ "index.header": "Field observations", "about.header": "About", "about.version": "Version", - "about.text": "<p>The app is developed by <a href='https://nibio.no/em' target='new'>NIBIO</a>'s <a href='https://www.vips-landbruk.no/'>VIPS team</a>.</p><p>VIPS project leader: <a href='https://www.nibio.no/en/employees/berit-nordskog' target='new'>Berit Nordskog</a></p><p>© 2022 <a href='https://nibio.no/en' target='new'>NIBIO</a></p>" + "about.text": "<p>The app is developed by <a href='https://nibio.no/em' target='new'>NIBIO</a>'s <a href='https://www.vips-landbruk.no/'>VIPS team</a>.</p><p>VIPS project leader: <a href='https://www.nibio.no/en/employees/berit-nordskog' target='new'>Berit Nordskog</a></p><p>© 2022 <a href='https://nibio.no/en' target='new'>NIBIO</a></p>", + + "copy" : "Copy" } \ No newline at end of file diff --git a/src/locales/nb.json b/src/locales/nb.json index b800e1b..876c04b 100644 --- a/src/locales/nb.json +++ b/src/locales/nb.json @@ -70,5 +70,7 @@ "index.header": "Feltobservasjoner", "about.header": "Om appen", "about.version": "Versjon", - "about.text": "<p>Appen er utviklet av <a href='https://nibio.no' target='new'>NIBIO</a>s <a href='https://www.vips-landbruk.no/'>VIPS-team</a>.</p><p>Prosjektleder for VIPS: <a href='https://www.nibio.no/ansatte/berit-nordskog' target='new'>Berit Nordskog</a></p><p>© 2022 <a href='https://nibio.no' target='new'>NIBIO</a></p>" + "about.text": "<p>Appen er utviklet av <a href='https://nibio.no' target='new'>NIBIO</a>s <a href='https://www.vips-landbruk.no/'>VIPS-team</a>.</p><p>Prosjektleder for VIPS: <a href='https://www.nibio.no/ansatte/berit-nordskog' target='new'>Berit Nordskog</a></p><p>© 2022 <a href='https://nibio.no' target='new'>NIBIO</a></p>", + + "copy" : "Kopi" } \ No newline at end of file diff --git a/src/main.js b/src/main.js index aa4e140..566a3e3 100644 --- a/src/main.js +++ b/src/main.js @@ -31,9 +31,12 @@ import { faUser } from '@fortawesome/free-solid-svg-icons' library.add(faUser); import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons' library.add(faCircleQuestion); +import { faClone } from '@fortawesome/free-solid-svg-icons' +library.add(faClone); import { faTrashCan } from '@fortawesome/free-regular-svg-icons' library.add(faTrashCan); + import {version} from '../package' -- GitLab