Mercurial > gemma
comparison client/src/components/ImportStretches.vue @ 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 | 9b9f1d164f26 |
children | c8e2f6838eaf |
comparison
equal
deleted
inserted
replaced
1976:ed3e770300b1 | 1977:53c1383dfee3 |
---|---|
287 this.edit = false; | 287 this.edit = false; |
288 this.loadStretches(); | 288 this.loadStretches(); |
289 }, | 289 }, |
290 methods: { | 290 methods: { |
291 editStretch(index) { | 291 editStretch(index) { |
292 const { date_info, name, objnam, nobjnam } = this.stretches[ | 292 const properties = this.stretches[index].properties; |
293 index | 293 this.date_info = properties.date_info.split("T")[0]; |
294 ].properties; | 294 this.id = properties.name; |
295 this.date_info = date_info; | 295 this.nobjbn = properties.nobjnam; |
296 this.id = name; | 296 this.objbn = properties.objnam; |
297 this.nobjbn = nobjnam; | 297 this.countryCode = properties.countries; |
298 this.objbn = objnam; | 298 this.source = properties["source_organization"]; |
299 this.source = this.stretches[index]; | |
300 this.edit = true; | 299 this.edit = true; |
300 this.startrhm = this.sanitizeRHM(properties.lower); | |
301 this.endrhm = this.sanitizeRHM(properties.upper); | |
301 }, | 302 }, |
302 deleteStretch(index) { | 303 deleteStretch(index) { |
303 displayInfo({ | 304 displayInfo({ |
304 title: this.$gettext("Not implemented"), | 305 title: this.$gettext("Not implemented"), |
305 message: this.$gettext("Deleting " + this.stretches[index].id) | 306 message: this.$gettext("Deleting " + this.stretches[index].id) |
400 to: this.endrhm, | 401 to: this.endrhm, |
401 "source-organization": this.source, | 402 "source-organization": this.source, |
402 "date-info": this.date_info, | 403 "date-info": this.date_info, |
403 objnam: this.objbn, | 404 objnam: this.objbn, |
404 nobjnam: this.nobjbn, | 405 nobjnam: this.nobjbn, |
405 countries: this.countryCode.split(",") | 406 countries: this.countryCode.split(",").map(x => { |
407 return x.trim(); | |
408 }) | |
406 }; | 409 }; |
407 this.$store | 410 this.$store |
408 .dispatch("imports/saveStretch", data) | 411 .dispatch("imports/saveStretch", data) |
409 .then(() => { | 412 .then(() => { |
410 displayInfo({ | 413 displayInfo({ |
421 displayError({ | 424 displayError({ |
422 title: this.$gettext("Backend Error"), | 425 title: this.$gettext("Backend Error"), |
423 message: `${status}: ${data.message || data}` | 426 message: `${status}: ${data.message || data}` |
424 }); | 427 }); |
425 }); | 428 }); |
429 }, | |
430 sanitizeRHM(rhm) { | |
431 return rhm.replace(/,|\(|\)/g, ""); | |
426 } | 432 } |
427 }, | 433 }, |
428 watch: { | 434 watch: { |
429 identifiedFeatures() { | 435 identifiedFeatures() { |
430 const filterDistanceMarks = x => { | 436 const filterDistanceMarks = x => { |
431 return /^distance_marks/.test(x["id_"]); | 437 return /^distance_marks/.test(x["id_"]); |
432 }; | 438 }; |
433 console.log(this.identifiedFeatures); | 439 console.log(this.identifiedFeatures); |
434 const distanceMark = this.identifiedFeatures.filter(filterDistanceMarks); | 440 const distanceMark = this.identifiedFeatures.filter(filterDistanceMarks); |
435 if (distanceMark.length > 0) { | 441 if (distanceMark.length > 0) { |
436 const value = distanceMark[0]["id_"] | 442 const value = this.sanitizeRHM(distanceMark[0]["id_"].split(".")[1]); |
437 .split(".")[1] | |
438 .replace(/,|\(|\)/g, ""); | |
439 this.startrhm = this.pipetteStart ? value : this.startrhm; | 443 this.startrhm = this.pipetteStart ? value : this.startrhm; |
440 this.endrhm = this.pipetteEnd ? value : this.endrhm; | 444 this.endrhm = this.pipetteEnd ? value : this.endrhm; |
441 this.pipetteStart = false; | 445 this.pipetteStart = false; |
442 this.pipetteEnd = false; | 446 this.pipetteEnd = false; |
443 } | 447 } |