From 3fb2e718c385ab93a00f0ccf3cc6336094916721 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e?= <tpoussard@neogeo.fr>
Date: Wed, 3 Aug 2022 18:29:23 +0200
Subject: [PATCH] prevent feature_id at feature-type creation instead of import
 for performance & fix undefined feature-type

---
 src/components/Project/Detail/ProjectFeatureTypes.vue | 10 ----------
 src/views/Feature/FeatureDetail.vue                   |  4 +++-
 src/views/FeatureType/FeatureTypeEdit.vue             |  1 +
 3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/components/Project/Detail/ProjectFeatureTypes.vue b/src/components/Project/Detail/ProjectFeatureTypes.vue
index 69c17132..633daf91 100644
--- a/src/components/Project/Detail/ProjectFeatureTypes.vue
+++ b/src/components/Project/Detail/ProjectFeatureTypes.vue
@@ -666,16 +666,6 @@ export default {
                 .filter(Boolean);
             if (sampleLine.length > 1 && headersCoord.length === 2) {
               this.csvError = null;
-              //* remove feature_id if found in headers
-              const featureIdIndex = headers.indexOf('feature_id');
-              if (featureIdIndex > -1) {
-                content = content.split('\n')
-                  .reduce((csvString, rowStr) => {
-                    let rowArray = rowStr.split(delimiter);
-                    rowArray.splice(featureIdIndex, 1); // remove feature_id in header and features
-                    return csvString += rowArray.join(delimiter) + '\n';
-                  }, '');
-              }
               this.csvImport = csvToJson(content, delimiter);
               this.featureTypeImporting = false;
               //* stock filename to import features afterward
diff --git a/src/views/Feature/FeatureDetail.vue b/src/views/Feature/FeatureDetail.vue
index 196ac2ae..3437f276 100644
--- a/src/views/Feature/FeatureDetail.vue
+++ b/src/views/Feature/FeatureDetail.vue
@@ -250,12 +250,14 @@ export default {
     ]),
     ...mapState('feature-type', [
       'feature_types',
-      'feature_type',
     ]),
     ...mapState('feature', [
       'currentFeature',
       'form',
     ]),
+    ...mapGetters('feature-type', [
+      'feature_type',
+    ]),
     ...mapGetters([
       'permissions',
     ]),
diff --git a/src/views/FeatureType/FeatureTypeEdit.vue b/src/views/FeatureType/FeatureTypeEdit.vue
index 5682366f..315acba7 100644
--- a/src/views/FeatureType/FeatureTypeEdit.vue
+++ b/src/views/FeatureType/FeatureTypeEdit.vue
@@ -247,6 +247,7 @@ export default {
         'archived_on',
         'deletion_on',
         'feature_type',
+        'feature_id',
         'display_creator',
         'display_last_editor',
         'project',
-- 
GitLab