Apply requested changes

This commit is contained in:
Pau 2022-10-27 08:46:22 +02:00
parent d937a1b505
commit d4a22f7962
6 changed files with 56 additions and 53 deletions

View File

@ -5,6 +5,13 @@
<vn-menu vn-id="menu">
<vn-list>
<vn-item
vn-acl="administrative"
vn-acl-action="remove"
ng-click="transferClient.show()"
translate>
Transfer client
</vn-item>
<vn-item
ng-click="addTurn.show()"
vn-acl="buyer"
@ -242,6 +249,36 @@
</tpl-buttons>
</vn-dialog>
<!-- Transfer Client popup -->
<vn-dialog
vn-id="transferClient"
title="transferClient"
size="sm"
on-accept="$ctrl.transferClient($client)">
<tpl-body>
<vn-autocomplete
vn-one
vn-id="client"
required="true"
url="Clients"
label="Client"
show-field="name"
value-field="id"
search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}]}"
ng-model="$ctrl.ticket.client.id"
initial-data="$ctrl.ticket.client.id"
order="id">
<tpl-item>
#{{id}} - {{::name}}
</tpl-item>
</vn-autocomplete>
</tpl-body>
<tpl-buttons>
<button response="accept" translate>Transfer client</button>
</tpl-buttons>
</vn-dialog>
<!-- Send SMS popup -->
<vn-ticket-sms
vn-id="sms"

View File

@ -95,6 +95,23 @@ class Controller extends Section {
});
}
transferClient() {
this.$http.get(`Clients/${this.ticket.client.id}`).then(client => {
const ticket = this.ticket;
const params =
{
clientFk: client.data.id,
addressFk: client.data.defaultAddressFk,
};
this.$http.patch(`Tickets/${ticket.id}`, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.reload();
});
});
}
isTicketEditable() {
if (!this.ticket) return;

View File

@ -9,4 +9,5 @@ Send CSV Delivery Note: Enviar albarán en CSV
Send PDF Delivery Note: Enviar albarán en PDF
Show Proforma: Ver proforma
Refund all: Abonar todo
The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}"
The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}"
Transfer client: Transferir cliente

View File

@ -93,44 +93,9 @@
icon="icon-basketadd">
</vn-quick-link>
</div>
<div ng-transclude="btnFour">
<vn-quick-link
vn-acl="administrative"
vn-acl-action="remove"
tooltip="Transfer client"
icon="people"
ng-click="transferClient.show()">
</vn-quick-link>
</div>
</slot-body>
</vn-descriptor-content>
<vn-dialog
vn-id="transferClient"
title="transferClient"
size="sm"
on-accept="$ctrl.transferClient($client)">
<tpl-body>
<vn-autocomplete
vn-one
vn-id="client"
required="true"
url="Clients"
label="Client"
show-field="name"
value-field="id"
search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}]}"
ng-model="$ctrl.ticket.client.id"
initial-data="$ctrl.ticket.client.id"
order="id">
<tpl-item>
#{{id}} - {{::name}}
</tpl-item>
</vn-autocomplete>
</tpl-body>
<tpl-buttons>
<button response="accept" translate>Transfer client</button>
</tpl-buttons>
</vn-dialog>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>

View File

@ -69,22 +69,6 @@ class Controller extends Descriptor {
// Prevents error when not defined
}
transferClient() {
this.$http.get(`Clients/${this.ticket.client.id}`).then(client => {
const ticket = this.ticket;
let params =
{
clientFk: client.data.id,
addressFk: client.data.defaultAddressFk,
};
this.$http.patch(`Tickets/${ticket.id}`, params);
this.cardReload();
});
}
get filter() {
return this.ticket ?
JSON.stringify({clientFk: this.ticket.clientFk}) : null;

View File

@ -23,4 +23,3 @@ Restore ticket: Restaurar ticket
You are going to restore this ticket: Vas a restaurar este ticket
Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket?
Are you sure you want to refund all?: ¿Seguro que quieres abonar todo?
Transfer client: Transferir cliente