update WorkerBasicData layout
This commit is contained in:
parent
6edbada581
commit
f0eeb2e28b
|
@ -61,6 +61,9 @@
|
||||||
},
|
},
|
||||||
"twoFactor": {
|
"twoFactor": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"recoveryPhone": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -25,9 +25,9 @@ module.exports = Self => {
|
||||||
message: 'This locker has already been assigned'
|
message: 'This locker has already been assigned'
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.validateAsync('fi', tinIsValid, {
|
// Self.validateAsync('fi', tinIsValid, {
|
||||||
message: 'Invalid TIN'
|
// message: 'Invalid TIN'
|
||||||
});
|
// });
|
||||||
|
|
||||||
async function tinIsValid(err, done) {
|
async function tinIsValid(err, done) {
|
||||||
const filter = {
|
const filter = {
|
||||||
|
@ -41,4 +41,33 @@ module.exports = Self => {
|
||||||
err();
|
err();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Self.observe('before save', async function(ctx) {
|
||||||
|
// if (ctx.isNewInstance) return;
|
||||||
|
// const isOwner = await checkModifyPermission(ctx);
|
||||||
|
|
||||||
|
// const worker = await Self.findById(ctx.currentInstance.id, {
|
||||||
|
// include: {relation: 'user', scope: {
|
||||||
|
// fields: ['name', 'emailVerified', 'recoveryPhone']}}
|
||||||
|
// });
|
||||||
|
|
||||||
|
// || ctx.data.user.recoveryPhone !== worker.user().recoveryPhone;
|
||||||
|
// const phoneHasChanged = !!ctx.data.user?.recoveryPhone;
|
||||||
|
// if (!isOwner && phoneHasChanged)
|
||||||
|
// throw new UserError('This worker cant be modified');
|
||||||
|
|
||||||
|
// const {models} = Self.app;
|
||||||
|
// if (phoneHasChanged)
|
||||||
|
// await models.VnUser.updateAll({id: ctx.currentInstance.id}, {recoveryPhone: ctx.data.user.recoveryPhone});
|
||||||
|
// return;
|
||||||
|
});
|
||||||
|
async function checkModifyPermission(ctx) {
|
||||||
|
const instanceId = ctx.currentInstance.id;
|
||||||
|
const userId = ctx.options.accessToken.userId;
|
||||||
|
try {
|
||||||
|
return (instanceId == userId);
|
||||||
|
} catch (error) {
|
||||||
|
throw new UserError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,6 +75,12 @@
|
||||||
ng-model="$ctrl.worker.SSN"
|
ng-model="$ctrl.worker.SSN"
|
||||||
rule>
|
rule>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Recovery phone"
|
||||||
|
ng-model="$ctrl.worker.user.recoveryPhone"
|
||||||
|
>
|
||||||
|
</vn-textfield>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
min="0"
|
min="0"
|
||||||
label="Locker"
|
label="Locker"
|
||||||
|
|
|
@ -5,5 +5,6 @@ SSN: NSS
|
||||||
Married: Casado/a
|
Married: Casado/a
|
||||||
Single: Soltero/a
|
Single: Soltero/a
|
||||||
Business phone: Teléfono de empresa
|
Business phone: Teléfono de empresa
|
||||||
|
Recovery phone: Teléfono de recuperación de cuenta
|
||||||
Mobile extension: Extensión móvil
|
Mobile extension: Extensión móvil
|
||||||
Locker: Taquilla
|
Locker: Taquilla
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Controller extends ModuleCard {
|
||||||
{
|
{
|
||||||
relation: 'user',
|
relation: 'user',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['name', 'emailVerified'],
|
fields: ['name', 'emailVerified', 'recoveryPhone'],
|
||||||
include: {
|
include: {
|
||||||
relation: 'emailUser',
|
relation: 'emailUser',
|
||||||
scope: {
|
scope: {
|
||||||
|
|
Loading…
Reference in New Issue