add dropdown selection to change state of tickets

This commit is contained in:
j3d1 2023-12-28 21:08:26 +01:00
parent 515648ffa8
commit 626c9f23fe
7 changed files with 166 additions and 13 deletions

View file

@ -88,13 +88,13 @@ export default {
computed: mapState(['loadedItems', 'layout']),
methods: {
...mapActions(['deleteItem', 'markItemReturned']),
openLightboxModalWith(item) { // Opens the editing modal with a copy of the selected item.
openLightboxModalWith(item) {
this.lightboxItem = {...item};
},
closeLightboxModal() { // Closes the editing modal and discards the edited copy of the item.
this.lightboxItem = null;
},
openEditingModalWith(item) {
openEditingModalWith(item) { // Opens the editing modal with a copy of the selected item.
this.editingItem = item;
},
closeEditingModal() {

View file

@ -9,13 +9,19 @@
<Timeline :timeline="ticket.timeline" @sendMail="handleMail"/>
<div class="card-footer d-flex justify-content-between">
<router-link :to="{name: 'tickets'}" class="btn btn-secondary mr-2">Back</router-link>
<button class="btn btn-danger" @click="deleteItem({type: 'tickets', id: ticket.id})">
<!--button class="btn btn-danger" @click="deleteItem({type: 'tickets', id: ticket.id})">
<font-awesome-icon icon="trash"/>
Delete
</button>
<button class="btn btn-success" @click="markItemReturned({type: 'tickets', id: ticket.id})">Mark
<button-- class="btn btn-success" @click="markItemReturned({type: 'tickets', id: ticket.id})">Mark
as returned
</button>
</button-->
<div class="btn-group">
<select class="form-control" v-model="ticket.state">
<option v-for="status in state_options" :value="status.value">{{ status.text }}</option>
</select>
<button class="form-control btn btn-success" @click="changeTicketStatus(ticket)">Change Status</button>
</div>
</div>
</div>
</div>
@ -31,7 +37,7 @@ export default {
name: 'Ticket',
components: {Timeline},
computed: {
...mapState(['tickets']),
...mapState(['tickets', 'state_options']),
ticket() {
const id = parseInt(this.$route.params.id)
const ret = this.tickets.find(ticket => ticket.id === id);
@ -39,15 +45,22 @@ export default {
}
},
methods: {
...mapActions(['deleteItem', 'markItemReturned', 'loadTickets', 'sendMail']),
...mapActions(['deleteItem', 'markItemReturned', 'loadTickets', 'sendMail', 'updateTicketPartial', 'fetchTicketStates']),
handleMail(mail) {
this.sendMail({
id: this.ticket.id,
message: mail
})
},
changeTicketStatus(ticket) {
this.updateTicketPartial({
id: ticket.id,
state: ticket.state
})
}
},
created() {
this.fetchTicketStates()
this.loadTickets()
}
};