refs #5137 sql moved to template
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
ca9d76db77
commit
059467a383
|
@ -5,23 +5,21 @@ module.exports = function(Self) {
|
|||
const options = ctx.options;
|
||||
|
||||
if (!instance.sectorFk || !instance.labelerFk) return;
|
||||
|
||||
const sector = await models.Sector.findById(instance.sectorFk, {
|
||||
fields: ['description', 'mainPrinterFk']
|
||||
fields: ['mainPrinterFk']
|
||||
}, options);
|
||||
|
||||
if (sector.mainPrinterFk && sector.mainPrinterFk != instance.labelerFk) {
|
||||
const userId = ctx.options.accessToken.userId;
|
||||
const user = await models.VnUser.findById(userId, {fields: ['nickname']}, options);
|
||||
const labeler = await models.Printer.findById(instance.labelerFk, {fields: ['name']}, options);
|
||||
const mainPrinter = await models.Printer.findById(sector.mainPrinterFk, {fields: ['name']}, options);
|
||||
await models.NotificationQueue.create({
|
||||
notificationFk: 'not-main-printer-configured',
|
||||
authorFk: userId,
|
||||
params: JSON.stringify(
|
||||
{
|
||||
'labeler': `#${instance.labelerFk} ${labeler.name}`,
|
||||
'sector': `#${instance.sectorFk} ${sector.description}`,
|
||||
'mainPrinter': `#${sector.mainPrinterFk} ${mainPrinter.name}`,
|
||||
'worker': `#${userId} ${user.nickname}`
|
||||
'labelerId': instance.labelerFk,
|
||||
'sectorId': instance.sectorFk,
|
||||
'workerId': userId
|
||||
}
|
||||
)
|
||||
}, options);
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
subject: Not main printer configured
|
||||
title: Not main printer configured
|
||||
description: Printer {0} has been configured in sector {1} (the main printer for that sector is {2}). Ask the worker {3}
|
||||
description: 'Printer #{0} {1} has been configured in sector #{2} {3} (the main printer for that sector is #{4} {5}). Ask the worker {6}.'
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
subject: Configurada impresora no principal
|
||||
title: Configurada impresora no principal
|
||||
description: Se ha configurado la impresora {0} en el sector {1} (la impresora principal de ese sector es la {2}). Preguntar al trabajador {3}.
|
||||
description: 'Se ha configurado la impresora #{0} {1} en el sector #{2} {3} (la impresora principal de ese sector es la #{4} {5}). Preguntar al trabajador {6}.'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="grid-row">
|
||||
<div class="grid-block vn-pa-ml">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p v-html="$t('description', [labeler, sector, mainPrinter, worker])"></p>
|
||||
<p v-html="$t('description', [labeler.id, labeler.name, sector.id, sector.description, mainPrinter.id, mainPrinter.name, worker.nickname])"></p>
|
||||
</div>
|
||||
</div>
|
||||
</email-body>
|
||||
|
|
|
@ -3,24 +3,30 @@ const emailBody = new Component('email-body');
|
|||
|
||||
module.exports = {
|
||||
name: 'not-main-printer-configured',
|
||||
async serverPrefetch() {
|
||||
this.sector = await this.findOneFromDef('sector', [this.sectorId]);
|
||||
|
||||
if (!this.sector)
|
||||
throw new Error('Something went wrong');
|
||||
|
||||
this.labeler = await this.findOneFromDef('printer', [this.labelerId]);
|
||||
this.mainPrinter = await this.findOneFromDef('printer', [this.sector.mainPrinterFk]);
|
||||
this.worker = await this.findOneFromDef('worker', [this.workerId]);
|
||||
},
|
||||
components: {
|
||||
'email-body': emailBody.build(),
|
||||
},
|
||||
props: {
|
||||
labeler: {
|
||||
type: String,
|
||||
labelerId: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
sector: {
|
||||
type: String,
|
||||
sectorId: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
mainPrinter: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
worker: {
|
||||
type: String,
|
||||
workerId: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
SELECT id, name
|
||||
FROM vn.printer
|
||||
WHERE id = ?
|
|
@ -0,0 +1,3 @@
|
|||
SELECT id, description, mainPrinterFk
|
||||
FROM vn.sector
|
||||
WHERE id = ?
|
|
@ -0,0 +1,3 @@
|
|||
SELECT nickname
|
||||
FROM account.user
|
||||
WHERE id = ?
|
Loading…
Reference in New Issue