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