Skip to content
Snippets Groups Projects
Commit 2fd26139 authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'ticket/11742' into 'develop'

add DELETE Feature

See merge request geocontrib/geocontrib-frontend!22
parents 8d95d13b 22b859d5
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ axios.defaults.headers.common['X-CSRFToken'] = (name => {
return (value != null) ? unescape(value[1]) : null;
})('csrftoken');
const DJANGO_API_BASE = process.env.VUE_APP_DJANGO_API_BASE
const feature = {
namespaced: true,
......@@ -66,7 +67,7 @@ const feature = {
actions: {
GET_PROJECT_FEATURES({ commit, /* dispatch */ }, project_slug) {
axios
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${project_slug}/feature/`)
.get(`${DJANGO_API_BASE}projects/${project_slug}/feature/`)
.then((response) => {
if (response.status === 200 && response.data) {
const features = response.data.features;
......@@ -100,7 +101,7 @@ const feature = {
if (routeName === "editer-signalement") {
axios
.put(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}features/${state.form.feature_id}/`, geojson)
.put(`${DJANGO_API_BASE}features/${state.form.feature_id}/`, geojson)
.then((response) => {
if (response.status === 200 && response.data) {
router.push({
......@@ -117,7 +118,7 @@ const feature = {
});
} else {
axios
.post(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}features/`, geojson)
.post(`${DJANGO_API_BASE}features/`, geojson)
.then((response) => {
if (response.status === 201 && response.data) {
dispatch("SEND_ATTACHMENTS", response.data.id)
......@@ -146,7 +147,7 @@ const feature = {
}
formdata.append("data", JSON.stringify(data));
axios
.post(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}features/${featureId}/attachments/`, formdata)
.post(`${DJANGO_API_BASE}features/${featureId}/attachments/`, formdata)
.then((response) => {
if (response.status === 200 && response.data) {
console.log(response, response.data)
......@@ -164,8 +165,17 @@ const feature = {
.getlinked_features(featureId)
.then((data) => commit("SET_FEATURE_LINKS", data));
} */
//DELETE_FEATURE({ state }, feature_slug) {
//console.log("Deleting feature:", feature_slug, state)
DELETE_FEATURE({ state }, feature_id) {
console.log("Deleting feature:", feature_id, state)
const url=`${DJANGO_API_BASE}features/${feature_id}`;
axios
.delete(url, {
})
.then()
.catch(() => {
return false;
});
},
// POST_COMMENT({ state }, data) {
//console.log("post comment", data, state)
......
......@@ -448,12 +448,27 @@ export default {
this.comment_form.attachment_file.value = shortName;
this.comment_form.title.value = shortName;
},
goBackToProject(message) {
this.$router.push({
name: "project_detail",
params: {
slug: this.$store.state.project_slug,
message,
},
});
},
deleteFeature() {
this.$store.dispatch(
"feature/DELETE_FEATURE",
this.$route.params.slug_signal
);
this.feature.feature_id
)
.then(() => {
this.$store.dispatch(
"feature/GET_PROJECT_FEATURES"
)
this.goBackToProject();
});
},
initMap() {
......
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