diff --git a/src/components/feature/FeatureListTable.vue b/src/components/feature/FeatureListTable.vue index 64fa582cfdb713aaf1e7718f36548fde37273080..d0a0ad5a90ac960398790d161f4b7dae86dbae5b 100644 --- a/src/components/feature/FeatureListTable.vue +++ b/src/components/feature/FeatureListTable.vue @@ -344,7 +344,7 @@ export default { ...mapState('projects', ['project']), userStatus() { - return this.USER_LEVEL_PROJECTS[this.project.slug]; + return this.USER_LEVEL_PROJECTS[this.$route.params.slug]; }, checked: { diff --git a/src/store/modules/feature_type.store.js b/src/store/modules/feature_type.store.js index 524b9dc108bf9c373867ae3876ee2f3af0184fb3..3d59897f40e9d8450e52fcb76750a5aad1e7d630 100644 --- a/src/store/modules/feature_type.store.js +++ b/src/store/modules/feature_type.store.js @@ -171,7 +171,8 @@ const feature_type = { if(!geojson && !state.fileToImport && state.fileToImport.size === 0 ) return; let formData = new FormData(); let fileToImport; - const { name, type } = geojson || state.fileToImport; + let { name, type } = geojson || state.fileToImport; + if (!name && state.fileToImport) name = state.fileToImport.name; if (rootState.projects.project.moderation) { if (state.fileToImport && state.fileToImport.size > 0) { //* if data in a binary file, read it as text diff --git a/src/views/feature/Feature_list.vue b/src/views/feature/Feature_list.vue index 4b3cb1edce87417de89a2ab2961ade7ae123c113..8aea781df598b2b7c475045e7b4c48bdd6004e96 100644 --- a/src/views/feature/Feature_list.vue +++ b/src/views/feature/Feature_list.vue @@ -470,45 +470,37 @@ export default { }, async modifyStatus(newStatus) { - let errorCount = 0; - const promises = this.checkedFeatures.map((feature_id) => { + if (this.checkedFeatures.length > 0) { + const feature_id = this.checkedFeatures[0]; let feature = this.clickedFeatures.find((el) => el.feature_id === feature_id); if (feature) { - return featureAPI.updateFeature({ + featureAPI.updateFeature({ feature_id, feature_type__slug: feature.feature_type, - project__slug: this.$route.params.slug, newStatus + project__slug: this.$route.params.slug, + newStatus + }).then((response) => { + if (response && response.data && response.status === 200) { + this.checkedFeatures.splice(this.checkedFeatures.indexOf(response.data.id), 1); + this.modifyStatus(newStatus); + } else { + this.$store.commit('DISPLAY_MESSAGE', { + comment: `Le signalement ${feature.title} n'a pas pu être modifié`, + level: 'negative' + }); + this.fetchPagedFeatures(); + } }); - } else { - errorCount += 1; - } - }); - const promisesResult = await Promise.all(promises); - promisesResult.forEach((response) => { - if (response && response.data && response.status === 200) { - this.checkedFeatures.splice(this.checkedFeatures.indexOf(response.data.id), 2); - } else { - errorCount += 1; - } - }); - let message = { - comment: 'Tous les signalements ont été modifié avec succès.', - level: 'positive' - }; - if (errorCount) { - //* display error message - if(errorCount === 1) { - message.comment = "Un signalement n'a pas pu être modifié. (Il reste sélectionné)"; - } else { - message.comment = `${errorCount} signalements n'ont pas pu être modifiés. (Ils restent sélectionnés)`; } - message.level = 'negative'; + } else { + this.fetchPagedFeatures(); + this.$store.commit('DISPLAY_MESSAGE', { + comment: 'Tous les signalements ont été modifié avec succès.', + level: 'positive' + }); } - this.fetchPagedFeatures(); - this.$store.commit('DISPLAY_MESSAGE', message); }, - deleteFeature(feature_id) { const url = `${this.API_BASE_URL}features/${feature_id}/?project__slug=${this.project.slug}`; axios //TODO: REFACTO -> Delete function already exist in store diff --git a/src/views/feature_type/Feature_type_edit.vue b/src/views/feature_type/Feature_type_edit.vue index 8ac0cad69c047f6b4363df60364c247cadf4f016..2e510c8c1181174a437c487a9850ab9f92f6be12 100644 --- a/src/views/feature_type/Feature_type_edit.vue +++ b/src/views/feature_type/Feature_type_edit.vue @@ -399,7 +399,7 @@ export default { this.importGeoJsonFeatureType(); if (this.fileToImport && this.fileToImport.name) { this.form.title.value = // * use the filename as title by default - this.fileToImport.name.split('.')[0]; + this.fileToImport.name.split('.')[0]; } else { //* case when the geojson comes from datasud catalog this.form.title.value = this.geojson.name;// * use the typename as title by default }