From 13f4d434dbe94d27ab8b3ada95126ee6816436e8 Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Sat, 18 May 2019 10:38:54 -0700 Subject: [PATCH] add MaterialDeleteDialog --- cateditor/src/components/CatalogContents.vue | 15 ++- .../src/components/MaterialDeleteDialog.vue | 98 +++++++++++++++++++ cateditor/src/pages/editor/store/index.js | 14 ++- 3 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 cateditor/src/components/MaterialDeleteDialog.vue diff --git a/cateditor/src/components/CatalogContents.vue b/cateditor/src/components/CatalogContents.vue index 24b836e..2979c69 100644 --- a/cateditor/src/components/CatalogContents.vue +++ b/cateditor/src/components/CatalogContents.vue @@ -112,10 +112,7 @@ - - info - - + delete @@ -136,6 +133,7 @@ + @@ -153,6 +151,7 @@ import SectionInfoDialog from './SectionInfoDialog' import SectionDeleteDialog from './SectionDeleteDialog' import ModelInfoDialog from './ModelInfoDialog' import ModelDeleteDialog from './ModelDeleteDialog' +import MaterialDeleteDialog from './MaterialDeleteDialog' export default { components: { @@ -163,6 +162,7 @@ export default { SectionDeleteDialog, ModelInfoDialog, ModelDeleteDialog, + MaterialDeleteDialog, //RawDisplayer, }, @@ -173,6 +173,8 @@ export default { showSectionDeleteDialog: false, showModelInfoDialog: false, showModelDeleteDialog: false, + //showMaterialInfoDialog: false, + showMaterialDeleteDialog: false, }), computed: { ...mapState([ @@ -276,6 +278,11 @@ export default { this.showModelDeleteDialog = true }, + popMaterialDelete(id) { + this.selectMaterial(id) + this.showMaterialDeleteDialog = true + }, + ...mapActions([ 'selectSection', 'selectModel', diff --git a/cateditor/src/components/MaterialDeleteDialog.vue b/cateditor/src/components/MaterialDeleteDialog.vue new file mode 100644 index 0000000..5242674 --- /dev/null +++ b/cateditor/src/components/MaterialDeleteDialog.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/cateditor/src/pages/editor/store/index.js b/cateditor/src/pages/editor/store/index.js index ad85cdc..a3123df 100644 --- a/cateditor/src/pages/editor/store/index.js +++ b/cateditor/src/pages/editor/store/index.js @@ -100,8 +100,8 @@ export const store = new Vuex.Store({ return [] }, - selectedMaterial: (state, getters) => (id) => { - return getters.material(id) + selectedMaterial: (state, getters) => { + return getters.material(state.selectedMaterialID) }, /// OLD STUFF @@ -494,6 +494,16 @@ export const store = new Vuex.Store({ // let { data } = await Axios.post('http://yourwebsite.com/api/todo') // context.commit('ADD_TODO',payload) // }, + deleteModelMaterial({ commit, getters }, { section, model, material }) { + let mats = model.ids.filter(id => id !== material.id) + + commit('setModelMaterials', { model: model, materials: mats }) + + // repaginate section + let models = getters.sectionModels(section) + let pages = paginateModels(models) + commit('setSectionPages', { section: section, pages: pages }) + }, setCatalogProperty(context, data) { context.commit('setCatalogProperty', data)