# HG changeset patch # User Markus Kottlaender # Date 1558003820 -7200 # Node ID c2cba529658dc9519df0e61659433656cd48cfae # Parent c2d753ef5aa1dcd304d350d614486c67183c5ac1 client: define stretches: seperated list and form into two components diff -r c2d753ef5aa1 -r c2cba529658d client/src/components/stretches/StretchForm.vue --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/stretches/StretchForm.vue Thu May 16 12:50:20 2019 +0200 @@ -0,0 +1,384 @@ + + + + + diff -r c2d753ef5aa1 -r c2cba529658d client/src/components/stretches/Stretches.vue --- a/client/src/components/stretches/Stretches.vue Thu May 16 12:48:23 2019 +0200 +++ b/client/src/components/stretches/Stretches.vue Thu May 16 12:50:20 2019 +0200 @@ -1,13 +1,10 @@
-
-
-
-
-
- - ID - - - - - Please enter an id - - -
-
- - Countrycode - - - - - Please enter a countrycode - - -
-
-
-
- - Start rhm - -
- - - - -
- - - Please enter a start point - - -
-
- - End rhm - -
- - - - -
- - - Please enter an end point - - -
-
-
-
- - Tolerance for snapping of waterway axis [m] - - - - - Please enter a tolerance value - - -
-
-
-
- - Object name - - - - - Please enter an objectname - - -
-
- - National Object name - - -
-
-
-
- - Date info - - - - - Please enter a date - - -
-
- Source - - - - Please enter a source - - -
-
-
-
- - -
-
@@ -317,45 +110,23 @@ import { sortTable } from "@/lib/mixins"; export default { - name: "importstretches", mixins: [sortTable], + components: { + StretchForm: () => import("./StretchForm") + }, data() { return { staging: [], - edit: false, - editExistingStretch: false, - id: "", - funktion: "", - startrhm: "", - endrhm: "", - tolerance: 5, - objbn: "", - nobjbn: "", - countryCode: "", - date_info: new Date().toISOString().split("T")[0], - source: "", - pipetteStart: false, - pipetteEnd: false, - idError: false, - funktionError: false, - startrhmError: false, - endrhmError: false, - toleranceError: false, - objbnError: false, - nobjbnError: false, - date_infoError: false, - sourceError: false, - countryCodeError: false, - loading: false + loading: false, + showForm: false, + editStretch: null }; }, computed: { ...mapState("application", ["searchQuery"]), - ...mapState("map", ["identifiedFeatures", "currentMeasurement"]), ...mapGetters("map", ["openLayersMap"]), - ...mapGetters("user", ["isSysAdmin"]), ...mapState("imports", ["stretches"]), - defineStretchesLabel() { + title() { return this.$gettext("Define Stretches"); }, nameLabel() { @@ -369,24 +140,6 @@ }, reviewTooltip() { return this.$gettext("Review pending import"); - }, - pipetteTooltip() { - return this.$gettext("Choose a distance mark by clicking on the map."); - } - }, - watch: { - identifiedFeatures() { - const distanceMark = this.identifiedFeatures.find(x => - /^distance_marks_geoserver/.test(x["id_"]) - ); - if (distanceMark) { - const location = distanceMark.get("location"); - this.startrhm = this.pipetteStart ? location : this.startrhm; - this.endrhm = this.pipetteEnd ? location : this.endrhm; - this.pipetteStart = false; - this.pipetteEnd = false; - this.$store.commit("map/mapPopupEnabled", true); - } } }, methods: { @@ -438,19 +191,6 @@ }); }); }, - editStretch(stretch) { - const properties = stretch.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 = properties.lower.replace(/[,()]/g, ""); - this.endrhm = properties.upper.replace(/[,()]/g, ""); - this.editExistingStretch = true; - }, deleteStretch(stretch) { this.$store.commit("application/popup", { icon: "trash", @@ -489,123 +229,9 @@ zoom: 17, preventZoomOut: true }); - }, - clean() { - this.id = ""; - this.edit = false; - this.editExistingStretch = false; - this.funktion = ""; - this.startrhm = ""; - this.tolerance = 5; - this.endrhm = ""; - this.objbn = ""; - this.nobjbn = ""; - this.countryCode = ""; - this.date_info = new Date().toISOString().split("T")[0]; - this.source = ""; - this.pipetteStart = false; - this.pipetteEnd = false; - this.idError = false; - this.funktionError = false; - this.startrhmError = false; - this.endrhmError = false; - this.toleranceError = false; - this.objbnError = false; - this.nobjbnError = false; - this.date_infoError = false; - this.sourceError = false; - this.countryCodeError = false; - }, - startEdit() { - this.clean(); - this.edit = true; - }, - togglePipette(t) { - this.openLayersMap() - .getLayer("DISTANCEMARKSAXIS") - .setVisible(true); - if (t === "start") { - this.$store.commit("map/mapPopupEnabled", this.pipetteStart); - this.pipetteStart = !this.pipetteStart; - this.pipetteEnd = false; - } else { - this.$store.commit("map/mapPopupEnabled", this.pipetteEnd); - this.pipetteEnd = !this.pipetteEnd; - this.pipetteStart = false; - } - }, - validate() { - const fields = [ - "id", - "funktion", - "startrhm", - "tolerance", - "endrhm", - "objbn", - "nobjbn", - "countryCode", - "date_info", - "source" - ]; - fields.forEach(field => { - if (!this[field]) { - this[field + "Error"] = true; - } else { - this[field + "Error"] = false; - } - }); - }, - save() { - this.validate(); - if ( - !this.id || - !this.startrhm || - !this.endrhm || - (!this.tolerance && this.editExistingStretch) || - !this.source || - !this.date_info || - !this.objbn || - !this.countryCode - ) - return; - const data = { - name: this.id, - from: this.startrhm, - to: this.endrhm, - "source-organization": this.source, - "date-info": this.date_info, - objnam: this.objbn, - nobjnam: this.nobjbn, - countries: this.countryCode.split(",").map(x => { - return x.trim(); - }) - }; - if (!this.editExistingStretch) { - data["tolerance"] = this.tolerance; - } - this.$store - .dispatch("imports/saveStretch", data) - .then(() => { - displayInfo({ - title: this.$gettext("Import"), - message: this.$gettext("Starting import of stretch") - }); - this.clean(); - this.$store.dispatch("imports/loadStretches").then(() => { - this.edit = false; - }); - }) - .catch(error => { - const { status, data } = error.response; - displayError({ - title: this.$gettext("Backend Error"), - message: `${status}: ${data.message || data}` - }); - }); } }, mounted() { - this.edit = false; this.loading = true; this.$store .dispatch("imports/loadStretches")