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

merge stash with previous branch

parent 5f7b96c3
No related branches found
No related tags found
No related merge requests found
import axios from 'axios';
import store from '../store'
const baseUrl = store.state.configuration.VUE_APP_DJANGO_API_BASE;
const featureAPI = {
async getFeatureAttachments(featureId) {
const response = await axios.get(
`${baseUrl}features/${featureId}/attachments/`
);
if (
response.status === 200 &&
response.data
) {
return response.data;
} else {
return null;
}
},
async postComment({ featureId, comment }) {
const response = await axios.get(
`${baseUrl}features/${featureId}/comments/`, { comment }
);
console.log(response)
if (
response.status === 200 &&
response.data
) {
return response.data;
} else {
return null;
}
},
/* async subscribeProject({ projectSlug, suscribe }) {
const response = await axios.put(
`${baseUrl}projects/${projectSlug}/subscription/`,
{ is_suscriber: suscribe }
);
if (
response.status === 200 &&
response.data
) {
return response.data;
} else {
return null;
}
}, */
}
export default featureAPI;
...@@ -274,11 +274,7 @@ ...@@ -274,11 +274,7 @@
method="POST" method="POST"
enctype="multipart/form-data" enctype="multipart/form-data"
> >
<!-- action="{% url 'geocontrib:add_comment' slug=feature.project.slug feature_type_slug=feature.feature_type.slug feature_id=feature.feature_id%}" --> <!-- <div
<!-- {% for hidden in comment_form.hidden_fields %}
{{ hidden }}
{% endfor %} -->
<div
v-if="comment_form.non_field_errors" v-if="comment_form.non_field_errors"
class="alert alert-danger" class="alert alert-danger"
role="alert" role="alert"
...@@ -286,7 +282,7 @@ ...@@ -286,7 +282,7 @@
<span v-for="error in comment_form.non_field_errors" :key="error"> <span v-for="error in comment_form.non_field_errors" :key="error">
{{ error }} {{ error }}
</span> </span>
</div> </div> -->
<div class="required field"> <div class="required field">
<label :for="comment_form.comment.id_for_label" <label :for="comment_form.comment.id_for_label"
>Ajouter un commentaire</label >Ajouter un commentaire</label
...@@ -309,7 +305,6 @@ ...@@ -309,7 +305,6 @@
: "Sélectionner un fichier ..." : "Sélectionner un fichier ..."
}}</span> }}</span>
</label> </label>
<!-- // todo : get image from "C:\\fakepath\..." -->
<input <input
type="file" type="file"
accept="application/pdf, image/jpeg, image/png" accept="application/pdf, image/jpeg, image/png"
...@@ -318,7 +313,7 @@ ...@@ -318,7 +313,7 @@
id="attachment_file" id="attachment_file"
@change="getAttachmentFileData($event)" @change="getAttachmentFileData($event)"
/> />
{{ comment_form.attachment_file.errors }} <!-- {{ comment_form.attachment_file.errors }} -->
</div> </div>
<div class="field"> <div class="field">
<input <input
...@@ -444,6 +439,10 @@ export default { ...@@ -444,6 +439,10 @@ export default {
computed: { computed: {
...mapState(["user"]), ...mapState(["user"]),
DJANGO_BASE_URL: function () {
return this.$store.state.configuration.VUE_APP_DJANGO_BASE;
},
feature: function () { feature: function () {
return ( return (
this.$store.state.feature.features.find( this.$store.state.feature.features.find(
...@@ -451,6 +450,7 @@ export default { ...@@ -451,6 +450,7 @@ export default {
) || [] ) || []
); );
}, },
linked_features: function () { linked_features: function () {
// todo: vérifier avec données réels si ça fonctionne correctement // todo: vérifier avec données réels si ça fonctionne correctement
//return this.mock_linked_features.filter((el) => el.feature_to); //return this.mock_linked_features.filter((el) => el.feature_to);
...@@ -460,14 +460,12 @@ export default { ...@@ -460,14 +460,12 @@ export default {
methods: { methods: {
postComment() { postComment() {
/* const data = { featureAPI.postComment({
featureId: this.$route.params.slug_signal,
comment: this.comment_form.comment.value, comment: this.comment_form.comment.value,
title: this.comment_form.title.value, });
attachment_file: this.comment_form.attachment_file.value,
}; */
this.$store.dispatch("feature/POST_COMMENT");
//console.log("POST comment", data);
}, },
getAttachmentFileData(evt) { getAttachmentFileData(evt) {
const files = evt.target.files || evt.dataTransfer.files; const files = evt.target.files || evt.dataTransfer.files;
const period = files[0].name.lastIndexOf("."); const period = files[0].name.lastIndexOf(".");
...@@ -477,12 +475,14 @@ export default { ...@@ -477,12 +475,14 @@ export default {
this.comment_form.attachment_file.value = shortName; this.comment_form.attachment_file.value = shortName;
this.comment_form.title.value = shortName; this.comment_form.title.value = shortName;
}, },
deleteFeature() { deleteFeature() {
this.$store.dispatch( this.$store.dispatch(
"feature/DELETE_FEATURE", "feature/DELETE_FEATURE",
this.$route.params.slug_signal this.$route.params.slug_signal
); );
}, },
initMap() { initMap() {
var mapDefaultViewCenter = var mapDefaultViewCenter =
this.$store.state.configuration.DEFAULT_MAP_VIEW.center; this.$store.state.configuration.DEFAULT_MAP_VIEW.center;
......
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