Skip to content
Snippets Groups Projects
Commit c74ca189 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

Merge branch 'evol/redmine-ticket-11442-linked_features-update' into...

Merge branch 'evol/redmine-ticket-11442-linked_features-update' into evol/redmine-ticket-11442-linked_features
parents 38074f4b 9529c9f0
No related branches found
No related tags found
1 merge request!43Evol/redmine ticket 11442 linked features
...@@ -235,12 +235,12 @@ export default new Vuex.Store({ ...@@ -235,12 +235,12 @@ export default new Vuex.Store({
}); });
}, },
GET_PROJECT_INFO({ state, commit, dispatch }, slug) { async GET_PROJECT_INFO({ state, commit, dispatch }, slug) {
commit("SET_PROJECT_SLUG", slug); commit("SET_PROJECT_SLUG", slug);
dispatch("GET_PROJECT_LAST_MESSAGES", slug); await dispatch("GET_PROJECT_LAST_MESSAGES", slug);
dispatch("feature_type/GET_PROJECT_FEATURE_TYPES", slug); await dispatch("feature_type/GET_PROJECT_FEATURE_TYPES", slug);
dispatch("feature/GET_PROJECT_FEATURES", slug); await dispatch("feature/GET_PROJECT_FEATURES", slug);
if (state.user) dispatch("map/GET_BASEMAPS", slug); if (state.user) await dispatch("map/GET_BASEMAPS", slug);
}, },
GET_PROJECT_LAST_MESSAGES({ commit }, project_slug) { GET_PROJECT_LAST_MESSAGES({ commit }, project_slug) {
......
...@@ -68,7 +68,7 @@ const feature = { ...@@ -68,7 +68,7 @@ const feature = {
}, },
actions: { actions: {
GET_PROJECT_FEATURES({ commit, rootState }, project_slug) { GET_PROJECT_FEATURES({ commit, rootState }, project_slug) {
axios return axios
.get(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}projects/${project_slug}/feature/`) .get(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}projects/${project_slug}/feature/`)
.then((response) => { .then((response) => {
if (response.status === 200 && response.data) { if (response.status === 200 && response.data) {
......
<template> <template>
<div v-frag> <div v-frag>
<script type="application/javascript" :src="baseUrl+'/resources/leaflet-control-geocoder-1.13.0/Control.Geocoder.js'"></script> <script
type="application/javascript"
:src="
baseUrl +
'/resources/leaflet-control-geocoder-1.13.0/Control.Geocoder.js'
"
></script>
<div class="fourteen wide column"> <div class="fourteen wide column">
<h1 v-if="feature && currentRouteName === 'editer-signalement'"> <h1 v-if="feature && currentRouteName === 'editer-signalement'">
Mise à jour du signalement "{{ feature.title || feature.feature_id }}" Mise à jour du signalement "{{ feature.title || feature.feature_id }}"
...@@ -265,8 +271,8 @@ export default { ...@@ -265,8 +271,8 @@ export default {
data() { data() {
return { return {
map: null, map: null,
feature_type:null, feature_type: null,
baseUrl:this.$store.state.configuration.BASE_URL, baseUrl: this.$store.state.configuration.BASE_URL,
file: null, file: null,
showGeoRef: false, showGeoRef: false,
showGeoPositionBtn: true, showGeoPositionBtn: true,
...@@ -274,23 +280,23 @@ export default { ...@@ -274,23 +280,23 @@ export default {
erreurUploadMessage: null, erreurUploadMessage: null,
attachmentDataKey: 0, attachmentDataKey: 0,
linkedDataKey: 0, linkedDataKey: 0,
statusChoicesFilter:[], statusChoicesFilter: [],
statusChoices: [ statusChoices: [
{ {
name: "Brouillon", name: "Brouillon",
value: "draft", value: "draft",
}, },
{ {
name: "Publié", name: "Publié",
value: "published" value: "published",
}, },
{ {
name: "Archivé", name: "Archivé",
value: "archived" value: "archived",
}, },
{ {
name: "En attente de publication", name: "En attente de publication",
value: "pending" value: "pending",
}, },
], ],
form: { form: {
...@@ -369,29 +375,29 @@ export default { ...@@ -369,29 +375,29 @@ export default {
}, },
}, },
watch: { /* watch: {
feature(newValue) { feature(newValue) {
if (this.$route.name === "editer-signalement") { if (this.$route.name === "editer-signalement") {
this.initForm(); this.initForm();
this.initExtraForms(newValue); this.initExtraForms(newValue);
} }
}, },
}, }, */
methods: { methods: {
makeStatusChoicesFilter(){ makeStatusChoicesFilter() {
let newStatusChoices = this.statusChoices let newStatusChoices = this.statusChoices;
if (this.project){ if (this.project) {
if (!this.project.moderation){ if (!this.project.moderation) {
newStatusChoices = [] newStatusChoices = [];
this.statusChoices.forEach(function(status) { this.statusChoices.forEach(function (status) {
if (status.value !== 'pending') { if (status.value !== "pending") {
newStatusChoices.push(status) newStatusChoices.push(status);
} }
}); });
} }
} }
this.statusChoicesFilter = newStatusChoices this.statusChoicesFilter = newStatusChoices;
}, },
initForm() { initForm() {
if (this.currentRouteName === "editer-signalement") { if (this.currentRouteName === "editer-signalement") {
...@@ -452,25 +458,24 @@ export default { ...@@ -452,25 +458,24 @@ export default {
}, },
}) })
.then(function (response) { .then(function (response) {
console.log("SUCCESS!!",response.data); console.log("SUCCESS!!", response.data);
if(response.data.geom.indexOf('POINT')>=0){ if (response.data.geom.indexOf("POINT") >= 0) {
let regexp=/POINT\s\((.*)\s(.*)\)/; let regexp = /POINT\s\((.*)\s(.*)\)/;
var arr = regexp.exec(response.data.geom); var arr = regexp.exec(response.data.geom);
let json={ "type": "Feature", let json = {
"geometry": { type: "Feature",
"type": "Point", geometry: {
"coordinates": [arr[1], arr[2]] type: "Point",
coordinates: [arr[1], arr[2]],
}, },
"properties": { properties: {},
}
}; };
self.updateMap(self.map, json) self.updateMap(self.map, json);
self.updateGeomField(json) self.updateGeomField(json);
// Set Attachment // Set Attachment
//self.addAttachment(self.file) //self.addAttachment(self.file)
} }
}) })
.catch(function (response) { .catch(function (response) {
console.log("FAILURE!!"); console.log("FAILURE!!");
...@@ -792,8 +797,8 @@ export default { ...@@ -792,8 +797,8 @@ export default {
); );
}, },
updateMap(map, geomFeatureJSON) { updateMap(geomFeatureJSON) {
this.drawnItems.clearLayers(); if (this.drawnItems) this.drawnItems.clearLayers();
console.log("update map"); console.log("update map");
var geomType = this.feature_type.geom_type; var geomType = this.feature_type.geom_type;
if (geomFeatureJSON) { if (geomFeatureJSON) {
...@@ -837,7 +842,7 @@ export default { ...@@ -837,7 +842,7 @@ export default {
axios axios
.get(url) .get(url)
.then((response) => { .then((response) => {
//console.log(response); console.log(response.data.features);
const features = response.data.features; const features = response.data.features;
if (features) { if (features) {
const allFeaturesExceptCurrent = features.filter( const allFeaturesExceptCurrent = features.filter(
...@@ -891,7 +896,9 @@ export default { ...@@ -891,7 +896,9 @@ export default {
created() { created() {
if (!this.project) { if (!this.project) {
this.project = this.$store.state.projects.find((project) => project.slug === this.$store.state.project_slug); this.project = this.$store.state.projects.find(
(project) => project.slug === this.$store.state.project_slug
);
this.makeStatusChoicesFilter(); this.makeStatusChoicesFilter();
} }
...@@ -911,25 +918,27 @@ export default { ...@@ -911,25 +918,27 @@ export default {
}, },
mounted() { mounted() {
let ftSlug=this.$route.params.slug_type_signal; let ftSlug = this.$route.params.slug_type_signal;
this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug).then(data=>{ this.$store
console.log(data) .dispatch("GET_PROJECT_INFO", this.$route.params.slug)
.then((data) => {
console.log(data);
this.initForm(); this.initForm();
this.initMap(); this.initMap();
this.feature_type=this.$store.state.feature_type.feature_types.find( console.log(this.$store.state.feature_type.feature_types)
(el) => el.slug === ftSlug this.feature_type = this.$store.state.feature_type.feature_types.find(
); (el) => el.slug === ftSlug
);
this.onFeatureTypeLoaded(); this.onFeatureTypeLoaded();
this.initExtraForms(); this.initExtraForms();
setTimeout( setTimeout(
function () { function () {
mapUtil.addGeocoders(this.$store.state.configuration); mapUtil.addGeocoders(this.$store.state.configuration);
}.bind(this), 1000); }.bind(this),
}) 1000
);
});
}, },
}; };
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment