pull request changed
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-04-21 09:34:13 +02:00
parent c1edb8206e
commit 0ec51202e0
4 changed files with 12 additions and 8 deletions

View File

@ -1,6 +1,6 @@
module.exports = Self => {
Self.remoteMethodCtx('deleteSalesClaimed', {
description: 'Deletes the selected sales',
Self.remoteMethodCtx('deleteClamedSales', {
description: 'Deletes the claimed sales',
accessType: 'WRITE',
accepts: [{
arg: 'sales',
@ -13,12 +13,12 @@ module.exports = Self => {
root: true
},
http: {
path: `/deleteSalesClaimed`,
path: `/deleteClamedSales`,
verb: 'POST'
}
});
Self.deleteSalesClaimed = async(ctx, sales, options) => {
Self.deleteClamedSales = async(ctx, sales, options) => {
const models = Self.app.models;
const myOptions = {};
const tx = await Self.beginTransaction({});

View File

@ -35,14 +35,18 @@ module.exports = Self => {
try {
const models = Self.app.models;
const promises = [];
for (let row of rows) {
const claimEnd = await models.ClaimEnd.findById(row.id, null, myOptions);
await claimEnd.updateAttribute('claimDestinationFk', claimDestinationFk, myOptions);
const updatedClaimEnd = claimEnd.updateAttribute('claimDestinationFk', claimDestinationFk, myOptions);
promises.push(updatedClaimEnd);
}
const updatedSales = await Promise.all(promises);
if (tx) await tx.commit();
return {};
return updatedSales;
} catch (e) {
if (tx) await tx.rollback();
throw e;

View File

@ -1,4 +1,4 @@
module.exports = Self => {
require('../methods/claim-end/filter')(Self);
require('../methods/claim-end/deleteSalesClaimed')(Self);
require('../methods/claim-end/deleteClamedSales')(Self);
};

View File

@ -93,7 +93,7 @@ export default class Controller extends Section {
removeSales(saleClaimed) {
const params = {sales: [saleClaimed]};
this.$http.post(`ClaimEnds/deleteSalesClaimed`, params).then(() => {
this.$http.post(`ClaimEnds/deleteClamedSales`, params).then(() => {
this.$.model.refresh();
this.vnApp.showSuccess(this.$t('Data saved!'));
});