3888-ticket.expedition_moveExpedition #1097
|
@ -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
|
|||||||
id: {inq: expeditionsIds}
|
id: {inq: expeditionIds}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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
joan
commented
Route id Route id
|
Loading…
Reference in New Issue
Utilizar destroyById() en un bucle. La función destroyAll() no es segura