diff options
author | Adam T. Carpenter <atc@53hor.net> | 2020-11-11 20:07:12 -0500 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2020-11-11 20:07:12 -0500 |
commit | 7381a7033231e6454a37fd64b1f3de4e8d59355f (patch) | |
tree | 7ae54976c2d036e0fe7cb199a7f6facdd09bbb6d /iridescence/src/store/index.js | |
parent | c5280144de096c274f185fade287ccd63b954ceb (diff) | |
download | theglassyladies-7381a7033231e6454a37fd64b1f3de4e8d59355f.tar.xz theglassyladies-7381a7033231e6454a37fd64b1f3de4e8d59355f.zip |
Kind of flailing with the UI; lots of API bugfixes though.
Diffstat (limited to 'iridescence/src/store/index.js')
-rw-r--r-- | iridescence/src/store/index.js | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/iridescence/src/store/index.js b/iridescence/src/store/index.js index fc77f79..f98fd87 100644 --- a/iridescence/src/store/index.js +++ b/iridescence/src/store/index.js @@ -29,6 +29,9 @@ export default new Vuex.Store({ } }, mutations: { + toggleBusy(state) { + state.busy = !state.busy; + }, searchTerm(state, term) { if (term) { state.searchTerm = term; @@ -40,9 +43,13 @@ export default new Vuex.Store({ } }, replaceProduct(state, product) { + if (!product || !product.id) { + return; + } + let index = state.products.findIndex(p => p.id == product.id); - if (product && index >= 0) { + if (index) { state.products[index] = product; } }, @@ -53,17 +60,29 @@ export default new Vuex.Store({ } }, actions: { - async refreshProducts(context) { + async refreshProducts({ commit }) { + commit("toggleBusy"); const products = await dichroism.getProducts(); - context.commit("setProducts", products); + commit("setProducts", products); + commit("toggleBusy"); }, - async updateProduct(context, product) { + async updateProduct({ commit }, product) { + commit("toggleBusy"); const updatedProduct = await dichroism.updateProduct(product); - context.dispatch("replaceProduct", updatedProduct); + commit("replaceProduct", updatedProduct); + commit("toggleBusy"); }, - async createProduct(context, product) { + async createProduct({ commit }, product) { + commit("toggleBusy"); const newProduct = await dichroism.createProduct(product); - context.dispatch("addProduct", newProduct); + commit("addProduct", newProduct); + commit("toggleBusy"); + }, + async createPhotoSet({ commit }, file) { + commit("toggleBusy"); + const photoSet = await dichroism.createPhoto(file); + commit("toggleBusy"); + return photoSet; } }, modules: {} |