CatalogEditor: redirect on successful save
This commit is contained in:
@ -54,6 +54,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import Loading from './Loading'
|
||||
import CatalogInfo from './CatalogInfo'
|
||||
import CatalogContents from './CatalogContents'
|
||||
@ -80,6 +81,9 @@ export default {
|
||||
savingCatalog() {
|
||||
return this.$store.getters.savingCatalog
|
||||
},
|
||||
...mapState([
|
||||
'catalogSavedOK',
|
||||
]),
|
||||
},
|
||||
methods: {
|
||||
popExit: function(id) {
|
||||
@ -89,6 +93,14 @@ export default {
|
||||
this.$store.dispatch('saveCatalog')
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
catalogSavedOK(value) {
|
||||
if (value) {
|
||||
console.log('catalog saved. redirecting to catalog list...')
|
||||
window.location.href = '/catalogs'
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
// catalogID is set by django
|
||||
// in a script block in our parent page.
|
||||
|
||||
@ -19,6 +19,7 @@ export const store = new Vuex.Store({
|
||||
selectedMaterialID: null,
|
||||
loadingCatalog: false,
|
||||
savingCatalog: false,
|
||||
catalogSavedOK: false,
|
||||
loadingProducts: false,
|
||||
},
|
||||
getters: {
|
||||
@ -96,10 +97,6 @@ export const store = new Vuex.Store({
|
||||
return state.catalog[key]
|
||||
},
|
||||
|
||||
//
|
||||
// selection info
|
||||
//
|
||||
|
||||
loadingCatalog(state) {
|
||||
return state.loadingCatalog
|
||||
},
|
||||
@ -195,6 +192,10 @@ export const store = new Vuex.Store({
|
||||
}
|
||||
},
|
||||
|
||||
setCatalogProperty(state, { key, value }) {
|
||||
state.catalog[key] = value
|
||||
},
|
||||
|
||||
setLoadingCatalog(state, value) {
|
||||
state.loadingCatalog = value
|
||||
},
|
||||
@ -203,12 +204,12 @@ export const store = new Vuex.Store({
|
||||
state.savingCatalog = value
|
||||
},
|
||||
|
||||
setLoadingProducts(state, value) {
|
||||
state.loadingProducts = value
|
||||
setCatalogSavedOK(state, value) {
|
||||
state.catalogSavedOK = value
|
||||
},
|
||||
|
||||
setCatalogProperty(state, { key, value }) {
|
||||
state.catalog[key] = value
|
||||
setLoadingProducts(state, value) {
|
||||
state.loadingProducts = value
|
||||
},
|
||||
|
||||
},
|
||||
@ -470,9 +471,9 @@ export const store = new Vuex.Store({
|
||||
if (response.data) {
|
||||
console.log('recieved catalog:', response.data)
|
||||
commit('setCatalog', response.data)
|
||||
commit('setCatalogSavedOK', true)
|
||||
} else {
|
||||
console.error('no catalog returned from save!')
|
||||
commit('newCatalog')
|
||||
}
|
||||
commit('setSavingCatalog', false)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user