# HG changeset patch # User Thomas Junk # Date 1548085992 -3600 # Node ID d1b7b1c7041053e79efb514157b57087a267d67c # Parent d4249b07e71982cf4b58ffb641c6598343c892f8 import stretch: listview with edit-function diff -r d4249b07e719 -r d1b7b1c70410 client/src/components/ImportStretches.vue --- a/client/src/components/ImportStretches.vue Mon Jan 21 15:49:51 2019 +0100 +++ b/client/src/components/ImportStretches.vue Mon Jan 21 16:53:12 2019 +0100 @@ -4,23 +4,45 @@ Define stretches -
-
-
id
-
funktion
-
startrhm
-
endrhm
-
-
-
{{ stretch.id }}
-
{{ stretch.funktion }}
-
{{ stretch.startrhm }}
-
{{ stretch.endrhm }}
-
+
+ + + + + + + + + + + + + + + + + + + +
NameDatumSource organization  
+ {{ + stretch.properties.name + }} + + {{ formatSurveyDate(stretch.properties["date_info"]) }} + {{ stretch.properties["source_organization"] }} + + + +
No results.
@@ -226,6 +248,8 @@ */ import { mapState, mapGetters } from "vuex"; import { displayError, displayInfo } from "@/lib/errors.js"; +import { formatSurveyDate } from "@/lib/date.js"; +import center from "@turf/center"; export default { name: "importstretches", @@ -256,15 +280,46 @@ }, mounted() { this.edit = false; - // this.$store.dispatch("imports/loadStretches").catch(error => { - // const { status, data } = error.response; - // displayError({ - // title: this.$gettext("Backend Error"), - // message: `${status}: ${data.message || data}` - // }); - // }); + this.loadStretches(); }, 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]; + this.edit = true; + }, + deleteStretch(index) { + displayInfo({ + title: this.$gettext("Not implemented"), + message: this.$gettext("Deleting " + this.stretches[index].id) + }); + }, + moveMapToStretch(index) { + const { coordinates } = center(this.stretches[index]).geometry; + this.$store.commit("map/moveMap", { + coordinates: coordinates, + zoom: 17, + preventZoomOut: true + }); + }, + formatSurveyDate(d) { + return formatSurveyDate(d); + }, + loadStretches() { + this.$store.dispatch("imports/loadStretches").catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); + }, clean() { this.id = ""; this.funktion = ""; @@ -339,6 +394,7 @@ }); this.clean(); this.edit = false; + this.loadStretches(); }) .catch(error => { console.log(error); @@ -375,24 +431,4 @@ }; - + diff -r d4249b07e719 -r d1b7b1c70410 client/src/store/imports.js --- a/client/src/store/imports.js Mon Jan 21 15:49:51 2019 +0100 +++ b/client/src/store/imports.js Mon Jan 21 16:53:12 2019 +0100 @@ -14,6 +14,7 @@ import { HTTP } from "@/lib/http"; import Vue from "vue"; +import { WFS } from "ol/format.js"; /* eslint-disable no-unused-vars */ /* eslint-disable no-unreachable */ @@ -115,10 +116,6 @@ setStretches: (state, stretches) => { state.stretches = stretches; }, - // only for prototype purposes delete after real backend is active - addStretch: (state, stretch) => { - state.stretches.push(stretch); - }, clearCurrentSchedule: state => { state.currentSchedule = initializeCurrentSchedule(); }, @@ -219,13 +216,28 @@ }, actions: { loadStretches({ commit }) { - throw new Error("Endpoint not activated!"); return new Promise((resolve, reject) => { - HTTP.get("/imports/stretch", { - headers: { "X-Gemma-Auth": localStorage.getItem("token") } - }) + var stretchesFeatureCollectionRequest = new WFS().writeGetFeature({ + srsName: "EPSG:4326", + featureNS: "gemma", + featurePrefix: "gemma", + featureTypes: ["stretches"], + outputFormat: "application/json" + }); + HTTP.post( + "/internal/wfs", + new XMLSerializer().serializeToString( + stretchesFeatureCollectionRequest + ), + { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "text/xml; charset=UTF-8" + } + } + ) .then(response => { - commit("setStretches", response.data); + commit("setStretches", response.data.features); resolve(response); }) .catch(error => { @@ -239,7 +251,6 @@ headers: { "X-Gemma-Auth": localStorage.getItem("token") } }) .then(response => { - commit("setStretches", response.data); resolve(response); }) .catch(error => {