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 @@
method="POST"
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%}" -->
<!-- {% for hidden in comment_form.hidden_fields %}
{{ hidden }}
{% endfor %} -->
<div
<!-- <div
v-if="comment_form.non_field_errors"
class="alert alert-danger"
role="alert"
......@@ -286,7 +282,7 @@
<span v-for="error in comment_form.non_field_errors" :key="error">
{{ error }}
</span>
</div>
</div> -->
<div class="required field">
<label :for="comment_form.comment.id_for_label"
>Ajouter un commentaire</label
......@@ -309,7 +305,6 @@
: "Sélectionner un fichier ..."
}}</span>
</label>
<!-- // todo : get image from "C:\\fakepath\..." -->
<input
type="file"
accept="application/pdf, image/jpeg, image/png"
......@@ -318,7 +313,7 @@
id="attachment_file"
@change="getAttachmentFileData($event)"
/>
{{ comment_form.attachment_file.errors }}
<!-- {{ comment_form.attachment_file.errors }} -->
</div>
<div class="field">
<input
......@@ -444,6 +439,10 @@ export default {
computed: {
...mapState(["user"]),
DJANGO_BASE_URL: function () {
return this.$store.state.configuration.VUE_APP_DJANGO_BASE;
},
feature: function () {
return (
this.$store.state.feature.features.find(
......@@ -451,6 +450,7 @@ export default {
) || []
);
},
linked_features: function () {
// todo: vérifier avec données réels si ça fonctionne correctement
//return this.mock_linked_features.filter((el) => el.feature_to);
......@@ -460,14 +460,12 @@ export default {
methods: {
postComment() {
/* const data = {
featureAPI.postComment({
featureId: this.$route.params.slug_signal,
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) {
const files = evt.target.files || evt.dataTransfer.files;
const period = files[0].name.lastIndexOf(".");
......@@ -477,12 +475,14 @@ export default {
this.comment_form.attachment_file.value = shortName;
this.comment_form.title.value = shortName;
},
deleteFeature() {
this.$store.dispatch(
"feature/DELETE_FEATURE",
this.$route.params.slug_signal
);
},
initMap() {
var mapDefaultViewCenter =
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