This commit is contained in:
parent
b36acee458
commit
30933220ac
|
@ -1,6 +1,21 @@
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
require('../methods/greuge/sumAmount')(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', {
|
Self.validatesLengthOf('description', {
|
||||||
max: 45,
|
max: 45,
|
||||||
message: 'Description should have maximum of 45 characters'
|
message: 'Description should have maximum of 45 characters'
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
"greugeTypeFk": {
|
"greugeTypeFk": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"required": true
|
"required": true
|
||||||
|
},
|
||||||
|
"userFk": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th field="shipped" default-order="DESC" expand>Date</vn-th>
|
<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="description">Comment</vn-th>
|
||||||
<vn-th field="greugeTypeFk">Type</vn-th>
|
<vn-th field="greugeTypeFk">Type</vn-th>
|
||||||
<vn-th field="amount" number>Amount</vn-th>
|
<vn-th field="amount" number>Amount</vn-th>
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="greuge in greuges">
|
<vn-tr ng-repeat="greuge in greuges">
|
||||||
<vn-td shrink-datetime>{{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }}</vn-td>
|
<vn-td shrink-datetime>{{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }}</vn-td>
|
||||||
|
<vn-td>{{::greuge.userFk}}</vn-td>
|
||||||
<vn-td>
|
<vn-td>
|
||||||
<span title="{{::greuge.description}}">{{::greuge.description}}</span>
|
<span title="{{::greuge.description}}">{{::greuge.description}}</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
Date: Fecha
|
Date: Fecha
|
||||||
Comment: Comentario
|
Comment: Comentario
|
||||||
Amount: Importe
|
Amount: Importe
|
||||||
Type: Tipo
|
Type: Tipo
|
||||||
|
Created by: Creado por
|
Loading…
Reference in New Issue