changeset 1977:53c1383dfee3

define stretch: edit function prefills fields
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 23 Jan 2019 11:59:18 +0100
parents ed3e770300b1
children 0a8fa6893181
files client/src/components/ImportStretches.vue
diffstat 1 files changed, 16 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/ImportStretches.vue	Wed Jan 23 11:20:38 2019 +0100
+++ b/client/src/components/ImportStretches.vue	Wed Jan 23 11:59:18 2019 +0100
@@ -289,15 +289,16 @@
   },
   methods: {
     editStretch(index) {
-      const { date_info, name, objnam, nobjnam } = this.stretches[
-        index
-      ].properties;
-      this.date_info = date_info;
-      this.id = name;
-      this.nobjbn = nobjnam;
-      this.objbn = objnam;
-      this.source = this.stretches[index];
+      const properties = this.stretches[index].properties;
+      this.date_info = properties.date_info.split("T")[0];
+      this.id = properties.name;
+      this.nobjbn = properties.nobjnam;
+      this.objbn = properties.objnam;
+      this.countryCode = properties.countries;
+      this.source = properties["source_organization"];
       this.edit = true;
+      this.startrhm = this.sanitizeRHM(properties.lower);
+      this.endrhm = this.sanitizeRHM(properties.upper);
     },
     deleteStretch(index) {
       displayInfo({
@@ -402,7 +403,9 @@
         "date-info": this.date_info,
         objnam: this.objbn,
         nobjnam: this.nobjbn,
-        countries: this.countryCode.split(",")
+        countries: this.countryCode.split(",").map(x => {
+          return x.trim();
+        })
       };
       this.$store
         .dispatch("imports/saveStretch", data)
@@ -423,6 +426,9 @@
             message: `${status}: ${data.message || data}`
           });
         });
+    },
+    sanitizeRHM(rhm) {
+      return rhm.replace(/,|\(|\)/g, "");
     }
   },
   watch: {
@@ -433,9 +439,7 @@
       console.log(this.identifiedFeatures);
       const distanceMark = this.identifiedFeatures.filter(filterDistanceMarks);
       if (distanceMark.length > 0) {
-        const value = distanceMark[0]["id_"]
-          .split(".")[1]
-          .replace(/,|\(|\)/g, "");
+        const value = this.sanitizeRHM(distanceMark[0]["id_"].split(".")[1]);
         this.startrhm = this.pipetteStart ? value : this.startrhm;
         this.endrhm = this.pipetteEnd ? value : this.endrhm;
         this.pipetteStart = false;