cateditor: allow selecting sections and models

This commit is contained in:
Seth Ladygo
2019-05-11 02:24:43 -07:00
parent 26a03fc63f
commit e902aa524a
2 changed files with 134 additions and 54 deletions

View File

@ -77,7 +77,7 @@ export const store = new Vuex.Store({
color: 'Yellow / Blue' },
},
selectedSectionID: null,
selectedFamilyID: null,
//selectedFamilyID: null,
selectedModelID: null,
selectedMaterial: null,
loadingCatalog: false,
@ -100,24 +100,26 @@ export const store = new Vuex.Store({
},
section: (state) => (id) => {
if (state.catalog != null) {
if (state.catalog && id) {
return state.catalog.sections.find(s => s.id === id)
} else {
return null
}
},
selectedSection: state => {
if (state.catalog != null) {
return state.catalog.sections[0]
selectedSection: (state, getters) => {
if (state.catalog && state.selectedSectionID) {
return getters.section(state.selectedSectionID)
} else {
return null
}
},
selectedModel: state => {
if (state.catalog != null) {
return state.catalog.sections[0].pages[0][0]
selectedModel: (state, getters) => {
if (state.catalog && state.selectedModelID) {
let section = getters.selectedSection
let models = getters.sectionModels(section)
return models.find(s => s.model === state.selectedModelID)
} else {
return null
}
@ -218,6 +220,22 @@ export const store = new Vuex.Store({
},
},
mutations: {
//
// selection
//
selectSection(state, id) {
state.selectedSectionID = id
},
selectModel(state, id) {
state.selectedModelID = id
},
//
// manipulation
//
reorderSection(state, { from, to }) {
if (from === to) return
state.catalog.sections = arrayMove(state.catalog.sections, from, to)
@ -283,6 +301,22 @@ export const store = new Vuex.Store({
},
actions: {
//
// selection
//
selectSection(context, id) {
context.commit('selectSection', id)
},
selectModel(context, id) {
context.commit('selectModel', id)
},
//
// manipulation
//
reorderSection({ commit }, payload) {
commit('reorderSection', payload)
},