add material selection

This commit is contained in:
Seth Ladygo
2019-05-18 00:50:34 -07:00
parent 0dfb38f87a
commit cb26908f3b
2 changed files with 20 additions and 2 deletions

View File

@ -101,6 +101,7 @@
<div v-for="item in selectedMaterials" :key="item.id"> <div v-for="item in selectedMaterials" :key="item.id">
<v-hover :key="item.id"> <v-hover :key="item.id">
<v-list-tile <v-list-tile
@click="selectMaterial(item.id)"
slot-scope="{ hover }" slot-scope="{ hover }"
:class="materialListItemClasses(item.id, hover)" :class="materialListItemClasses(item.id, hover)"
> >
@ -179,12 +180,14 @@ export default {
'materials', 'materials',
'selectedSectionID', 'selectedSectionID',
'selectedModelID', 'selectedModelID',
'selectedMaterialID',
]), ]),
...mapGetters([ ...mapGetters([
'section', 'section',
'sections', 'sections',
'selectedSection', 'selectedSection',
'selectedModel', 'selectedModel',
'selectedMaterial',
'sectionModels', 'sectionModels',
'modelMaterials', 'modelMaterials',
'material', 'material',
@ -231,7 +234,9 @@ export default {
}, },
materialListItemClasses(id, hovering) { materialListItemClasses(id, hovering) {
if (hovering) { if (id === this.selectedMaterialID) {
return 'list-item primary'
} else if (hovering) {
return 'list-item grey lighten-4' return 'list-item grey lighten-4'
} else { } else {
return 'list-item' return 'list-item'
@ -274,6 +279,7 @@ export default {
...mapActions([ ...mapActions([
'selectSection', 'selectSection',
'selectModel', 'selectModel',
'selectMaterial',
'reorderSection', 'reorderSection',
'setSectionPages', 'setSectionPages',
'setModelMaterials', 'setModelMaterials',

View File

@ -12,7 +12,7 @@ export const store = new Vuex.Store({
materials: {}, materials: {},
selectedSectionID: null, selectedSectionID: null,
selectedModelID: null, selectedModelID: null,
selectedMaterial: null, selectedMaterialID: null,
loadingCatalog: false, loadingCatalog: false,
savingCatalog: false, savingCatalog: false,
loadingProducts: false, loadingProducts: false,
@ -100,6 +100,10 @@ export const store = new Vuex.Store({
return [] return []
}, },
selectedMaterial: (state, getters) => (id) => {
return getters.material(id)
},
/// OLD STUFF /// OLD STUFF
// //
// catalog info // catalog info
@ -181,6 +185,10 @@ export const store = new Vuex.Store({
state.selectedModelID = id state.selectedModelID = id
}, },
selectMaterial(state, id) {
state.selectedMaterialID = id
},
// //
// manipulation // manipulation
// //
@ -293,6 +301,10 @@ export const store = new Vuex.Store({
context.commit('selectModel', id) context.commit('selectModel', id)
}, },
selectMaterial(context, id) {
context.commit('selectMaterial', id)
},
// //
// manipulation // manipulation
// //