# HG changeset patch # User Thomas Junk # Date 1558008945 -7200 # Node ID 7a88b37bce8b2dbab76dedcbb3101d8b5b66f3ed # Parent 6996aa1d2df9a2156d3db915d83ae36edc1d6f72# Parent 3ada3d0347bd092541638ffb925c80ccadd85242 merge diff -r 6996aa1d2df9 -r 7a88b37bce8b client/src/components/sections/SectionForm.vue --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/sections/SectionForm.vue Thu May 16 14:15:45 2019 +0200 @@ -0,0 +1,360 @@ + + + + + diff -r 6996aa1d2df9 -r 7a88b37bce8b client/src/components/sections/Sections.vue --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/sections/Sections.vue Thu May 16 14:15:45 2019 +0200 @@ -0,0 +1,249 @@ + + + + + diff -r 6996aa1d2df9 -r 7a88b37bce8b 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 14:15:45 2019 +0200 @@ -0,0 +1,384 @@ + + + + + diff -r 6996aa1d2df9 -r 7a88b37bce8b client/src/components/stretches/Stretches.vue --- a/client/src/components/stretches/Stretches.vue Thu May 16 12:53:46 2019 +0200 +++ b/client/src/components/stretches/Stretches.vue Thu May 16 14:15:45 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") diff -r 6996aa1d2df9 -r 7a88b37bce8b client/src/store/imports.js --- a/client/src/store/imports.js Thu May 16 12:53:46 2019 +0200 +++ b/client/src/store/imports.js Thu May 16 14:15:45 2019 +0200 @@ -33,6 +33,8 @@ warning: false, stretches: [], selectedStretchId: null, + sections: [], + selectedSectionId: null, imports: [], reviewed: [], show: null, @@ -46,19 +48,19 @@ }; }; -const getStretchFromWFS = filter => { +const getFromWFS = (type, filter) => { return new Promise((resolve, reject) => { - var stretchesFeatureCollectionRequest = new WFS().writeGetFeature({ + var featureCollectionRequest = new WFS().writeGetFeature({ srsName: "EPSG:4326", featureNS: "gemma", featurePrefix: "gemma", - featureTypes: ["stretches_geoserver"], + featureTypes: [type], outputFormat: "application/json", filter: filter }); HTTP.post( "/internal/wfs", - new XMLSerializer().serializeToString(stretchesFeatureCollectionRequest), + new XMLSerializer().serializeToString(featureCollectionRequest), { headers: { "X-Gemma-Auth": localStorage.getItem("token"), @@ -132,6 +134,12 @@ selectedStretchId: (state, id) => { state.selectedStretchId = id; }, + setSections: (state, sections) => { + state.sections = sections; + }, + selectedSectionId: (state, id) => { + state.selectedSectionId = id; + }, setReviewed: (state, reviewed) => { state.reviewed = reviewed; }, @@ -194,7 +202,7 @@ actions: { loadStretch(context, name) { return new Promise((resolve, reject) => { - getStretchFromWFS(equalToFilter("name", name)) + getFromWFS("stretches_geoserver", equalToFilter("name", name)) .then(response => { resolve(response); }) @@ -205,7 +213,7 @@ }, loadStretches({ commit }) { return new Promise((resolve, reject) => { - getStretchFromWFS(equalToFilter("staging_done", true)) + getFromWFS("stretches_geoserver", equalToFilter("staging_done", true)) .then(response => { if (response.data.features) { commit("setStretches", response.data.features); @@ -232,6 +240,46 @@ }); }); }, + loadSection(context, name) { + return new Promise((resolve, reject) => { + getFromWFS("sections_geoserver", equalToFilter("name", name)) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, + loadSections({ commit }) { + return new Promise((resolve, reject) => { + getFromWFS("sections_geoserver", equalToFilter("staging_done", true)) + .then(response => { + if (response.data.features) { + commit("setSections", response.data.features); + } else { + commit("setSections", []); + } + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, + saveSection(context, section) { + return new Promise((resolve, reject) => { + HTTP.post("/imports/sec", section, { + headers: { "X-Gemma-Auth": localStorage.getItem("token") } + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, getImports({ commit }, options) { let { filter, from, to, query } = options; let queryParams = "";