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

adjust routing for project and feature

parent e44ad0cd
No related branches found
No related tags found
No related merge requests found
......@@ -104,10 +104,11 @@ const feature = {
.then((response) => {
if (response.status === 200 && response.data) {
router.push({
name: "project_detail",
name: "details-signalement",
params: {
slug: rootState.project_slug,
message: "Le signalement a été mis à jour",
slug_type_signal: rootState.feature_type.current_feature_type_slug,
slug_signal: state.form.feature_id,
//message: "Le signalement a été mis à jour",
},
});
}
......@@ -122,10 +123,11 @@ const feature = {
if (response.status === 201 && response.data) {
dispatch("SEND_ATTACHMENTS", response.data.id)
router.push({
name: "project_detail",
name: "details-signalement",
params: {
slug: rootState.project_slug,
message: "Le signalement a été crée",
slug_type_signal: rootState.feature_type.current_feature_type_slug,
slug_signal: response.data.id,
//message: "Le signalement a été crée",
},
});
}
......@@ -159,21 +161,21 @@ const feature = {
}
},
/* GET_FEATURE_LINK({ commit }, featureId) {
featureAPI
.getlinked_features(featureId)
.then((data) => commit("SET_FEATURE_LINKS", data));
} */
/* GET_FEATURE_LINK({ commit }, featureId) {
featureAPI
.getlinked_features(featureId)
.then((data) => commit("SET_FEATURE_LINKS", data));
} */
DELETE_FEATURE({ state, rootState }, feature_id) {
console.log("Deleting feature:", feature_id, state)
const url=`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${feature_id}`;
axios
.delete(url, {
})
.then()
.catch(() => {
return false;
});
const url = `${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${feature_id}`;
axios
.delete(url, {
})
.then()
.catch(() => {
return false;
});
},
// POST_COMMENT({ state }, data) {
......
......@@ -579,16 +579,6 @@ export default {
return isValid;
},
goBackToProject(message) {
this.$router.push({
name: "project_detail",
params: {
slug: this.$store.state.project_slug,
message,
},
});
},
postForm() {
let is_valid = true;
if (!this.feature_type.title_optional) {
......@@ -876,7 +866,6 @@ export default {
},
created() {
if (!this.project) {
this.project = this.$store.state.projects.find((project) => project.slug === this.$store.state.project_slug);
this.makeStatusChoicesFilter();
......
......@@ -172,12 +172,11 @@ import Dropdown from "@/components/Dropdown.vue";
import { mapGetters } from "vuex";
axios.defaults.headers.common['X-CSRFToken'] = (name => {
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : null;
})('csrftoken');
axios.defaults.headers.common["X-CSRFToken"] = ((name) => {
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return value != null ? unescape(value[1]) : null;
})("csrftoken");
export default {
name: "Project_edit",
......@@ -284,30 +283,28 @@ export default {
postProjectThumbnail(projectSlug) {
//* send img to the backend when feature_type is created
if (this.fileToImport.size > 0) {
let formData = new FormData();
formData.append("file", this.fileToImport);
const url =
this.$store.state.configuration.VUE_APP_DJANGO_API_BASE +
"projects/" +
projectSlug +
"/thumbnail/";
return axios
.put(url, formData, {
headers: {
"Content-Type": "multipart/form-data",
},
})
.then((response) => {
if (response && response.status === 200) {
//dispatch("GET_IMPORTS", feature_type_slug); // ? Besoin de vérifier le statut de l'import ?
this.goBackNrefresh(projectSlug);
}
})
.catch((error) => {
throw error;
});
}
let formData = new FormData();
formData.append("file", this.fileToImport);
const url =
this.$store.state.configuration.VUE_APP_DJANGO_API_BASE +
"projects/" +
projectSlug +
"/thumbnail/";
return axios
.put(url, formData, {
headers: {
"Content-Type": "multipart/form-data",
},
})
.then((response) => {
if (response && response.status === 200) {
//dispatch("GET_IMPORTS", feature_type_slug); // ? Besoin de vérifier le statut de l'import ?
this.goBackNrefresh(projectSlug);
}
})
.catch((error) => {
throw error;
});
},
checkForm() {
......@@ -331,8 +328,6 @@ export default {
async postForm() {
if (!this.checkForm()) return;
// todo: check form
//let url = `${configuration.VUE_APP_DJANGO_API_BASE}projects/`;
const projectData = {
title: this.form.title,
description: this.form.description,
......@@ -371,11 +366,12 @@ export default {
)
.then((response) => {
if (response && response.status === 200) {
//* send thumbnail after feature_type was created
if (this.fileToImport)
//* send thumbnail after feature_type was updated
if (this.fileToImport.size > 0) {
this.postProjectThumbnail(this.project.slug);
} else {
this.goBackNrefresh(this.project.slug);
} else {
this.goBackNrefresh(this.project.slug);
}
}
})
.catch((error) => {
......
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