#4507 greuge.js/json now insert userFk @2h
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pau 2022-10-24 09:37:17 +02:00
parent b36acee458
commit 30933220ac
4 changed files with 23 additions and 1 deletions

View File

@ -1,6 +1,21 @@
const LoopBackContext = require('loopback-context');
module.exports = function(Self) {
require('../methods/greuge/sumAmount')(Self);
Self.observe('before save', function(ctx, next) {
const loopBackContext = LoopBackContext.getCurrentContext();
let userFk = loopBackContext.active.accessToken.userId;
if (ctx.instance)
ctx.instance.userFk = userFk;
else
ctx.data.userFk = userFk;
next();
});
Self.validatesLengthOf('description', {
max: 45,
message: 'Description should have maximum of 45 characters'

View File

@ -34,6 +34,10 @@
"greugeTypeFk": {
"type": "number",
"required": true
},
"userFk": {
"type": "number",
"required": true
}
},

View File

@ -29,6 +29,7 @@
<vn-thead>
<vn-tr>
<vn-th field="shipped" default-order="DESC" expand>Date</vn-th>
<vn-th field="userFk">Created by</vn-thfield></vn-th>
<vn-th field="description">Comment</vn-th>
<vn-th field="greugeTypeFk">Type</vn-th>
<vn-th field="amount" number>Amount</vn-th>
@ -37,6 +38,7 @@
<vn-tbody>
<vn-tr ng-repeat="greuge in greuges">
<vn-td shrink-datetime>{{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }}</vn-td>
<vn-td>{{::greuge.userFk}}</vn-td>
<vn-td>
<span title="{{::greuge.description}}">{{::greuge.description}}</span>
</vn-td>

View File

@ -1,4 +1,5 @@
Date: Fecha
Comment: Comentario
Amount: Importe
Type: Tipo
Type: Tipo
Created by: Creado por