Add transferclient
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
04be661b68
commit
a43e642ff7
|
@ -93,9 +93,42 @@
|
|||
icon="icon-basketadd">
|
||||
</vn-quick-link>
|
||||
</div>
|
||||
<div ng-transclude="btnFour">
|
||||
<vn-quick-link
|
||||
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>
|
||||
|
|
|
@ -69,6 +69,22 @@ 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;
|
||||
|
|
|
@ -42,4 +42,18 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
|||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
|
||||
describe('transferClient()', () => {
|
||||
it(`should perform two queries, a get to obtain the clientData and a patch to update the ticket`, () => {
|
||||
let client =
|
||||
{
|
||||
clientFk: 1101,
|
||||
addressFk: 1,
|
||||
};
|
||||
$httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client);
|
||||
$httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond();
|
||||
controller.transferClient();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,4 +22,5 @@ SMS Pending payment: 'SMS Pago pendiente'
|
|||
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?
|
||||
Are you sure you want to refund all?: ¿Seguro que quieres abonar todo?
|
||||
Transfer client: Transferir cliente
|
Loading…
Reference in New Issue