implement "new catalog" in editor
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
<v-stepper v-model="step">
|
||||
<v-stepper-header>
|
||||
<v-stepper-step :complete="step > 1" step="1">Catalog info</v-stepper-step>
|
||||
<Loading text="Loading" :show="loadingCatalog"/>
|
||||
|
||||
<v-divider></v-divider>
|
||||
<v-stepper-step :complete="step > 2" step="2">Contents</v-stepper-step>
|
||||
<v-divider></v-divider>
|
||||
@ -40,17 +42,32 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Loading from './Loading'
|
||||
import CatalogInfo from './CatalogInfo'
|
||||
import CatalogContents from './CatalogContents'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Loading,
|
||||
CatalogInfo,
|
||||
CatalogContents
|
||||
},
|
||||
data: () => ({
|
||||
step: 1,
|
||||
}),
|
||||
computed: {
|
||||
loadingCatalog() {
|
||||
return this.$store.getters.loadingCatalog
|
||||
},
|
||||
savingCatalog() {
|
||||
return this.$store.getters.savingCatalog
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
saveCatalog() {
|
||||
this.$store.dispatch('saveCatalog')
|
||||
},
|
||||
},
|
||||
mounted: function() {
|
||||
// catalogID is set by django
|
||||
// in a script block in our parent page.
|
||||
|
||||
21
cateditor/src/components/Loading.vue
Normal file
21
cateditor/src/components/Loading.vue
Normal file
@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<v-dialog v-model="show" persistent width="300">
|
||||
<v-card color="green" dark>
|
||||
<v-card-text class="white--text">
|
||||
{{ text }}
|
||||
<v-progress-linear indeterminate color="white" class="mb-0" />
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data: () => ({
|
||||
}),
|
||||
props: {
|
||||
text: String,
|
||||
show: Boolean,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@ -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)
|
||||
})
|
||||
|
||||
@ -139,9 +139,9 @@ class Catalog(models.Model):
|
||||
sections = 0
|
||||
pages = 0
|
||||
materials = 0
|
||||
for section in data.get('sections'):
|
||||
for section in data.get('sections', []):
|
||||
sections += 1
|
||||
for page in section.get('pages'):
|
||||
for page in section.get('pages', []):
|
||||
pages += 1
|
||||
for block in page:
|
||||
materials += len(block.get('ids', []))
|
||||
|
||||
Reference in New Issue
Block a user