diff client/src/store/imports.js @ 1365:da7ee82ad5d6

merge
author Fadi Abbud <fadi.abbud@intevation.de>
date Tue, 27 Nov 2018 09:03:27 +0100
parents ca33ad696594 58d41573e530
children f4b3fb43b311 5e1218b5a123
line wrap: on
line diff
--- a/client/src/store/imports.js	Mon Nov 26 12:44:52 2018 +0100
+++ b/client/src/store/imports.js	Tue Nov 27 09:03:27 2018 +0100
@@ -30,7 +30,7 @@
   };
 };
 
-export default {
+const imports = {
   init,
   namespaced: true,
   state: init(),
@@ -39,19 +39,21 @@
       state.imports = imports;
     },
     setStaging: (state, staging) => {
-      state.staging = staging;
+      const enriched = staging.map(x => {
+        return { ...x, status: STATES.NEEDSAPPROVAL };
+      });
+      state.staging = enriched;
     },
 
     toggleApproval: (state, change) => {
-      throw "Not implemented!";
-      const { id, newState } = change;
-      const stagedResult = this.state.staging.find(e => {
+      const { id, newStatus } = change;
+      const stagedResult = state.staging.find(e => {
         return e.id === id;
       });
-      if (stagedResult.status === newState) {
-        stagedResult.status = this.$options.STATES.NEEDSAPPROVAL;
+      if (stagedResult.status === newStatus) {
+        stagedResult.status = STATES.NEEDSAPPROVAL;
       } else {
-        stagedResult.status = newState;
+        stagedResult.status = newStatus;
       }
     }
   },
@@ -101,3 +103,5 @@
     }
   }
 };
+
+export { imports, STATES };