diff --git a/src/components/Projects/SearchProjects.vue b/src/components/Projects/SearchProjects.vue index 15136e994a26c71f81bd5f3bb27fb312b03993b7..25d04fdd463de612a0777e4173381a829c3aaa82 100644 --- a/src/components/Projects/SearchProjects.vue +++ b/src/components/Projects/SearchProjects.vue @@ -35,6 +35,9 @@ export default { this.searchFunction(newValue) .then(() => { this.$emit('loading', false); + }) + .catch((err) => { + if (err.message) this.$emit('loading', false); }); }, 100) }, diff --git a/src/store/index.js b/src/store/index.js index df23ac617d8949f73cefaedb30b23bb557d239c4..743b1431da014bb91434ae66fbe1eca1e14ffb4e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -181,7 +181,7 @@ export default new Vuex.Store({ USER_EVENTS({ commit }) { return new Promise((resolve, reject) => { axios - .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}events`) + .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}events/`) .then((response) => { if (response && response.status === 200) { const events = response.data; diff --git a/src/store/modules/projects.store.js b/src/store/modules/projects.store.js index 5b0bee8858d4d1ae74a249db702849683a665831..e6229cff4e35e2dcbae23a160ed0b9b517596226 100644 --- a/src/store/modules/projects.store.js +++ b/src/store/modules/projects.store.js @@ -153,25 +153,21 @@ const projects = { } } - try { - const response = await axios.get( - filteredUrl ? filteredUrl : url, - { - cancelToken: cancelToken.token, - } - ); - if (response.status === 200) { - const projects = response.data; - if (projects) { - commit('SET_PROJECTS', projects); - commit('SET_PROJECTS_SEARCH_STATE', { - isSearched: true, - text: text - }); - } + const response = await axios.get( + filteredUrl ? filteredUrl : url, + { + cancelToken: cancelToken.token, + } + ); + if (response.status === 200) { + const projects = response.data; + if (projects) { + commit('SET_PROJECTS', projects); + commit('SET_PROJECTS_SEARCH_STATE', { + isSearched: true, + text: text + }); } - } catch(err) { - console.error(err); } }, } diff --git a/src/views/My_account.vue b/src/views/My_account.vue index 0ee43939977e77a2e211d13643b07aa61a97de04..3d7b105b32684814ceeb5fe0130b28f234ba5f91 100644 --- a/src/views/My_account.vue +++ b/src/views/My_account.vue @@ -137,7 +137,10 @@ </div> </div> - <div class="row"> + <div + v-if="!isSharedProject" + class="row" + > <div class="fourteen wide column"> <div class="ui three stackable cards"> <div class="red card"> @@ -335,9 +338,12 @@ export default { return null; }, + isSharedProject() { + return this.$route.path.includes('projet-partage'); + }, + availableProjects() { - console.log(this.$route.path); - if (this.$route.path.includes('projet-partage')) { + if (this.isSharedProject) { return this.projects.filter((el) => el.slug === this.$route.params.slug); } return this.projects; @@ -368,7 +374,7 @@ export default { }, modifyUrl(url) { - if (this.$route.path.includes('projet-partage')) { + if (this.isSharedProject) { return url.replace('projet', 'projet-partage'); } return url; diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue index c20cb72cda4d07e4ce38d6bc4feaf87a428bf1f9..66892238a5562dec20c683ce3a47387cbfd99ce9 100644 --- a/src/views/feature/Feature_detail.vue +++ b/src/views/feature/Feature_detail.vue @@ -410,9 +410,7 @@ export default { data() { return { - isCanceling: false, attachments: [], - events: [], comment_form: { attachment_file: { errors: null, @@ -426,6 +424,9 @@ export default { value: null, }, }, + events: [], + isCanceling: false, + projectSlug: this.$route.params.slug, }; }, @@ -462,7 +463,7 @@ export default { isModerator() { return this.USER_LEVEL_PROJECTS && this.project && - this.USER_LEVEL_PROJECTS[this.project.slug] === 'Modérateur' + this.USER_LEVEL_PROJECTS[this.projectSlug] === 'Modérateur' ? true : false; }, diff --git a/src/views/feature/Feature_list.vue b/src/views/feature/Feature_list.vue index 8ae3c99ace67050fc7bfe1b01448f5bbe6b90ffd..ea80fcc80e132fd04b95f9328f8e30bd578ad7d4 100644 --- a/src/views/feature/Feature_list.vue +++ b/src/views/feature/Feature_list.vue @@ -258,6 +258,9 @@ export default { data() { return { + clickedFeatures: [], + currentLayer: null, + featuresCount: 0, form: { type: { selected: '', @@ -267,17 +270,13 @@ export default { }, title: null, }, - baseUrl: this.$store.state.configuration.BASE_URL, - clickedFeatures: [], - modalAllDeleteOpen: false, - mode: 'modify', - map: null, - zoom: null, lat: null, lng: null, - featuresCount: 0, + map: null, + modalAllDeleteOpen: false, + mode: 'modify', + next: null, paginatedFeatures: [], - currentLayer: null, pagination: { currentPage: 1, pagesize: 15, @@ -285,14 +284,15 @@ export default { end: 15, }, previous: null, - next: null, + projectSlug: this.$route.params.slug, + showMap: true, + showAddFeature: false, + showModifyStatus: false, sort: { column: '', ascending: true, }, - showMap: true, - showAddFeature: false, - showModifyStatus: false, + zoom: null, }; }, @@ -387,9 +387,9 @@ export default { mounted() { if (!this.project) { // Chargements des features et infos projet en cas d'arrivée directe sur la page ou de refresh - this.$store.dispatch('projects/GET_PROJECT', this.$route.params.slug); + this.$store.dispatch('projects/GET_PROJECT', this.projectSlug); this.$store - .dispatch('projects/GET_PROJECT_INFO', this.$route.params.slug) + .dispatch('projects/GET_PROJECT_INFO', this.projectSlug) .then(() => this.initMap()); } else { this.initMap(); @@ -441,7 +441,7 @@ export default { featureAPI.updateFeature({ feature_id, feature_type__slug: feature.feature_type, - project__slug: this.$route.params.slug, + project__slug: this.projectSlug, newStatus }).then((response) => { if (response && response.data && response.status === 200) { @@ -466,13 +466,13 @@ export default { }, deleteFeature(feature_id) { - const url = `${this.API_BASE_URL}features/${feature_id}/?project__slug=${this.project.slug}`; + const url = `${this.API_BASE_URL}features/${feature_id}/?project__slug=${this.projectSlug}`; axios //TODO: REFACTO -> Delete function already exist in store .delete(url, {}) .then(() => { if (!this.modalAllDeleteOpen) { this.GET_PROJECT_FEATURES({ - project_slug: this.$route.params.slug, + project_slug: this.projectSlug, }) .then(() => { this.fetchPagedFeatures(); @@ -533,11 +533,11 @@ export default { // --------- End sidebar events ---------- setTimeout(() => { - const project_id = this.$route.params.slug.split('-')[0]; + const project_id = this.projectSlug.split('-')[0]; const mvtUrl = `${this.API_BASE_URL}features.mvt/?tile={z}/{x}/{y}&project_id=${project_id}`; mapUtil.addVectorTileLayer( mvtUrl, - this.$route.params.slug, + this.projectSlug, this.feature_types, this.form ); @@ -547,7 +547,7 @@ export default { fetchBboxNfit(queryParams) { featureAPI - .getFeaturesBbox(this.project.slug, queryParams) + .getFeaturesBbox(this.projectSlug, queryParams) .then((bbox) => { if (bbox) { mapUtil.getMap().fitBounds(bbox, { padding: [25, 25] }); @@ -589,7 +589,7 @@ export default { fetchPagedFeatures(newUrl) { this.onFilterChange(); //* use paginated event to watch change in filters and modify features on map - let url = `${this.API_BASE_URL}projects/${this.$route.params.slug}/feature-paginated/?output=geojson&limit=${this.pagination.pagesize}&offset=${this.pagination.start}`; + let url = `${this.API_BASE_URL}projects/${this.projectSlug}/feature-paginated/?output=geojson&limit=${this.pagination.pagesize}&offset=${this.pagination.start}`; //* if receiving next & previous url if (newUrl && typeof newUrl === 'string') { //newUrl = newUrl.replace("8000", "8010"); //* for dev uncomment to use proxy link