state button has the state pre selected

This commit is contained in:
bton 2024-11-02 01:13:21 +01:00 committed by jedi
parent dffd3531fa
commit 767d34f8b7

View file

@ -14,18 +14,25 @@
Delete
</button-->
<div class="btn-group">
<select class="form-control" v-model="ticket.assigned_to">
<select class="form-control" v-model="selected_assignee">
<option v-for="user in users" :value="user.username">{{ user.username }}</option>
</select>
<button class="form-control btn btn-success" @click="assigTicket(ticket)">
<button class="form-control btn btn-success"
@click="assignTicket(ticket)"
:disabled="!selected_assignee || (selected_assignee == ticket.assigned_to)">
Assign&nbsp;Ticket
</button>
</div>
<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 class="form-control" v-model="selected_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)">
<button class="form-control btn btn-success"
@click="changeTicketStatus(ticket)"
:disabled="(selected_state == ticket.state)">
Change&nbsp;Status
</button>
</div>
@ -64,7 +71,19 @@ export default {
components: {ClipboardButton, Timeline},
data() {
return {
shipping_voucher_type: null
selected_state: null,
selected_assignee: null,
shipping_voucher_type: null,
}
},
watch: {
ticket(val) {
if (this.selected_state == null) {
this.selected_state = val.state;
}
if (this.selected_assignee == null) {
this.selected_assignee = val.assigned_to
}
}
},
computed: {
@ -83,7 +102,7 @@ export default {
methods: {
...mapActions(['deleteItem', 'markItemReturned', 'sendMail', 'updateTicketPartial', 'postComment']),
...mapActions(['loadTickets', 'fetchTicketStates', 'loadUsers', 'scheduleAfterInit']),
...mapActions(['claimShippingVoucher']),
...mapActions(['claimShippingVoucher', 'fetchShippingVouchers']),
handleMail(mail) {
this.sendMail({
id: this.ticket.id,
@ -97,20 +116,23 @@ export default {
})
},
changeTicketStatus(ticket) {
ticket.state = this.selected_state;
this.updateTicketPartial({
id: ticket.id,
state: ticket.state
state: this.selected_state,
})
},
assigTicket(ticket) {
assignTicket(ticket) {
ticket.assigned_to = this.selected_assignee;
this.updateTicketPartial({
id: ticket.id,
assigned_to: ticket.assigned_to
assigned_to: this.selected_assignee
})
},
},
mounted() {
this.scheduleAfterInit(() => [this.fetchTicketStates(), this.loadTickets(), this.loadUsers()]);
this.scheduleAfterInit(() => [this.fetchTicketStates(), this.loadTickets(), this.loadUsers(),
this.fetchShippingVouchers()]);
}
};
</script>