delete box button works, with

\confirmation
This commit is contained in:
j3d1 2023-12-29 18:22:48 +01:00
parent affd6f6c86
commit 07213bd421
3 changed files with 14 additions and 6 deletions

View file

@ -315,6 +315,10 @@ const store = new Vuex.Store({
commit('closeAddBoxModal'); commit('closeAddBoxModal');
}); });
}, },
async deleteBox({commit, dispatch}, box_id) {
await axios.delete(`/2/boxes/${box_id}/`);
dispatch('loadBoxes');
},
async updateItem({commit, getters}, item) { async updateItem({commit, getters}, item) {
const {data} = await axios.put(`/2/${getters.getEventSlug}/item/${item.uid}/`, item); const {data} = await axios.put(`/2/${getters.getEventSlug}/item/${item.uid}/`, item);
commit('updateItem', data); commit('updateItem', data);

View file

@ -23,13 +23,13 @@
> >
<template #actions="{ item }"> <template #actions="{ item }">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-success" @click.stop="markItemReturned(item)" title="returned"> <button class="btn btn-success" @click.stop="confirm('return Item?') && markItemReturned(item)" title="returned">
<font-awesome-icon icon="check"/> <font-awesome-icon icon="check"/>
</button> </button>
<button class="btn btn-secondary" @click.stop="openEditingModalWith(item)" title="edit"> <button class="btn btn-secondary" @click.stop="openEditingModalWith(item)" title="edit">
<font-awesome-icon icon="edit"/> <font-awesome-icon icon="edit"/>
</button> </button>
<button class="btn btn-danger" @click.stop="deleteItem(item)" title="delete"> <button class="btn btn-danger" @click.stop="confirm('delete Item?') && deleteItem(item)" title="delete">
<font-awesome-icon icon="trash"/> <font-awesome-icon icon="trash"/>
</button> </button>
</div> </div>

View file

@ -13,9 +13,10 @@
<template v-slot:actions="{ item }"> <template v-slot:actions="{ item }">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-secondary" @click.stop="showBoxContent(item.name)"> <button class="btn btn-secondary" @click.stop="showBoxContent(item.name)">
<!--font-awesome-icon icon="archive"/--> content <font-awesome-icon icon="archive"/>
</button> </button>
<button class="btn btn-danger" @click.stop="" title="delete"> <button class="btn btn-danger" @click.stop="confirm('delete box?') && deleteBox(item.cid)"
title="Delete Box">
<font-awesome-icon icon="trash"/> <font-awesome-icon icon="trash"/>
</button> </button>
</div> </div>
@ -32,8 +33,11 @@ export default {
components: {Table}, components: {Table},
computed: mapState(['loadedBoxes', 'layout']), computed: mapState(['loadedBoxes', 'layout']),
methods: { methods: {
...mapActions(['showBoxContent']), ...mapActions(['showBoxContent', 'deleteBox']),
...mapMutations(['openAddBoxModal']) ...mapMutations(['openAddBoxModal']),
confirm(message) {
return window.confirm(message);
},
}, },
}; };
</script> </script>