3888-ticket.expedition_moveExpedition #1097

Merged
vicent merged 26 commits from 3888-ticket.expedition_moveExpedition into dev 2022-11-02 13:54:11 +00:00
4 changed files with 10 additions and 9 deletions
Showing only changes of commit 5fce93abd5 - Show all commits

View File

@ -4,7 +4,7 @@ module.exports = Self => {
description: 'Delete the selected expeditions', description: 'Delete the selected expeditions',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [{ accepts: [{
arg: 'expeditionsIds', arg: 'expeditionIds',
type: ['number'], type: ['number'],
required: true, required: true,
description: 'The expeditions ids to delete' description: 'The expeditions ids to delete'
@ -19,7 +19,7 @@ module.exports = Self => {
} }
}); });
Self.deleteExpeditions = async(expeditionsIds, options) => { Self.deleteExpeditions = async(expeditionIds, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -34,7 +34,7 @@ module.exports = Self => {
try { try {
const deletedExpeditions = await models.Expedition.destroyAll({ const deletedExpeditions = await models.Expedition.destroyAll({
vicent marked this conversation as resolved Outdated
Outdated
Review

Utilizar destroyById() en un bucle. La función destroyAll() no es segura

Utilizar destroyById() en un bucle. La función destroyAll() no es segura
id: {inq: expeditionsIds} id: {inq: expeditionIds}
}, myOptions); }, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -4,7 +4,7 @@ module.exports = Self => {
description: 'Move the selected expeditions to another ticket', description: 'Move the selected expeditions to another ticket',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [{ accepts: [{
arg: 'expeditionsIds', arg: 'expeditionIds',
type: ['number'], type: ['number'],
required: true, required: true,
description: 'The expeditions ids to nove' description: 'The expeditions ids to nove'
@ -25,7 +25,7 @@ module.exports = Self => {
} }
}); });
Self.moveExpeditions = async(expeditionsIds, ticketId, options) => { Self.moveExpeditions = async(expeditionIds, ticketId, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -40,7 +40,7 @@ module.exports = Self => {
try { try {
const promises = []; const promises = [];
for (let expeditionsId of expeditionsIds) { for (let expeditionsId of expeditionIds) {
const expeditionToUpdate = await models.Expedition.findById(expeditionsId); const expeditionToUpdate = await models.Expedition.findById(expeditionsId);
const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions);
promises.push(expeditionUpdated); promises.push(expeditionUpdated);

View File

@ -63,7 +63,7 @@ describe('Ticket', () => {
it('should make a query and then call to the model refresh() method', () => { it('should make a query and then call to the model refresh() method', () => {
jest.spyOn($scope.model, 'refresh'); jest.spyOn($scope.model, 'refresh');
const expectedParams = {expeditionsIds: [1, 2]}; const expectedParams = {expeditionIds: [1, 2]};
$httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200); $httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200);
controller.onRemove(); controller.onRemove();
$httpBackend.flush(); $httpBackend.flush();
@ -97,7 +97,7 @@ describe('Ticket', () => {
const expectedResponse = {id: ticketIdToTransfer}; const expectedResponse = {id: ticketIdToTransfer};
const expectedParams = { const expectedParams = {
expeditionsIds: [1, 2], expeditionIds: [1, 2],
ticketId: 28 ticketId: 28
}; };
$httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse);

View File

@ -3,3 +3,4 @@ Expedition removed: Expedición eliminada
Move: Mover Move: Mover
New ticket without route: Nuevo ticket sin ruta New ticket without route: Nuevo ticket sin ruta
New ticket with route: Nuevo ticket con ruta New ticket with route: Nuevo ticket con ruta
Id route: Id ruta
vicent marked this conversation as resolved Outdated
Outdated
Review

Route id

Route id