implement "new catalog" in editor

This commit is contained in:
Seth Ladygo
2019-05-04 14:44:34 -07:00
parent 7431f23b67
commit 829df7667e
4 changed files with 45 additions and 8 deletions

View File

@ -78,7 +78,7 @@ export const store = new Vuex.Store({
selectedFamilyID: null,
selectedModelID: null,
selectedMaterial: null,
loadingCatalog: true,
loadingCatalog: false,
savingCatalog: false,
},
getters: {
@ -212,6 +212,10 @@ export const store = new Vuex.Store({
context.commit('setCatalogProperty', data)
},
newCatalog({ commit }) {
commit('setCatalog', {})
},
async loadCatalog({ commit }, id) {
try {
commit('setLoadingCatalog', true)
@ -219,18 +223,15 @@ export const store = new Vuex.Store({
if (response.data) {
console.log('recieved catalog:', response.data)
commit('setCatalog', response.data)
commit('setCatalogID', id)
} else {
console.log('no catalog')
commit('setCatalog', null)
commit('setCatalogID', null)
}
commit('setLoadingCatalog', false)
} catch (error) {
// TODO set loading error property
console.error('error loading catalog: ', error)
commit('setCatalog', null)
commit('setCatalogID', null)
commit('setLoadingCatalog', false)
}
},
@ -244,11 +245,9 @@ export const store = new Vuex.Store({
if (response.data) {
console.log('recieved catalog:', response.data)
commit('setCatalog', response.data)
commit('setCatalogID', response.data.id)
} else {
console.error('no catalog returned from save!')
commit('setCatalog', null)
commit('setCatalogID', null)
}
commit('setSavingCatalog', false)
})