# HG changeset patch # User Thomas Junk # Date 1548241158 -3600 # Node ID 53c1383dfee3038d8fd4d741a302ccef796746d3 # Parent ed3e770300b12339c92c6b46c327118efcfb4618 define stretch: edit function prefills fields diff -r ed3e770300b1 -r 53c1383dfee3 client/src/components/ImportStretches.vue --- 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;