diff client/src/store/imports.js @ 2654:3c04c8e46bd4

importoverview: reload reloads current selection
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 14 Mar 2019 15:37:10 +0100
parents 9f3856337f55
children 501967471981
line wrap: on
line diff
--- a/client/src/store/imports.js	Thu Mar 14 15:03:49 2019 +0100
+++ b/client/src/store/imports.js	Thu Mar 14 15:37:10 2019 +0100
@@ -29,7 +29,11 @@
 // initial state
 const init = () => {
   return {
-    filters: [],
+    failed: false,
+    pending: false,
+    accepted: false,
+    declined: false,
+    warning: false,
     stretches: [],
     imports: [],
     reviewed: [],
@@ -68,16 +72,41 @@
   });
 };
 
+const clearFilterCriteria = state => {
+  state.warning = false;
+  state.successful = false;
+  state.failed = false;
+  state.pending = false;
+  state.accepted = false;
+  state.declined = false;
+};
+
 const imports = {
   init,
   namespaced: true,
   state: init(),
+  getters: {
+    filters: state => {
+      return ["failed", "pending", "accepted", "declined", "warning"].filter(
+        x => state[x]
+      );
+    }
+  },
   mutations: {
-    setFilters: (state, filters) => {
-      state.filters = filters;
+    toggleFilter: (state, name) => {
+      state[name] = !state[name];
+      const allSet =
+        state.failed &&
+        state.pending &&
+        state.accepted &&
+        state.declined &&
+        state.warning;
+      if (allSet) {
+        clearFilterCriteria(state);
+      }
     },
     clearFilters: state => {
-      state.filters = [];
+      clearFilterCriteria(state);
     },
     setStretches: (state, stretches) => {
       state.stretches = stretches;
@@ -200,20 +229,6 @@
           });
       });
     },
-    getStaging({ commit }) {
-      return new Promise((resolve, reject) => {
-        HTTP.get("/imports?states=pending", {
-          headers: { "X-Gemma-Auth": localStorage.getItem("token") }
-        })
-          .then(response => {
-            commit("setStaging", response.data.imports);
-            resolve(response);
-          })
-          .catch(error => {
-            reject(error);
-          });
-      });
-    },
     confirmReview({ state }, reviewResults) {
       return new Promise((resolve, reject) => {
         HTTP.patch("/imports", reviewResults, {