diff --git a/package-lock.json b/package-lock.json index 5c65244599ec38ec18636b5cfef2ee74c1468351..b97b5e1ccb5cd3bb97abdb38ecd4be6de9711e06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "geocontrib-frontend", - "version": "2.2.0", + "version": "2.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1795,6 +1795,87 @@ "webpack-chain": "^6.4.0", "webpack-dev-server": "^3.11.0", "webpack-merge": "^4.2.2" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "optional": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "optional": true + }, + "loader-utils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz", + "integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==", + "dev": true, + "optional": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "optional": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "vue-loader-v16": { + "version": "npm:vue-loader@16.8.3", + "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz", + "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==", + "dev": true, + "optional": true, + "requires": { + "chalk": "^4.1.0", + "hash-sum": "^2.0.0", + "loader-utils": "^2.0.0" + } + } } }, "@vue/cli-shared-utils": { @@ -11511,87 +11592,6 @@ } } }, - "vue-loader-v16": { - "version": "npm:vue-loader@16.8.1", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.1.tgz", - "integrity": "sha512-V53TJbHmzjBhCG5OYI2JWy/aYDspz4oVHKxS43Iy212GjGIG1T3EsB3+GWXFm/1z5VwjdjLmdZUFYM70y77vtQ==", - "dev": true, - "optional": true, - "requires": { - "chalk": "^4.1.0", - "hash-sum": "^2.0.0", - "loader-utils": "^2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "optional": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "optional": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "optional": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "optional": true - }, - "loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", - "dev": true, - "optional": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "optional": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "vue-multiselect": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/vue-multiselect/-/vue-multiselect-2.1.6.tgz", diff --git a/src/assets/js/map-util.js b/src/assets/js/map-util.js index 10535ded16b11cdcfff46c84a9313c101265f0d2..b66c3c1eb7b43871b1a48c2e3a42f72b5d8d13b4 100644 --- a/src/assets/js/map-util.js +++ b/src/assets/js/map-util.js @@ -297,9 +297,10 @@ const mapUtil = { }, retrieveFeatureColor: function (featureType, properties) { - if (featureType && featureType.colors_style && featureType.colors_style.custom_field_name) { - const currentValue = properties[featureType.colors_style.custom_field_name]; - const colorStyle = featureType.colors_style.colors[currentValue]; + const colorsStyle = featureType.colors_style.value ? featureType.colors_style.value : featureType.colors_style; + if (featureType && colorsStyle && colorsStyle.custom_field_name) { + const currentValue = properties[colorsStyle.custom_field_name]; + const colorStyle = colorsStyle.colors[currentValue]; return colorStyle ? colorStyle : featureType.color } else{ @@ -373,48 +374,44 @@ const mapUtil = { const featureGroup = new L.FeatureGroup(); features.forEach((feature) => { - const featureType = featureTypes.find((ft) => ft.slug === (feature.properties.feature_type.slug || feature.properties.feature_type)); + const featureProperties = feature.properties ? feature.properties : feature; + const featureType = featureTypes.find((ft) => ft.slug === (featureProperties.feature_type.slug || featureProperties.feature_type)); let filters = []; if (filter) { - const typeCheck = filter.featureType && feature.properties.feature_type.slug === filter.featureType; - const statusCheck = filter.featureStatus && feature.properties.status.value === filter.featureStatus; - const titleCheck = filter.featureTitle && feature.properties.title.includes(filter.featureTitle); + const typeCheck = filter.featureType && featureProperties.feature_type.slug === filter.featureType; + const statusCheck = filter.featureStatus && featureProperties.status.value === filter.featureStatus; + const titleCheck = filter.featureTitle && featureProperties.title.includes(filter.featureTitle); filters = [typeCheck, statusCheck, titleCheck]; } - if (!filter || !Object.values(filter).some(val => val) || Object.values(filter).some(val => val) && filters.length && filters.every(val => val !== false)) { - const geomJSON = flip(feature.geometry); + if ( + !filter || + !Object.values(filter).some(val => val) || + Object.values(filter).some(val => val) && + filters.length && filters.every(val => val !== false) + ) { + const geomJSON = flip(feature.geometry || feature.geom); const popupContent = this._createContentPopup(feature); // Look for a custom field let customField; let customFieldOption; - if (featureType.customfield_set && Object.keys(feature.properties).some(el => featureType.customfield_set.map(e => e.name).includes(el))) { - customField = Object.keys(feature.properties).filter(el => featureType.customfield_set.map(e => e.name).includes(el)); - customFieldOption = feature.properties[customField[0]]; + if (featureType.customfield_set && Object.keys(featureProperties).some(el => featureType.customfield_set.map(e => e.name).includes(el))) { + customField = Object.keys(featureProperties).filter(el => featureType.customfield_set.map(e => e.name).includes(el)); + customFieldOption = featureProperties[customField[0]]; } - let color = this.retrieveFeatureColor(featureType, feature.properties) || feature.properties.color; - - // if (!color && customFieldOption && featureType.colors_style) { - // color = - // featureType.colors_style.value ? - // featureType.colors_style.value.colors[customFieldOption].value ? - // featureType.colors_style.value.colors[customFieldOption].value : - // featureType.colors_style.value.colors[customFieldOption] : - // featureType.colors_style.colors[customFieldOption] - // } else { - // color = feature.properties.color; - // } + let color = this.retrieveFeatureColor(featureType, featureProperties) || featureProperties.color; if (color == undefined){ color = featureType.color; } + const colorValue = color.value ? color.value : color; if (geomJSON.type === 'Point') { if (customFieldOption && featureType.colors_style && featureType.colors_style.value && featureType.colors_style.value.icons) { const iconHTML = ` <i class="fas fa-${featureType.colors_style.value.icons[customFieldOption]} fa-2x" - style="color: ${color}" + style="color: ${colorValue}" ></i> `; const customMapIcon = L.divIcon({ @@ -424,14 +421,14 @@ const mapUtil = { }); L.marker(geomJSON.coordinates, { icon: customMapIcon, - color: color, + color: colorValue, zIndexOffset: 100 }) .bindPopup(popupContent) .addTo(featureGroup); } else { L.circleMarker(geomJSON.coordinates, { - color: color, + color: colorValue, radius: 4, fillOpacity: 0.5, weight: 3, @@ -441,14 +438,14 @@ const mapUtil = { } } else if (geomJSON.type === 'LineString') { L.polyline(geomJSON.coordinates, { - color: color, + color: colorValue, weight: 3, }) .bindPopup(popupContent) .addTo(featureGroup); } else if (geomJSON.type === 'Polygon') { L.polygon(geomJSON.coordinates, { - color: color, + color: colorValue, weight: 3, fillOpacity: 0.5, }) @@ -457,7 +454,7 @@ const mapUtil = { } } }); - if (addToMap) { + if (map && addToMap) { map.addLayer(featureGroup); } @@ -474,10 +471,23 @@ const mapUtil = { return formatted_date; } let feature_type; - let status = feature.properties.status; - let date_maj = feature.properties.updated_on; - let feature_type_url = feature.properties.feature_type_url; - let feature_url = feature.properties.feature_url; + let status; + let date_maj; + let feature_type_url; + let feature_url; + + if (feature.properties) { + status = feature.properties.status; + date_maj = feature.properties.updated_on; + feature_type_url = feature.properties.feature_type_url; + feature_url = feature.properties.feature_url; + } else { + status = feature.status; + date_maj = feature.updated_on; + feature_type_url =feature.feature_type_url; + feature_url = feature.feature_url; + } + if (featureTypes) { // => VectorTile feature_type = featureTypes.find((x) => x.slug.split('-')[0] === '' + feature.properties.feature_type_id); status = statusList.find((x) => x.value === feature.properties.status).name; @@ -486,22 +496,24 @@ const mapUtil = { feature_url = feature_type_url + 'signalement/' + feature.properties.feature_id + '/'; //status=feature.properties.status; } else { - feature_type = feature.properties.feature_type; - status = feature.properties.status.label; + feature_type = feature.properties ? feature.properties.feature_type : feature.feature_type; + status = feature.properties ? feature.properties.status.label : feature.status.label; } - let author = ""; - if (feature.properties.creator) { - author = feature.properties.creator.full_name + let author = ''; + const creator = feature.properties ? feature.properties.creator : feature.creator + if (creator) { + author = creator.full_name ? `<div> - Auteur : ${feature.properties.creator.first_name} ${feature.properties.creator.last_name} + Auteur : ${creator.first_name} ${creator.last_name} </div>` - : feature.properties.creator.username ? `<div>Auteur: ${feature.properties.creator.username}</div>` : ''; + : creator.username ? `<div>Auteur: ${creator.username}</div>` : ''; } + const title = feature.properties ? feature.properties.title : feature.title; return ` <h4> - <a href="${feature_url}">${feature.properties.title}</a> + <a href="${feature_url}">${title}</a> </h4> <div> Statut : ${status} diff --git a/src/components/feature_type/SymbologySelector.vue b/src/components/feature_type/SymbologySelector.vue index 7e730930a5b193d63e737131ce32735c825e764c..cd3c2409e6c8a375c139fd075818b7c58b25aa56 100644 --- a/src/components/feature_type/SymbologySelector.vue +++ b/src/components/feature_type/SymbologySelector.vue @@ -23,7 +23,7 @@ > <font-awesome-icon :icon="['fas', form.icon]" - :style="{ color: form.color.value }" + :style="{ color: form.color.value || '#000000' }" class="icon alt" /> </button> @@ -161,7 +161,6 @@ export default { border-radius: 3px; box-shadow: 0 0 2px 1px rgb(131, 131, 131); .icon.alt { - color: rgb(75, 75, 75); width: 30px; height: 30px; } diff --git a/src/store/modules/feature.js b/src/store/modules/feature.js index 3cc1c1b9ffdb24f9b1d9bf25e160b14b72ffde78..7d42ef515fa16c814ea1aede68311d54b46ff486 100644 --- a/src/store/modules/feature.js +++ b/src/store/modules/feature.js @@ -129,6 +129,7 @@ const feature = { if (limit) { url = url.concat('', `${url.includes('?') ? '&' : '?'}limit=${limit}`); } + url = url.concat('', '&output=geojson'); return axios .get(url, { cancelToken: cancelToken.token }) .then((response) => { @@ -338,7 +339,6 @@ const feature = { .delete(url) .then((response) => { if (response && response.status === 204) { - console.log(response) commit("REMOVE_ATTACHMENTS_ID_TO_DELETE", payload.attachmentsId) return response } @@ -354,7 +354,6 @@ const feature = { .put(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${featureId}/feature-links/`, state.linkedFormset) .then((response) => { if (response.status === 200 && response.data) { - console.log(response, response.data) return "La relation a bien été ajouté" } }) @@ -363,8 +362,7 @@ const feature = { }); }, - DELETE_FEATURE({ state, rootState }, feature_id) { - console.log("Deleting feature:", feature_id, state) + DELETE_FEATURE({ rootState }, feature_id) { const url = `${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${feature_id}/?` + `feature_type__slug=${rootState.feature_type.current_feature_type_slug}` + `&project__slug=${rootState.project_slug}`; diff --git a/src/store/modules/map.js b/src/store/modules/map.js index b9843087d53556c34c8fd0b7831b5e4560755305..57ae63836919b88664930870cdbfe96b7d83034f 100644 --- a/src/store/modules/map.js +++ b/src/store/modules/map.js @@ -11,6 +11,7 @@ import { mapUtil } from "@/assets/js/map-util.js"; const map = { namespaced: true, state: { + map: null, basemaps: null, basemapsToDelete: [], features: [], @@ -18,6 +19,9 @@ const map = { availableLayers: null, }, mutations: { + SET_MAP(state, payload) { + state.map = payload; + }, SET_LAYERS(state, availableLayers) { state.availableLayers = availableLayers; }, @@ -110,7 +114,7 @@ const map = { }); }, - INITIATE_MAP({ state, rootGetters }, el) { + INITIATE_MAP({ state, rootGetters, commit }, el) { const project = rootGetters.project let mapDefaultViewCenter = [46, 2]; // defaultMapView.center; let mapDefaultViewZoom = 5; // defaultMapView.zoom; @@ -118,6 +122,7 @@ const map = { mapDefaultViewCenter, mapDefaultViewZoom, }); + commit('SET_MAP', mapUtil.getMap()); // Load the layers. // - if one basemap exists, check in the localstorage if one active basemap is set diff --git a/src/views/feature/Feature_edit.vue b/src/views/feature/Feature_edit.vue index 12342f42377c8481ded3fa19b53a25c36a31e6bc..62230a8ad09640c59bce137bb9c811e6f2ce1469 100644 --- a/src/views/feature/Feature_edit.vue +++ b/src/views/feature/Feature_edit.vue @@ -539,7 +539,7 @@ export default { }) .catch((error) => { - console.log({ error }); + console.error({ error }); if (error && error.response && error.response) { this.erreurUploadMessage = error.response.data.error; } else { @@ -575,7 +575,6 @@ export default { }, addAttachment(attachment) { - console.log(attachment); this.$store.commit("feature/ADD_ATTACHMENT_FORM", { dataKey: this.attachmentDataKey, title: attachment.title, diff --git a/src/views/feature/Feature_list.vue b/src/views/feature/Feature_list.vue index c31ad0879058b2a0a117cd71012851e6df2bb8c3..cdceee6da1d67c9929bd61db6ac3e6d0ce34bfb3 100644 --- a/src/views/feature/Feature_list.vue +++ b/src/views/feature/Feature_list.vue @@ -235,6 +235,7 @@ export default { lng: null, featuresCount: 0, paginatedFeatures: [], + currentLayer: null, pagination: { currentPage: 1, pagesize: 15, @@ -259,13 +260,56 @@ export default { "form.status.selected.value"() { this.fetchPagedFeatures(); }, + map(newValue) { + if (newValue && this.paginatedFeatures && this.paginatedFeatures.length) { + if (this.currentLayer) { + this.map.removeLayer(this.currentLayer); + } + this.currentLayer = mapUtil.addFeatures( + this.paginatedFeatures, + {}, + true, + this.feature_types + ); + } + }, + paginatedFeatures: { + deep: true, + handler(newValue, oldValue) { + if (newValue && newValue.length && newValue !== oldValue && this.map) { + if (this.currentLayer) { + this.map.removeLayer(this.currentLayer); + this.currentLayer = null; + } + this.currentLayer = mapUtil.addFeatures( + newValue, + {}, + true, + this.feature_types + ); + } else if (newValue && newValue.length === 0) { + if (this.currentLayer) { + this.map.removeLayer(this.currentLayer); + this.currentLayer = null; + } + } + } + } }, computed: { - ...mapGetters(["project", "permissions"]), - ...mapState("feature", ["checkedFeatures"]), - ...mapState("feature_type", ["feature_types"]), - ...mapState("map", ["basemaps"]), + ...mapGetters([ + 'project', 'permissions' + ]), + ...mapState('feature', [ + 'checkedFeatures' + ]), + ...mapState('feature_type', [ + 'feature_types' + ]), + ...mapState('map', [ + 'basemaps' + ]), API_BASE_URL() { return this.$store.state.configuration.VUE_APP_DJANGO_API_BASE; @@ -421,23 +465,25 @@ export default { url = newUrl; } const queryString = this.buildQueryString(); + console.log(queryString); url += queryString; this.$store.commit( "DISPLAY_LOADER", "Récupération des signalements en cours..." ); - featureAPI.getPaginatedFeatures(url).then((data) => { - if (data) { - this.featuresCount = data.count; - this.previous = data.previous; - this.next = data.next; - this.paginatedFeatures = data.results.features; - } - //* bbox needs to be updated with the same filters - if (queryString) this.fetchBboxNfit(queryString); - this.$store.commit("DISCARD_LOADER"); - }); + featureAPI.getPaginatedFeatures(url) + .then((data) => { + if (data) { + this.featuresCount = data.count; + this.previous = data.previous; + this.next = data.next; + this.paginatedFeatures = data.results.features; + } + //* bbox needs to be updated with the same filters + if (this.paginatedFeatures.length) this.fetchBboxNfit(queryString); + this.$store.commit("DISCARD_LOADER"); + }); }, //* Pagination for table *// diff --git a/src/views/feature_type/Feature_type_symbology.vue b/src/views/feature_type/Feature_type_symbology.vue index 67d0c7efa1956e69ced868544e0cc3702da6071f..b3c3b37f4b3380d412d9a9c8411177127b7e0a14 100644 --- a/src/views/feature_type/Feature_type_symbology.vue +++ b/src/views/feature_type/Feature_type_symbology.vue @@ -5,7 +5,14 @@ </div> <div id="message" class="fullwidth"> <div v-if="error" class="ui negative message"> - <p><i class="cross icon"></i> {{ error }}</p> + <p><i class="close icon"></i> {{ error }}</p> + </div> + <div v-if="success" class="ui positive message"> + <i + class="close icon" + @click="success = null" + /> + <p>{{ success }}</p> </div> </div> <div class="fourteen wide column"> @@ -61,10 +68,16 @@ > <SymbologySelector :title="option" - :initColor="feature_type.colors_style.value.colors[option] ? - feature_type.colors_style.value.colors[option].value : - feature_type.colors_style.value.colors[option]" - :initIcon="feature_type.colors_style.value.icons[option]" + :initColor="feature_type.colors_style.value ? + feature_type.colors_style.value.colors[option] ? + feature_type.colors_style.value.colors[option].value : + feature_type.colors_style.value.colors[option] + : null + " + :initIcon="feature_type.colors_style.value ? + feature_type.colors_style.value.icons[option] : + null + " :geomType="feature_type.customfield_set.geomType" @set="setColorsStyle" /> @@ -106,6 +119,7 @@ export default { return { loading: false, error: null, + success: null, selectedCustomfield: null, form: { color: '#000000', @@ -174,10 +188,11 @@ export default { this.SEND_FEATURE_SYMBOLOGY(this.form) .then(() => { this.loading = false; + this.success = 'La modification de la symbologie a été prise en compte.' }) .catch(() => { this.loading = false; - }) + }); } } } diff --git a/src/views/project/Project_detail.vue b/src/views/project/Project_detail.vue index 0b65164ca8331b3de91a551c4cba825a69f955ea..f284036ef0bd1236bb247ab9a9d5429170fd316b 100644 --- a/src/views/project/Project_detail.vue +++ b/src/views/project/Project_detail.vue @@ -367,7 +367,7 @@ <div class="ui relaxed list"> <div v-for="(item, index) in features" - :key="item.title + index" + :key="item.properties.title + index" class="item" > <div class="content"> @@ -377,21 +377,27 @@ name: 'details-signalement', params: { slug: project.slug, - slug_type_signal: item.feature_type.slug, - slug_signal: item.feature_id, + slug_type_signal: item.properties.feature_type.slug, + slug_signal: item.id, }, }" - >{{ item.title || item.feature_id }}</router-link + >{{ item.properties.title || item.id }}</router-link > </div> <div class="description"> - <i - >[{{ item.created_on | setDate - }}<span v-if="user && item.display_creator" - >, par {{ item.display_creator }} + <i> + [{{ item.properties.created_on}} + <span + v-if="user && item.properties.creator" + > + , par {{ + item.properties.creator.full_name ? + item.properties.creator.full_name : + item.properties.creator.username + }} </span> - ]</i - > + ] + </i> </div> </div> </div> @@ -658,6 +664,9 @@ export default { 'user', 'reloadIntervalId' ]), + ...mapState('map', [ + 'map' + ]), DJANGO_BASE_URL() { return this.$store.state.configuration.VUE_APP_DJANGO_BASE; }, @@ -670,6 +679,30 @@ export default { }, watch: { + map(newValue) { + if (newValue && this.features && this.features.length) { + mapUtil.addFeatures( + this.features, + {}, + true, + this.feature_types + ); + } + }, + features: { + deep: true, + handler(newValue, oldValue) { + if (newValue && newValue.length && newValue !== oldValue && this.map) { + mapUtil.addFeatures( + newValue, + {}, + true, + this.feature_types + ); + } + } + }, + feature_types: { deep: true, handler(newValue, oldValue) { @@ -748,7 +781,6 @@ export default { let self = this; this.arraysOfflineErrors = []; this.arraysOffline.forEach((feature) => { - console.log(feature); if (feature.type === "post") { promises.push( axios @@ -762,7 +794,7 @@ export default { } }) .catch((error) => { - console.log(error); + console.error(error); self.arraysOfflineErrors.push(feature); }) ); @@ -774,7 +806,6 @@ export default { feature.geojson ) .then((response) => { - console.log(response); if (response.status === 200 && response.data) { return "OK" } @@ -783,7 +814,7 @@ export default { } }) .catch((error) => { - console.log(error); + console.error(error); self.arraysOfflineErrors.push(feature); }) ); @@ -886,7 +917,6 @@ export default { this.$route.params.slug, this.$store.state.feature_type.feature_types ); - this.arraysOffline.forEach((x) => (x.geojson.properties.color = "red")); const features = this.arraysOffline.map((x) => x.geojson); mapUtil.addFeatures( diff --git a/src/views/project/Project_mapping.vue b/src/views/project/Project_mapping.vue index 34397ecb7b5f37acb1814dac5b3e6236cb799654..7ab8de8b85ed98b6d09f9a00100cfb7e8180b97b 100644 --- a/src/views/project/Project_mapping.vue +++ b/src/views/project/Project_mapping.vue @@ -87,7 +87,6 @@ export default { checkTitles() { let isValid = true; this.basemaps.forEach((basemap) => { - console.log(basemap); if (basemap.title === null || basemap.title === "") { basemap.errors = "Veuillez compléter ce champ."; isValid = false; @@ -134,7 +133,7 @@ export default { ); }) .catch((error) => { - console.log(error); + console.error(error); }); } },