diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue index 6e8b2789d5a2107271ca6cd361e02c6e49c50e23..2ee8f4ce89f9546099471b08a918414d84b65e1e 100644 --- a/src/views/feature/Feature_detail.vue +++ b/src/views/feature/Feature_detail.vue @@ -8,7 +8,7 @@ {{ feature.title || feature.feature_id }} <div class="ui icon right floated compact buttons"> <router-link - v-if="permissions.can_create_feature" + v-if="permissions && permissions.can_create_feature" :to="{ name: 'ajouter-signalement', params: { @@ -22,7 +22,7 @@ <i class="plus fitted icon"></i> </router-link> <router-link - v-if="permissions.can_update_feature" + v-if="permissions && permissions.can_update_feature" :to="{ name: 'editer-signalement', params: { @@ -35,7 +35,7 @@ <i class="inverted grey pencil alternate icon"></i> </router-link> <a - v-if="permissions.can_delete_feature" + v-if="permissions && permissions.can_delete_feature" @click="isCanceling = true" id="feature-delete" class="ui button button-hover-red" @@ -147,10 +147,13 @@ v-for="(link, index) in linked_features" :key="link.feature_to.title + index" > - <td> + <td v-if="link.feature_to.feature_type_slug"> {{ link.relation_type_display }} - <router-link - v-if="link.feature_to.feature_type_slug" + <a @click="pushNgo(link)">{{ link.feature_to.title }} </a> + ({{ link.feature_to.display_creator }} - + {{ link.feature_to.created_on }}) + <!-- <router-link + :key="$route.fullPath" :to="{ name: 'details-signalement', params: { @@ -162,6 +165,7 @@ > ({{ link.feature_to.display_creator }} - {{ link.feature_to.created_on }}) + --> </td> </tr> </tbody> @@ -267,7 +271,10 @@ </div> </div> - <div v-if="permissions.can_create_feature" class="ui segment"> + <div + v-if="permissions && permissions.can_create_feature" + class="ui segment" + > <form id="form-comment" class="ui form" @@ -416,13 +423,31 @@ export default { }, feature: function () { - return this.$store.state.feature.features.find( + const result = this.$store.state.feature.features.find( (el) => el.feature_id === this.$route.params.slug_signal ); + console.log("result", result); + return result; }, }, methods: { + pushNgo(link) { + this.$router.push({ + name: "details-signalement", + params: { + slug_type_signal: link.feature_to.feature_type_slug, + slug_signal: link.feature_to.feature_id, + }, + }); + this.getFeatureEvents(); + this.getFeatureAttachments(); + this.getLinkedFeatures(); + this.addFeatureToMap(); + //this.initMap(); + //this.$router.go(); + }, + postComment() { featureAPI .postComment({ @@ -536,8 +561,13 @@ export default { mapUtil.getMap().dragging.disable(); mapUtil.getMap().doubleClickZoom.disable(); mapUtil.getMap().scrollWheelZoom.disable(); - var currentFeatureId = this.$route.params.slug_signal; - const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features/${currentFeatureId}/?output=geojson`; + + this.addFeatureToMap(); + }, + + addFeatureToMap() { + const currentFeatureId = this.$route.params.slug_signal; + const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features/${currentFeatureId}/?feature_type__slug=${this.$route.params.slug_type_signal}&output=geojson`; axios .get(url) .then((response) => { @@ -575,9 +605,9 @@ export default { }, created() { - if (!this.project) { - this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); - } + // if (!this.project) { + // this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); + // } this.$store.commit( "feature_type/SET_CURRENT_FEATURE_TYPE_SLUG", this.$route.params.slug_type_signal @@ -588,12 +618,16 @@ export default { }, mounted() { - this.$store - .dispatch("GET_PROJECT_INFO", this.$route.params.slug) - .then((data) => { - console.log(data); - this.initMap(); - }); + if (!this.project) { + this.$store + .dispatch("GET_PROJECT_INFO", this.$route.params.slug) + .then((data) => { + console.log(data); + this.initMap(); + }); + } else { + this.initMap(); + } }, beforeDestroy() { diff --git a/src/views/feature/Feature_edit.vue b/src/views/feature/Feature_edit.vue index 5a2d4742ecaf78fb86082a63a892ddaecf3a21d8..bf455ac417517635948694ad077698dda856b37a 100644 --- a/src/views/feature/Feature_edit.vue +++ b/src/views/feature/Feature_edit.vue @@ -271,7 +271,6 @@ export default { data() { return { map: null, - feature_type: null, baseUrl: this.$store.state.configuration.BASE_URL, file: null, showGeoRef: false, @@ -336,6 +335,7 @@ export default { computed: { ...mapGetters(["project"]), + ...mapGetters("feature_type", ["feature_type"]), ...mapState(["user", "USER_LEVEL_PROJECTS"]), ...mapState("map", ["basemaps"]), ...mapState("feature", [ @@ -411,19 +411,10 @@ export default { } } } - return [] + return []; }, }, - /* watch: { - feature(newValue) { - if (this.$route.name === "editer-signalement") { - this.initForm(); - this.initExtraForms(newValue); - } - }, - }, */ - methods: { initForm() { if (this.currentRouteName === "editer-signalement") { @@ -875,7 +866,7 @@ export default { }); const currentFeatureId = this.$route.params.slug_signal; - const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`; + const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?feature_type__slug=${this.$route.params.slug_type_signal}&output=geojson`; axios .get(url) .then((response) => { @@ -932,14 +923,6 @@ export default { }, created() { - /* if (!this.project) { - console.log(this.$store.state.projects); - this.project = this.$store.state.projects.find( - (project) => project.slug === this.$store.state.project_slug - ); - this.filterStatusChoicesF(); - } */ - this.$store.commit( "feature_type/SET_CURRENT_FEATURE_TYPE_SLUG", this.$route.params.slug_type_signal @@ -952,17 +935,12 @@ export default { }, mounted() { - let ftSlug = this.$route.params.slug_type_signal; this.$store .dispatch("GET_PROJECT_INFO", this.$route.params.slug) .then((data) => { console.log(data); this.initForm(); this.initMap(); - console.log(this.$store.state.feature_type.feature_types); - this.feature_type = this.$store.state.feature_type.feature_types.find( - (el) => el.slug === ftSlug - ); this.onFeatureTypeLoaded(); this.initExtraForms();