From 6b1cb363a36b480684b85aad1ad6405b1c096048 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr>
Date: Fri, 24 Dec 2021 12:06:11 +0100
Subject: [PATCH] Fix regression in feature store & improve catalog style

---
 src/store/modules/feature.js                  |   2 +
 src/views/Catalog.vue                         | 128 ++++++++++++------
 .../feature_type/Feature_type_detail.vue      |   2 +
 3 files changed, 93 insertions(+), 39 deletions(-)

diff --git a/src/store/modules/feature.js b/src/store/modules/feature.js
index 7c08380c..1d359d83 100644
--- a/src/store/modules/feature.js
+++ b/src/store/modules/feature.js
@@ -139,8 +139,10 @@ const feature = {
           const features_count = response.data.count;
           commit("SET_FEATURES_COUNT", features_count);
         }
+        return response
       } catch (error) {
         console.error(error);
+        return error
       }
     },
     GET_PROJECT_FEATURE({ commit, rootState }, { project_slug, feature_id }) {
diff --git a/src/views/Catalog.vue b/src/views/Catalog.vue
index dc293a01..82cf434e 100644
--- a/src/views/Catalog.vue
+++ b/src/views/Catalog.vue
@@ -14,8 +14,15 @@
       <div
         v-for="(resource, index) in paginatedRessources"
         :key="`${resource.resource}-${index}`"
-        @click="selectResource(resource.dataset)"
-        class="row"
+        @click="selectResource(resource)"
+        :class="[
+          'row',
+          {
+            selected:
+              selectedResource &&
+              resource.resource === selectedResource.resource,
+          },
+        ]"
       >
         <div>{{ resource.organisation }}</div>
         <div>{{ resource.dataset }}</div>
@@ -100,182 +107,218 @@ export default {
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
+          layerName: "travaux_ccpro_867f108",
           resource: "Ressource 1",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
+          layerName: "travaux_ccpro_867f108",
           resource: "Ressource 2",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
+          layerName: "travaux_ccpro_867f108",
           resource: "Ressource 3",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
+          layerName: "travaux_ccpro_867f108",
           resource: "Ressource 4",
         },
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
-          resource: "Ressource 1",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 11",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
-          resource: "Ressource 2",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 12",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
-          resource: "Ressource 3",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 13",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
-          resource: "Ressource 4",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 14",
         },
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
-          resource: "Ressource 1",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 21",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
-          resource: "Ressource 2",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 22",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
-          resource: "Ressource 3",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 23",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
-          resource: "Ressource 4",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 24",
         },
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
-          resource: "Ressource 1",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 31",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
-          resource: "Ressource 2",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 32",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
-          resource: "Ressource 3",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 33",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
-          resource: "Ressource 4",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 34",
         },
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
-          resource: "Ressource 1",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 41",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
-          resource: "Ressource 2",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 42",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
-          resource: "Ressource 3",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 43",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
-          resource: "Ressource 4",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 44",
         },
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
-          resource: "Ressource 1",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 51",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
-          resource: "Ressource 2",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 52",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
-          resource: "Ressource 3",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 53",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
-          resource: "Ressource 4",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 54",
         },
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
-          resource: "Ressource 1",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 61",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
-          resource: "Ressource 2",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 62",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
-          resource: "Ressource 3",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 63",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
-          resource: "Ressource 4",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 64",
         },
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
-          resource: "Ressource 1",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 71",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
-          resource: "Ressource 2",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 72",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
-          resource: "Ressource 3",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 73",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
-          resource: "Ressource 4",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 74",
         },
         {
           organisation: "Organisation 1",
           dataset: "Dataset 1",
-          resource: "Ressource 1",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 81",
         },
         {
           organisation: "Organisation 2",
           dataset: "Dataset 2",
-          resource: "Ressource 2",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 82",
         },
         {
           organisation: "Organisation 3",
           dataset: "Dataset 3",
-          resource: "Ressource 3",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 83",
         },
         {
           organisation: "Organisation 4",
           dataset: "Dataset 4",
-          resource: "Ressource 4",
+          layerName: "travaux_ccpro_867f108",
+          resource: "Ressource 84",
         },
       ],
       pagination: {
@@ -313,9 +356,8 @@ export default {
   },
 
   methods: {
-    selectResource(typename) {
-      typename = "travaux_ccpro_867f108" // ! mock until plugin deployed
-      this.selectedResource = typename
+    selectResource(resource) {
+      this.selectedResource = resource;
     },
     toPage(pageNumber) {
       const toAddOrRemove =
@@ -355,7 +397,7 @@ export default {
 
     launchImport() {
       const user = "communaute-de-communes-du-pays-reuni-dorange";
-      const paramsTest = `user=${user}&TYPENAME=${this.selectedResource}`;
+      const paramsTest = `user=${user}&TYPENAME=${this.selectedResource.layerName}`;
       miscAPI.getExternalGeojson(paramsTest).then((data) => {
         this.geojson = data;
         console.log(this.geojson);
@@ -387,6 +429,14 @@ h1 {
 .table > .row {
   display: flex;
 }
+.table > .row:not(:first-of-type).selected {
+  background-color: #8bddd9;
+}
+.table > .row:not(:first-of-type):hover {
+  background-color: #009c95;
+  color: #ffffff;
+  cursor: pointer;
+}
 .table > .row:not(:last-child) {
   border-bottom: 1px solid #cacaca;
 }
@@ -416,7 +466,7 @@ h1 {
 @media only screen and (max-width: 767px) {
   .pagination_wrapper {
     justify-content: center;
-}
+  }
 }
 
 .dataTables_length,
diff --git a/src/views/feature_type/Feature_type_detail.vue b/src/views/feature_type/Feature_type_detail.vue
index cf4ddc8f..456cbcda 100644
--- a/src/views/feature_type/Feature_type_detail.vue
+++ b/src/views/feature_type/Feature_type_detail.vue
@@ -459,6 +459,8 @@ export default {
           limit: '5'
         });
 
+        console.log("response", response)
+
       if (response){
         this.featuresLoading = false;
       }
-- 
GitLab