refs #4856 fix: actualizar estado a 'SENDED' movido al back
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2023-03-30 08:14:17 +02:00
parent d066c4ea0b
commit 5a67f47305
5 changed files with 27 additions and 26 deletions

View File

@ -69,6 +69,12 @@ module.exports = Self => {
reason: args.reason || null
}, myOptions);
if (args.state == 'SENDED') {
await workerTimeControlMail.updateAttributes({
sendedCounter: workerTimeControlMail.sendedCounter + 1
}, myOptions);
}
const logRecord = {
originFk: args.workerId,
userFk: userId,

View File

@ -25,6 +25,16 @@ module.exports = Self => {
arg: 'url',
type: 'string',
required: true
},
{
arg: 'workerId',
type: 'number',
required: true
},
{
arg: 'state',
type: 'string',
required: true
}
],
returns: {
@ -37,17 +47,11 @@ module.exports = Self => {
}
});
Self.weeklyHourRecordEmail = async(ctx, recipient, week, year, url) => {
const params = {
recipient: recipient,
lang: ctx.req.getLocale(),
week: week,
year: year,
url: url
};
Self.weeklyHourRecordEmail = async ctx => {
const models = Self.app.models;
const email = new Email('weekly-hour-record', params);
Self.sendTemplate(ctx, 'weekly-hour-record');
return email.send();
return models.WorkerTimeControl.updateWorkerTimeControlMail(ctx);
};
};

View File

@ -28,6 +28,9 @@
},
"reason": {
"type": "string"
},
"sendedCounter": {
"type": "number"
}
},
"acls": [

View File

@ -204,7 +204,7 @@
vn-id="sendEmailConfirmation"
on-accept="$ctrl.resendEmail()"
message="Send time control email">
<tpl-body style="min-width: 500px;">
<tpl-body>
<span translate>Are you sure you want to send it?</span>
</tpl-body>
<tpl-buttons>

View File

@ -379,20 +379,6 @@ class Controller extends Section {
});
}
isSended() {
const params = {
workerId: this.worker.id,
year: this.date.getFullYear(),
week: this.weekNumber,
state: 'SENDED'
};
const query = `WorkerTimeControls/updateWorkerTimeControlMail`;
this.$http.post(query, params).then(() => {
this.getMailStates(this.date);
this.getWeekData();
});
}
changeState(state, reason) {
this.state = state;
this.reason = reason;
@ -423,10 +409,12 @@ class Controller extends Section {
week: this.weekNumber,
year: this.date.getFullYear(),
url: url,
workerId: this.worker.id,
state: 'SENDED'
};
this.$http.post(`WorkerTimeControls/weekly-hour-hecord-email`, params)
.then(() => {
this.isSended();
this.getMailStates(this.date);
this.vnApp.showSuccess(this.$t('Email sended'));
});
}