Browse Source

[FIX] realoading

Gogs 7 years ago
parent
commit
cb4a05c4a8
3 changed files with 33 additions and 10 deletions
  1. 13 9
      src/components/Loader.vue
  2. 2 0
      src/index.js
  3. 18 1
      src/store/modules/loader.js

+ 13 - 9
src/components/Loader.vue

@@ -4,16 +4,16 @@
 </template>
 
 <script>
-    import { mapGetters } from 'vuex'
+    import { mapGetters, mapActions } from 'vuex'
 
     export default {
-        computed: mapGetters([
-            'isLoaded'
-        ]),
+        computed: mapGetters({
+            loaded: 'isLoaded'
+        }),
         watch: {
-            isLoaded(loaded) {
-                if (loaded) {
-                     this.$modal.hide("pos-loader")
+            loaded(completed) {
+                if (completed) {
+                    this.$modal.hide("pos-loader")
                 } else {
                     this.$modal.show("pos-loader")
                 }
@@ -21,12 +21,16 @@
         },
         methods: {
             beforeClose(e) {
-                if (!this.isLoaded) {
+                if (!this.loaded) {
                     e.stop()
                 }
-            }
+            },
+            ...mapActions([
+                'clear'
+            ])
         },
         mounted() {
+            this.clear()
             this.$modal.show("pos-loader")
         }
     }

+ 2 - 0
src/index.js

@@ -28,5 +28,7 @@ openerp.eiru_pos = (instance, local) => {
         }
     })
 
+
     instance.web.client_actions.add('eiru_pos.action_launch', 'instance.eiru_pos.PosWidget')
 }
+

+ 18 - 1
src/store/modules/loader.js

@@ -4,10 +4,19 @@ const state = {
         currencies: false,
         customers: false,
         products: false,
-    }
+    },
+    messages: [
+        'Cargando compañía',
+        'Cargando monedas',
+        'Cargando clientes',
+        'Cargando productos'
+    ]
 }
 
 const getters = {
+    getMessages(state) {
+        return state.messages
+    },
     isLoaded(state) {
         return state.loaded.company && state.loaded.currencies && state.loaded.customers && state.loaded.products
     }
@@ -16,12 +25,20 @@ const getters = {
 const mutations = {
     setLoaded(state, payload) {
         state.loaded[payload.module] = true
+    },
+    setUnloaded(state) {
+        for (let module in state.loaded) {
+            state.loaded[module] = false
+        }
     }
 }
 
 const actions = {
     loaded({ commit }, payload) {
         commit('setLoaded', payload)
+    },
+    clear({ commit }) {
+        commit('setUnloaded')
     }
 }