refs #5866 fix(transferClient): correct variable name
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-07-21 08:28:19 +02:00
parent cd377c4790
commit eb963ff993
2 changed files with 8 additions and 8 deletions

View File

@ -12,7 +12,7 @@ module.exports = Self => {
http: {source: 'path'}
},
{
arg: 'clientId',
arg: 'clientFk',
type: 'number',
required: true,
},
@ -23,26 +23,26 @@ module.exports = Self => {
}
});
Self.transferClient = async(ctx, ticketId, clientId, options) => {
Self.transferClient = async(ctx, id, clientFk, options) => {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const isEditable = await Self.isEditable(ctx, ticketId, myOptions);
const isEditable = await Self.isEditable(ctx, id, myOptions);
if (!isEditable)
throw new UserError(`The current ticket can't be modified`);
const ticket = await models.Ticket.findById(
ticketId,
id,
{fields: ['id', 'shipped', 'clientFk', 'addressFk']},
myOptions
);
const client = await models.Client.findById(clientId, {fields: ['id', 'defaultAddressFk']}, myOptions);
const client = await models.Client.findById(clientFk, {fields: ['id', 'defaultAddressFk']}, myOptions);
await ticket.updateAttributes({
clientFk: clientId,
clientFk,
addressFk: client.defaultAddressFk,
});
};

View File

@ -97,9 +97,9 @@ class Controller extends Section {
transferClient() {
const ticket = this.ticket;
const clientId = ticket.client.id;
const clientFk = ticket.client.id;
this.$http.patch(`Tickets/${ticket.id}/transferClient`, {clientId})
this.$http.patch(`Tickets/${ticket.id}/transferClient`, {clientFk})
.then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.reload();