cateditor: allow selecting sections and models
This commit is contained in:
@ -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)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user