From 35db3aecfc909ab2a898e75434926bf1a4c3497d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr>
Date: Tue, 14 Sep 2021 17:02:38 +0200
Subject: [PATCH] add call to action add_feature when features return from api

---
 src/store/modules/feature.js | 101 ++++++++++++++++++-----------------
 1 file changed, 51 insertions(+), 50 deletions(-)

diff --git a/src/store/modules/feature.js b/src/store/modules/feature.js
index 0accdbd6..b572c0de 100644
--- a/src/store/modules/feature.js
+++ b/src/store/modules/feature.js
@@ -45,12 +45,13 @@ const feature = {
 
   },
   actions: {
-    GET_PROJECT_FEATURES({ commit }, project_slug) {
+    GET_PROJECT_FEATURES({ commit, dispatch }, project_slug) {
       axios
         .get(`${DJANGO_API_BASE}projects/${project_slug}/feature`)
         .then((response) => {
           const features = response.data.features;
           commit("SET_FEATURES", features);
+          dispatch("map/ADD_FEATURES", null, { root: true });
         })
         .catch((error) => {
           throw error;
@@ -61,59 +62,59 @@ const feature = {
       dispatch ("map/ADD_FEATURES");
     }, */
 
-   // POST_FEATURE({ state }) {
-      /* const data = {
-        form: state.form,
-        attachmentFormset: state.attachmentFormset,
-        linkedFormset: state.linkedFormset,
-        extra_form: state.extra_form,
-      } */
+    // POST_FEATURE({ state }) {
+    /* const data = {
+      form: state.form,
+      attachmentFormset: state.attachmentFormset,
+      linkedFormset: state.linkedFormset,
+      extra_form: state.extra_form,
+    } */
 
-      /* axios
-        .post(`${DJANGO_API_BASE}feature_type/`, data)
-        .then((response) => {
-          const routerHistory = router.options.routerHistory 
-          commit("SET_USER", response.data.user);
-          router.push(routerHistory[routerHistory.length - 1] || "/")
-          dispatch("GET_USER_LEVEL_PROJECTS");
-        })
-        .catch(() => {
-          commit("SET_USER", false)
-        }); */
-   // },
+    /* axios
+      .post(`${DJANGO_API_BASE}feature_type/`, data)
+      .then((response) => {
+        const routerHistory = router.options.routerHistory 
+        commit("SET_USER", response.data.user);
+        router.push(routerHistory[routerHistory.length - 1] || "/")
+        dispatch("GET_USER_LEVEL_PROJECTS");
+      })
+      .catch(() => {
+        commit("SET_USER", false)
+      }); */
+    // },
     //DELETE_FEATURE({ state }, feature_slug) {
-      //console.log("Deleting feature:", feature_slug, state)
+    //console.log("Deleting feature:", feature_slug, state)
 
-      /* axios
-        .post(`${DJANGO_API_BASE}feature_type/`, data)
-        .then((response) => {
-          const routerHistory = router.options.routerHistory 
-          commit("SET_USER", response.data.user);
-          router.push(routerHistory[routerHistory.length - 1] || "/")
-          dispatch("GET_USER_LEVEL_PROJECTS");
-        })
-        .catch(() => {
-          commit("SET_USER", false)
-        }); */
-   // },
-   // POST_COMMENT({ state }, data) {
-      //console.log("post comment", data, state)
+    /* axios
+      .post(`${DJANGO_API_BASE}feature_type/`, data)
+      .then((response) => {
+        const routerHistory = router.options.routerHistory 
+        commit("SET_USER", response.data.user);
+        router.push(routerHistory[routerHistory.length - 1] || "/")
+        dispatch("GET_USER_LEVEL_PROJECTS");
+      })
+      .catch(() => {
+        commit("SET_USER", false)
+      }); */
+    // },
+    // POST_COMMENT({ state }, data) {
+    //console.log("post comment", data, state)
 
-      /* axios
-        .post(`${DJANGO_API_BASE}feature_type/`, data)
-        .then((response) => {
-          const routerHistory = router.options.routerHistory 
-          commit("SET_USER", response.data.user);
-          router.push(routerHistory[routerHistory.length - 1] || "/")
-          dispatch("GET_USER_LEVEL_PROJECTS");
-        })
-        .catch(() => {
-          commit("SET_USER", false)
-        }); */
-   // },
-   // EXPORT_FEATURES({ /* state */ }) {
-      //console.log("Export features", state.features)
-   // }
+    /* axios
+      .post(`${DJANGO_API_BASE}feature_type/`, data)
+      .then((response) => {
+        const routerHistory = router.options.routerHistory 
+        commit("SET_USER", response.data.user);
+        router.push(routerHistory[routerHistory.length - 1] || "/")
+        dispatch("GET_USER_LEVEL_PROJECTS");
+      })
+      .catch(() => {
+        commit("SET_USER", false)
+      }); */
+    // },
+    // EXPORT_FEATURES({ /* state */ }) {
+    //console.log("Export features", state.features)
+    // }
   },
 
 }
-- 
GitLab