revive SectionDeleteDialog

This commit is contained in:
Seth Ladygo
2019-05-17 22:55:47 -07:00
parent 151a16d0c5
commit 70c532daad
3 changed files with 52 additions and 12 deletions

View File

@ -41,7 +41,7 @@
<v-btn icon @click.stop="popSectionInfo(item.id)"> <v-btn icon @click.stop="popSectionInfo(item.id)">
<v-icon small color="grey lighten-1">info</v-icon> <v-icon small color="grey lighten-1">info</v-icon>
</v-btn> </v-btn>
<v-btn icon @click.stop="popDelete(item.id)"> <v-btn icon @click.stop="popSectionDelete(item.id)">
<v-icon small color="grey lighten-1">delete</v-icon> <v-icon small color="grey lighten-1">delete</v-icon>
</v-btn> </v-btn>
</span> </span>
@ -132,6 +132,7 @@
<AddProductDialog v-model="showAddProductDialog"/> <AddProductDialog v-model="showAddProductDialog"/>
<AddSectionDialog v-model="showAddSectionDialog"/> <AddSectionDialog v-model="showAddSectionDialog"/>
<SectionInfoDialog v-model="showSectionInfoDialog"/> <SectionInfoDialog v-model="showSectionInfoDialog"/>
<SectionDeleteDialog v-model="showSectionDeleteDialog"/>
</v-container> </v-container>
</template> </template>
@ -146,6 +147,7 @@ import DragListHeading from './DragListHeading'
import AddProductDialog from './AddProductDialog' import AddProductDialog from './AddProductDialog'
import AddSectionDialog from './AddSectionDialog' import AddSectionDialog from './AddSectionDialog'
import SectionInfoDialog from './SectionInfoDialog' import SectionInfoDialog from './SectionInfoDialog'
import SectionDeleteDialog from './SectionDeleteDialog'
export default { export default {
components: { components: {
@ -153,6 +155,7 @@ export default {
AddProductDialog, AddProductDialog,
AddSectionDialog, AddSectionDialog,
SectionInfoDialog, SectionInfoDialog,
SectionDeleteDialog,
//RawDisplayer, //RawDisplayer,
}, },
@ -160,6 +163,7 @@ export default {
showAddProductDialog: false, showAddProductDialog: false,
showAddSectionDialog: false, showAddSectionDialog: false,
showSectionInfoDialog: false, showSectionInfoDialog: false,
showSectionDeleteDialog: false,
}), }),
computed: { computed: {
...mapState([ ...mapState([
@ -249,6 +253,11 @@ export default {
this.showSectionInfoDialog = true this.showSectionInfoDialog = true
}, },
popSectionDelete(id) {
this.selectSection(id)
this.showSectionDeleteDialog = true
},
...mapActions([ ...mapActions([
'selectSection', 'selectSection',
'reorderSection', 'reorderSection',

View File

@ -2,17 +2,22 @@
<v-layout row justify-center> <v-layout row justify-center>
<v-dialog v-model="show" max-width="250"> <v-dialog v-model="show" max-width="250">
<v-card> <v-card>
<v-card-title>Delete Section</v-card-title> <DialogHeading title="Delete Section">
<v-btn icon @click="show = false" class="ma-0 pa-0">
<v-icon color="white">clear</v-icon>
</v-btn>
</DialogHeading>
<v-card-text> <v-card-text>
Really delete section: Really delete section?
<input v-model="name"/> <input class="subheading font-weight-medium mt-2" v-model="name"/>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn flat @click="show = false">Cancel</v-btn> <v-btn flat @click="show = false">Cancel</v-btn>
<v-btn color="primary" flat @click="show = false">OK</v-btn> <v-btn color="primary" flat @click="doDelete()">OK</v-btn>
<v-spacer></v-spacer>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
@ -20,8 +25,13 @@
</template> </template>
<script> <script>
// https://stackoverflow.com/questions/48035310/open-a-vuetify-dialog-from-a-component-template-in-vuejs import DialogHeading from './DialogHeading'
import { mapGetters, mapActions } from 'vuex'
export default { export default {
components: {
DialogHeading,
},
data: () => ({ data: () => ({
}), }),
props: { props: {
@ -42,12 +52,23 @@ export default {
}, },
name: { name: {
get() { get() {
var sectionID = this.$store.getters.SELECTED_SECTION_ID let section = this.selectedSection()
var section = this.$store.getters.CAT_SECTION(sectionID)
return section ? section.name : '(none)' return section ? section.name : '(none)'
} }
} }
} },
methods: {
doDelete() {
this.deleteSection(this.selectedSection())
this.show = false
},
...mapGetters([
'selectedSection',
]),
...mapActions([
'deleteSection',
]),
},
} }
</script> </script>

View File

@ -189,6 +189,12 @@ export const store = new Vuex.Store({
state.catalog.sections.push(section) state.catalog.sections.push(section)
}, },
deleteSection(state, section) {
if (section) {
state.catalog.sections = state.catalog.sections.filter(s => s.id !== section.id)
}
},
setSectionName(state, { section, name }) { setSectionName(state, { section, name }) {
section.name = name section.name = name
}, },
@ -296,6 +302,10 @@ export const store = new Vuex.Store({
commit('addSection', section) commit('addSection', section)
}, },
deleteSection({ commit, getters }, section) {
commit('deleteSection', section)
},
setSectionName({ commit }, payload) { setSectionName({ commit }, payload) {
commit('setSectionName', payload) commit('setSectionName', payload)
}, },