From 964e0ca05ec0fc21cf5c39c46b6f8722c7b92f34 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr>
Date: Mon, 11 Oct 2021 12:31:22 +0200
Subject: [PATCH] allow only author of a feature to delete it

---
 src/views/feature/Feature_detail.vue | 45 ++++++++++++++--------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue
index 62203ff9..42a6d487 100644
--- a/src/views/feature/Feature_detail.vue
+++ b/src/views/feature/Feature_detail.vue
@@ -37,8 +37,9 @@
                 >
                   <i class="inverted grey pencil alternate icon"></i>
                 </router-link>
+                <!-- (permissions && permissions.can_delete_feature) || -->
                 <a
-                  v-if="permissions && permissions.can_delete_feature"
+                  v-if="isFeatureCreator"
                   @click="isCanceling = true"
                   id="feature-delete"
                   class="ui button button-hover-red"
@@ -101,7 +102,7 @@
                     v-if="feature.status"
                     :class="getIconLabelStatus(feature.status, 'icon')"
                   ></i>
-                  {{ getIconLabelStatus(feature.status, 'label') }}
+                  {{ getIconLabelStatus(feature.status, "label") }}
                 </td>
               </tr>
               <tr>
@@ -417,7 +418,6 @@ export default {
       const result = this.$store.state.feature.features.find(
         (el) => el.feature_id === this.$route.params.slug_signal
       );
-      console.log("result", result);
       return result;
     },
 
@@ -438,23 +438,19 @@ export default {
   },
 
   methods: {
-    getIconLabelStatus(status, type){
-      if (status  === 'archived')
-        if (type == 'icon')
-          return "grey archive icon";
-        else return 'Archivé';
-      else if (status === 'pending')
-        if (type == 'icon')
-          return "teal hourglass outline icon";
-        else return 'En attente de publication';
-      else if (status === 'published')
-        if (type == 'icon')
-          return "olive check icon";
-        else return 'Publié';
-      else if (status === 'draft')
-        if (type == 'icon')
-          return "orange pencil alternate icon";
-        else return 'Brouillon';
+    getIconLabelStatus(status, type) {
+      if (status === "archived")
+        if (type == "icon") return "grey archive icon";
+        else return "Archivé";
+      else if (status === "pending")
+        if (type == "icon") return "teal hourglass outline icon";
+        else return "En attente de publication";
+      else if (status === "published")
+        if (type == "icon") return "olive check icon";
+        else return "Publié";
+      else if (status === "draft")
+        if (type == "icon") return "orange pencil alternate icon";
+        else return "Brouillon";
     },
     pushNgo(link) {
       this.$router.push({
@@ -533,7 +529,10 @@ export default {
         .dispatch("feature/DELETE_FEATURE", this.feature.feature_id)
         .then((response) => {
           if (response.status === 204) {
-            this.$store.dispatch("feature/GET_PROJECT_FEATURES", this.$route.params.slug);
+            this.$store.dispatch(
+              "feature/GET_PROJECT_FEATURES",
+              this.$route.params.slug
+            );
             this.goBackToProject();
           }
         });
@@ -599,7 +598,9 @@ export default {
           if (feature) {
             const currentFeature = [feature];
             const featureGroup = mapUtil.addFeatures(currentFeature);
-            mapUtil.getMap().fitBounds(featureGroup.getBounds(), { padding: [25, 25] });
+            mapUtil
+              .getMap()
+              .fitBounds(featureGroup.getBounds(), { padding: [25, 25] });
           }
         })
         .catch((error) => {
-- 
GitLab