@@ -3,6 +3,7 @@ import Vuex from 'vuex'
import actions from '@/store/actions'
+import loader from '@/store/modules/loader'
import company from '@/store/modules/company'
import currencies from '@/store/modules/currencies'
import products from '@/store/modules/products'
@@ -14,6 +15,7 @@ Vue.use(Vuex)
const Store = new Vuex.Store({
...actions,
modules: {
+ loader,
company,
currencies,
products,
@@ -18,7 +18,7 @@ const mutations = {
}
const actions = {
- fetchCompany({ commit }) {
+ fetchCompany({ commit, dispatch }) {
return new Promise((resolve, reject) => {
let pos = new openerp.web.Model('eiru.pos')
pos.call('get_company').then(response => {
@@ -26,7 +26,10 @@ const actions = {
company: response
})
- console.log('fetched company')
+ dispatch('loaded', {
+ module: 'company'
+ })
+
resolve()
}).fail(error => {
console.log(error)
- fetchCurrencies({ commit }) {
+ fetchCurrencies({ commit, dispatch }) {
pos.call('get_currencies').then(response => {
currencies: response
- console.log('fetched currencies')
+ module: 'currencies'
console.log(error);
@@ -22,14 +22,18 @@ const mutations = {
- fetchCustomers({ commit }) {
+ fetchCustomers({ commit, dispatch }) {
let customer = new openerp.web.Model('res.partner')
customer.query(['name', 'display_name', 'image_medium']).filter([['customer', '=', true], ['is_company', '=', false], ['active', '=', true]]).all().then(response => {
commit('pushCustomers', {
customers: response
- console.log('fetched customers')
+ module: 'customers'
@@ -0,0 +1,33 @@
+const state = {
+ loaded: {
+ company: false,
+ currencies: false,
+ customers: false,
+ products: false,
+ }
+}
+const getters = {
+ isLoaded(state) {
+ return state.loaded.company && state.loaded.currencies && state.loaded.customers && state.loaded.products
+const mutations = {
+ setLoaded(state, payload) {
+ state.loaded[payload.module] = true
+const actions = {
+ loaded({ commit }, payload) {
+ commit('setLoaded', payload)
+export default {
+ state,
+ getters,
+ mutations,
+ actions
@@ -30,7 +30,7 @@ const mutations = {
- fetchProducts ({ commit }) {
+ fetchProducts ({ commit, dispatch }) {
pos.call('get_products').then(response => {
@@ -38,7 +38,10 @@ const actions = {
products: response
- console.log('fetched products')
+ module: 'products'