Mercurial > gemma
changeset 1200:502e0b960424
improve manual coordinate input validation
allows only numbers now
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Mon, 19 Nov 2018 09:01:06 +0100 |
parents | 181b8a947ecd |
children | 37889ae85133 |
files | client/src/fairway/Fairwayprofile.vue |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/fairway/Fairwayprofile.vue Mon Nov 19 08:51:44 2018 +0100 +++ b/client/src/fairway/Fairwayprofile.vue Mon Nov 19 09:01:06 2018 +0100 @@ -523,16 +523,16 @@ const coordinates = this.coordinatesInput .split(",") .map(coord => parseFloat(coord.trim())); - if (coordinates.length === 4) { - this.applyCoordinates([ - coordinates[1], - coordinates[0], - coordinates[3], - coordinates[2] - ]); - } + this.applyCoordinates([ + coordinates[1], + coordinates[0], + coordinates[3], + coordinates[2] + ]); }, applyCoordinates(coordinates) { + // allow only numbers + coordinates = coordinates.filter(c => Number(c) === c) if (coordinates.length === 4) { // draw line on map const cutLayer = this.getLayerByName("Cut Tool"); @@ -547,6 +547,11 @@ // draw diagram this.$store.dispatch("fairwayprofile/cut", cut); + } else { + displayError({ + title: "Invalid input", + message: "Please enter correct coordinates in the format: Lat,Lon,Lat,Lon" + }); } }, saveCut() {