diff --git a/cateditor/src/components/CatalogContents.vue b/cateditor/src/components/CatalogContents.vue index 28fb835..068206f 100644 --- a/cateditor/src/components/CatalogContents.vue +++ b/cateditor/src/components/CatalogContents.vue @@ -9,36 +9,24 @@ - - Sections - + + Sections +
- - - - - - - -
-
-
- - - - - Models - - -
-
- +
+ + + + + + + +
@@ -46,17 +34,42 @@ - - Materials - + + Models + + +
+
+ + + + + +
+
+
+
+ + + + + Materials +
-
- +
+ + + + +
@@ -94,6 +107,8 @@ export default { ...mapState([ 'catalog', 'materials', + 'selectedSectionID', + 'selectedModelID', ]), ...mapGetters([ 'section', @@ -113,15 +128,46 @@ export default { return this.modelMaterials(model) }, }, - /* - watch: { - catalog: function(cat) { - console.log('catalog changed') - addSectionDrops(this) - }, - }, - */ + methods: { + selectSection: function(id) { + console.log('select section', id) + this.$store.dispatch('selectSection', id) + }, + + selectModel: function(id) { + console.log('select model', id) + this.$store.dispatch('selectModel', id) + }, + + sectionListItemClasses: function(id, hovering) { + if (id === this.selectedSectionID) { + return 'list-item primary' + } else if (hovering) { + return 'list-item grey lighten-4' + } else { + return '' + } + }, + + modelListItemClasses: function(id, hovering) { + if (id === this.selectedModelID) { + return 'list-item primary' + } else if (hovering) { + return 'list-item grey lighten-4' + } else { + return 'list-item' + } + }, + + materialListItemClasses: function(id, hovering) { + if (hovering) { + return 'list-item grey lighten-4' + } else { + return 'list-item' + } + }, + reorderModel: function(fromIndex, toIndex) { let models = this.selectedModels arrayMove.mutate(models, fromIndex, toIndex) @@ -303,6 +349,6 @@ function addSectionDrops(myvue) { } .list-item { - border-bottom: 1px solid #ddd; + //border-bottom: 1px solid #ddd; } diff --git a/cateditor/src/pages/editor/store/index.js b/cateditor/src/pages/editor/store/index.js index a154abb..8108667 100644 --- a/cateditor/src/pages/editor/store/index.js +++ b/cateditor/src/pages/editor/store/index.js @@ -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) },