state button has the state pre selected

This commit is contained in:
bton 2024-11-02 01:13:21 +01:00
parent 84aa2e8820
commit 987a851fc3

View file

@ -15,23 +15,25 @@
Delete Delete
</button--> </button-->
<div class="btn-group"> <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> <option v-for="user in users" :value="user.username">{{ user.username }}</option>
</select> </select>
<button class="form-control btn btn-success" <button class="form-control btn btn-success"
@click="assignTicket(ticket)" @click="assignTicket(ticket)"
:disabled="!ticket.assigned_to"> :disabled="!selected_assignee && (selected_assignee == ticket.assigned_to)">
Assign&nbsp;Ticket Assign&nbsp;Ticket
</button> </button>
</div> </div>
<div class="btn-group"> <div class="btn-group">
<select class="form-control" v-model="ticket.state"> <select class="form-control" v-model="selected_state">
<option v-for="status in state_options" :value="status.value">{{ <option v-for="status in state_options" :value="status.value">{{
status.text status.text
}} }}
</option> </option>
</select> </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 Change&nbsp;Status
</button> </button>
</div> </div>
@ -71,11 +73,20 @@ export default {
name: 'Ticket', name: 'Ticket',
components: {AsyncLoader, ClipboardButton, Timeline}, components: {AsyncLoader, ClipboardButton, Timeline},
data() { data() {
return { return {
shipping_voucher_type: null selected_state: null,
Selected_assignee: null,
shipping_voucher_type: null,
} }
}, },
computed: { watch: {
ticket(val) {
if (this.selected_state == null){
this.selected_state = val.state;
}
}
},
computed: {
...mapState(['tickets', 'state_options', 'users']), ...mapState(['tickets', 'state_options', 'users']),
...mapGetters(['availableShippingVoucherTypes']), ...mapGetters(['availableShippingVoucherTypes']),
ticket() { ticket() {
@ -87,7 +98,7 @@ export default {
const domain = document.location.hostname; const domain = document.location.hostname;
return `ticket+${this.ticket.uuid}@${domain}`; return `ticket+${this.ticket.uuid}@${domain}`;
} }
}, },
methods: { methods: {
...mapActions(['deleteItem', 'markItemReturned', 'sendMail', 'updateTicketPartial', 'postComment']), ...mapActions(['deleteItem', 'markItemReturned', 'sendMail', 'updateTicketPartial', 'postComment']),
...mapActions(['loadTickets', 'fetchTicketStates', 'loadUsers', 'scheduleAfterInit']), ...mapActions(['loadTickets', 'fetchTicketStates', 'loadUsers', 'scheduleAfterInit']),
@ -105,15 +116,17 @@ export default {
}) })
}, },
changeTicketStatus(ticket) { changeTicketStatus(ticket) {
this.updateTicketPartial({ ticket.state = this.selected_state;
this.updateTicketPartial({
id: ticket.id, id: ticket.id,
state: ticket.state state: this.selected_state,
}) })
}, },
assignTicket(ticket) { assignTicket(ticket) {
this.updateTicketPartial({ ticket.assigned_to = this.selected_assignee;
this.updateTicketPartial({
id: ticket.id, id: ticket.id,
assigned_to: ticket.assigned_to assigned_to: this.selected_assignee
}) })
}, },
}, },