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

Merge branch 'redmine-issues/12433' into 'develop'

parents 7d35beab e8012cb9
Branches
Tags
No related merge requests found
......@@ -510,7 +510,7 @@
<div class="content">
<button
@click="subsribeProject"
@click="subscribeProject"
:class="['ui compact fluid button', is_suscriber ? 'red' : 'green']"
>
{{
......@@ -576,9 +576,12 @@ export default {
DJANGO_BASE_URL() {
return this.$store.state.configuration.VUE_APP_DJANGO_BASE;
},
API_BASE_URL() {
return this.$store.state.configuration.VUE_APP_DJANGO_API_BASE;
},
last_features() {
// * limit to last five element of array (looks sorted chronologically, but not sure...)
return this.$store.state.feature.features.slice(-5);
return this.features.slice(-5);
},
},
......@@ -586,9 +589,11 @@ export default {
refreshId() {
return "?ver=" + Math.random();
},
isOffline() {
return navigator.onLine === false;
},
checkForOfflineFeature() {
let arraysOffline = [];
let localStorageArray = localStorage.getItem("geocontrib_offline");
......@@ -599,6 +604,7 @@ export default {
);
}
},
sendOfflineFeatures() {
var promises = [];
this.arraysOffline.forEach((feature, index, object) => {
......@@ -606,10 +612,7 @@ export default {
if (feature.type === "post") {
promises.push(
axios
.post(
`${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features/`,
feature.geojson
)
.post(`${this.API_BASE_URL}features/`, feature.geojson)
.then((response) => {
console.log(response);
if (response.status === 201 && response.data) {
......@@ -624,7 +627,7 @@ export default {
promises.push(
axios
.put(
`${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features/${feature.featureId}`,
`${this.API_BASE_URL}features/${feature.featureId}`,
feature.geojson
)
.then((response) => {
......@@ -644,6 +647,7 @@ export default {
window.location.reload();
});
},
updateLocalStorage() {
let arraysOffline = [];
let localStorageArray = localStorage.getItem("geocontrib_offline");
......@@ -656,6 +660,7 @@ export default {
arraysOffline = arraysOfflineOtherProject.concat(this.arraysOffline);
localStorage.setItem("geocontrib_offline", JSON.stringify(arraysOffline));
},
toNewFeatureType() {
this.$router.push({
name: "ajouter-type-signalement",
......@@ -686,8 +691,7 @@ export default {
}
},
subsribeProject() {
this.$store.state.configuration.VUE_APP_DJANGO_API_BASE;
subscribeProject() {
projectAPI
.subscribeProject({
suscribe: !this.is_suscriber,
......@@ -707,11 +711,11 @@ export default {
},
initMap() {
if (this.project && this.permissions.can_view_project) {
this.$store.dispatch("map/INITIATE_MAP", this.$refs.map);
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`;
this.$store.dispatch("map/INITIATE_MAP");
const url = `${this.API_BASE_URL}projects/${this.$route.params.slug}/feature/?output=geojson`;
this.checkForOfflineFeature();
let project_id = this.$route.params.slug.split("-")[0];
const mvtUrl = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features.mvt/?tile={z}/{x}/{y}&project_id=${project_id}`;
const mvtUrl = `${this.API_BASE_URL}features.mvt/?tile={z}/{x}/{y}&project_id=${project_id}`;
mapUtil.addVectorTileLayer(
mvtUrl,
this.$route.params.slug,
......@@ -760,10 +764,9 @@ export default {
},
mounted() {
this.$store.dispatch("GET_PROJECT_INFO", this.slug).then(() => {
this.featureTypeLoading = false;
setTimeout(this.initMap, 1000);
});
this.$store
.dispatch("GET_PROJECT_INFO", this.slug)
.then(() => setTimeout(this.initMap, 1000));
if (this.message) {
this.tempMessage = this.message;
document
......
......
......@@ -409,52 +409,50 @@ export default {
is_project_type: this.form.is_project_type,
moderation: this.form.moderation,
};
let url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/`;
if (this.action === "create" || this.action === "create_from") {
this.loading = true;
if (this.action === "edit") {
await axios
.post(
`${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/`,
projectData
)
.put((url += `${this.project.slug}/`), projectData)
.then((response) => {
if (response && response.status === 201 && response.data) {
//* send thumbnail after feature_type was created
if (response && response.status === 200) {
//* send thumbnail after feature_type was updated
if (this.fileToImport.size > 0) {
this.postProjectThumbnail(response.data.slug);
this.postProjectThumbnail(this.project.slug);
} else {
this.goBackNrefresh(response.data.slug);
this.goBackNrefresh(this.project.slug);
}
}
this.loading = false;
})
.catch((error) => {
if (error.response && error.response.data.title[0]) {
this.errors.title.push(error.response.data.title[0]);
}
this.loading = false;
throw error;
});
} else if (this.action === "edit") {
} else {
if (this.action === "create_from") {
url += `${this.project.slug}/duplicate/`;
}
this.loading = true;
await axios
.put(
`${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.project.slug}/`,
projectData
)
.post(url, projectData)
.then((response) => {
if (response && response.status === 200) {
//* send thumbnail after feature_type was updated
if (response && response.status === 201 && response.data) {
//* send thumbnail after feature_type was created
if (this.fileToImport.size > 0) {
this.postProjectThumbnail(this.project.slug);
this.postProjectThumbnail(response.data.slug);
} else {
this.goBackNrefresh(this.project.slug);
this.goBackNrefresh(response.data.slug);
}
}
this.loading = false;
})
.catch((error) => {
if (error.response && error.response.data.title[0]) {
this.errors.title.push(error.response.data.title[0]);
}
this.loading = false;
throw error;
});
}
......@@ -484,13 +482,13 @@ export default {
this.form.access_level_pub_feature = {
name: this.project.access_level_pub_feature,
value: this.levelPermissions.find(
(el) => (el.name === this.project.access_level_pub_feature)
(el) => el.name === this.project.access_level_pub_feature
).value,
};
this.form.access_level_arch_feature = {
name: this.project.access_level_arch_feature,
value: this.levelPermissions.find(
(el) => (el.name === this.project.access_level_arch_feature)
(el) => el.name === this.project.access_level_arch_feature
).value,
};
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment