feat: add backRoutes
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
1894492a2c
commit
deb8a00dfb
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('deleteExpeditions', {
|
||||||
|
description: 'Delete the selected expeditions',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'expeditionsIds',
|
||||||
|
type: ['number'],
|
||||||
|
required: true,
|
||||||
|
description: 'The expeditions ids to delete'
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/deleteExpeditions`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.deleteExpeditions = async(expeditionsIds, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const deletedExpeditions = await models.Expedition.destroyAll({
|
||||||
|
id: {inq: expeditionsIds}
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
return deletedExpeditions;
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,59 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('moveExpeditions', {
|
||||||
|
description: 'Move the selected expeditions to another ticket',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'expeditionsIds',
|
||||||
|
type: ['number'],
|
||||||
|
required: true,
|
||||||
|
description: 'The expeditions ids to nove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'ticketId',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'the ticket id to which the expeditions are added'
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/moveExpeditions`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.moveExpeditions = async(expeditionsIds, ticketId, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const promises = [];
|
||||||
|
for (let expeditionsId of expeditionsIds) {
|
||||||
|
const expeditionToUpdate = await models.Expedition.findById(expeditionsId);
|
||||||
|
const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions);
|
||||||
|
promises.push(expeditionUpdated);
|
||||||
|
}
|
||||||
|
|
||||||
|
const updated = await Promise.all(promises);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
return updated;
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,3 +1,5 @@
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
require('../methods/expedition/filter')(Self);
|
require('../methods/expedition/filter')(Self);
|
||||||
|
require('../methods/expedition/deleteExpeditions')(Self);
|
||||||
|
require('../methods/expedition/moveExpeditions')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
<vn-button icon="keyboard_arrow_down"
|
<vn-button icon="keyboard_arrow_down"
|
||||||
label="Move"
|
label="Move"
|
||||||
ng-click="moreOptions.show($event)"
|
ng-click="moreOptions.show($event)"
|
||||||
ng-show="$ctrl.totalChecked">
|
disabled="!$ctrl.totalChecked">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
<vn-button
|
<vn-button
|
||||||
ng-show="$ctrl.checked.length > 0"
|
disabled="!$ctrl.checked.length"
|
||||||
ng-click="removeConfirm.show()"
|
ng-click="removeConfirm.show()"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
vn-tooltip="Delete expedition">
|
vn-tooltip="Delete expedition">
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Controller extends Section {
|
||||||
const checkedRows = [];
|
const checkedRows = [];
|
||||||
for (let row of rows) {
|
for (let row of rows) {
|
||||||
if (row.checked)
|
if (row.checked)
|
||||||
checkedRows.push(row);
|
checkedRows.push(row.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkedRows;
|
return checkedRows;
|
||||||
|
@ -27,19 +27,15 @@ class Controller extends Section {
|
||||||
return this.checked.length;
|
return this.checked.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
async onRemove() {
|
onRemove() {
|
||||||
const params = [];
|
const params = {expeditionsIds: this.checked};
|
||||||
for (let expedition of this.checked)
|
const query = `Expeditions/deleteExpeditions`;
|
||||||
params.push(expedition.id);
|
this.$http.post(query, params)
|
||||||
|
|
||||||
for (let id of params) {
|
|
||||||
await this.$http.delete(`Expeditions/${id}`)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.vnApp.showSuccess(this.$t('Expedition removed'));
|
this.vnApp.showSuccess(this.$t('Expedition removed'));
|
||||||
this.$state.reload();
|
this.$state.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
createTicket(routeFk) {
|
createTicket(routeFk) {
|
||||||
const date = new Date(); // esta fecha hay que preguntarla a Fran Monsalvez
|
const date = new Date(); // esta fecha hay que preguntarla a Fran Monsalvez
|
||||||
|
@ -54,13 +50,12 @@ class Controller extends Section {
|
||||||
this.$http.post(query, ticketParams).then(res => {
|
this.$http.post(query, ticketParams).then(res => {
|
||||||
if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk});
|
if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk});
|
||||||
|
|
||||||
const params = [];
|
const params = {
|
||||||
for (let expedition of this.checked)
|
expeditionsIds: this.checked,
|
||||||
params.push(expedition.id);
|
ticketId: res.data.id
|
||||||
const expeditionParams = {ticketFk: res.data.id};
|
};
|
||||||
for (let id of params)
|
const query = `Expeditions/moveExpeditions`;
|
||||||
this.$http.patch(`Expeditions/${id}`, expeditionParams);
|
this.$http.post(query, params);
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
this.$state.go('ticket.card.summary', {id: res.data.id});
|
this.$state.go('ticket.card.summary', {id: res.data.id});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
Status log: Hitorial de estados
|
Status log: Hitorial de estados
|
||||||
Expedition removed: Expedición eliminada
|
Expedition removed: Expedición eliminada
|
||||||
|
Move: Mover
|
||||||
|
New ticket without route: Nuevo ticket sin ruta
|
||||||
|
New ticket with route: Nuevo ticket con ruta
|
Loading…
Reference in New Issue