feat: cancelar petición cuando esta calculando el packaging
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-10-26 10:36:41 +02:00
parent 0f57a40aac
commit 350c516bb1
5 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,6 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('InvoiceOut', 'clientToInvoice', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
('InvoiceOut', 'clientsToInvoice', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES

View File

@ -1,5 +1,5 @@
module.exports = Self => {
Self.remoteMethodCtx('clientToInvoice', {
Self.remoteMethodCtx('clientsToInvoice', {
description: 'Get the clients to make global invoicing',
accessType: 'WRITE',
accepts: [
@ -38,12 +38,12 @@ module.exports = Self => {
type: 'object'
}],
http: {
path: '/clientToInvoice',
path: '/clientsToInvoice',
verb: 'POST'
}
});
Self.clientToInvoice = async(ctx, options) => {
Self.clientsToInvoice = async(ctx, options) => {
const args = ctx.args;
let tx;
const myOptions = {};

View File

@ -7,7 +7,7 @@ module.exports = Self => {
require('../methods/invoiceOut/book')(Self);
require('../methods/invoiceOut/createPdf')(Self);
require('../methods/invoiceOut/createManualInvoice')(Self);
require('../methods/invoiceOut/clientToInvoice')(Self);
require('../methods/invoiceOut/clientsToInvoice')(Self);
require('../methods/invoiceOut/invoiceClient')(Self);
require('../methods/invoiceOut/refund')(Self);
require('../methods/invoiceOut/invoiceEmail')(Self);

View File

@ -50,6 +50,11 @@ class Controller extends Dialog {
this.$.invoiceButton.disabled = false;
}
cancelRequest() {
this.canceler = this.$q.defer();
return {timeout: this.canceler.promise};
}
invoiceOut(invoice, clientsAndAddresses) {
const [clientAndAddress] = clientsAndAddresses;
if (!clientAndAddress) return;
@ -63,10 +68,8 @@ class Controller extends Dialog {
minShipped: invoice.minShipped,
};
this.canceler = this.$q.defer();
const options = {
timeout: this.canceler.promise
};
const options = this.cancelRequest();
return this.$http.post(`InvoiceOuts/invoiceClient`, params, options)
.then(() => {
@ -93,7 +96,9 @@ class Controller extends Dialog {
this.$.invoiceButton.disabled = true;
this.packageInvoicing = true;
this.$http.post(`InvoiceOuts/clientToInvoice`, this.invoice)
const options = this.cancelRequest();
this.$http.post(`InvoiceOuts/clientsToInvoice`, this.invoice, options)
.then(res => {
this.packageInvoicing = false;
const invoice = res.data.invoice;

View File

@ -106,7 +106,7 @@ describe('InvoiceOut', () => {
invoice: controller.invoice
};
$httpBackend.expect('POST', `InvoiceOuts/clientToInvoice`).respond(response);
$httpBackend.expect('POST', `InvoiceOuts/clientsToInvoice`).respond(response);
$httpBackend.expect('POST', `InvoiceOuts/invoiceClient`).respond({id: 1});
controller.responseHandler('accept');
$httpBackend.flush();