changeset 1311:d5eda9f79610

staging: display visual feedback for now due missing backendcall
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 23 Nov 2018 13:52:34 +0100
parents d675e6439aa5
children 3c37017f5eb8
files client/src/components/map/contextbox/Staging.vue client/src/store/imports.js
diffstat 2 files changed, 52 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/map/contextbox/Staging.vue	Fri Nov 23 13:20:10 2018 +0100
+++ b/client/src/components/map/contextbox/Staging.vue	Fri Nov 23 13:52:34 2018 +0100
@@ -47,7 +47,7 @@
             </tbody>
         </table>
         <div class="p-3" v-if="filteredData.length">
-            <button class="btn btn-info">Confirm</button>
+            <button @click="confirmReview" class="btn btn-info">Confirm</button>
         </div>
     </div>
 </template>
@@ -68,7 +68,7 @@
  */
 import { mapState } from "vuex";
 
-import { displayError } from "../../../lib/errors.js";
+import { displayError, displayInfo } from "../../../lib/errors.js";
 
 export default {
   STATES: {
@@ -165,6 +165,20 @@
     }
   },
   methods: {
+    confirmReview() {
+      const message = this.demodata
+        .map(x => {
+          return x.name + ": " + x.status;
+        })
+        .join("\n");
+      displayInfo({
+        title: "Staging Area",
+        message: message
+      });
+      if (false) {
+        //CODE
+      }
+    },
     needsApproval(item) {
       return item.status === this.$options.STATES.NEEDSAPPROVAL;
     },
--- a/client/src/store/imports.js	Fri Nov 23 13:20:10 2018 +0100
+++ b/client/src/store/imports.js	Fri Nov 23 13:52:34 2018 +0100
@@ -15,6 +15,14 @@
 
 import { HTTP } from "../lib/http";
 
+/* eslint-disable no-unused-vars */
+/* eslint-disable no-unreachable */
+const STATES = {
+  NEEDSAPPROVAL: "NEEDSAPPROVAL",
+  APPROVED: "APPROVED",
+  REJECTED: "REJECTED"
+};
+
 // initial state
 const init = () => {
   return {
@@ -33,6 +41,19 @@
     },
     setStaging: (state, staging) => {
       state.staging = staging;
+    },
+
+    toggleApproval: (state, change) => {
+      throw "Not implemented!";
+      const { id, newState } = change;
+      const stagedResult = this.state.staging.find(e => {
+        return e.id === id;
+      });
+      if (stagedResult.status === newState) {
+        stagedResult.status = this.$options.STATES.NEEDSAPPROVAL;
+      } else {
+        stagedResult.status = newState;
+      }
     }
   },
   actions: {
@@ -63,6 +84,21 @@
             reject(error);
           });
       });
+    },
+    setStaging({ commit }, results) {
+      return new Promise((resolve, reject) => {
+        throw "Not implemented!";
+        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);
+          });
+      });
     }
   }
 };