Merge branch 'dev' into 4767-route.index-delete-route
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pau 2022-11-21 08:46:32 +00:00
commit b788415920
6 changed files with 36 additions and 5 deletions

View File

@ -0,0 +1 @@
ALTER TABLE `vn`.`greuge` CHANGE `userFK` `userFk` int(10) unsigned DEFAULT NULL NULL;

View File

@ -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'

View File

@ -2,9 +2,9 @@
"name": "Greuge", "name": "Greuge",
"base": "Loggable", "base": "Loggable",
"log": { "log": {
"model": "ClientLog", "model": "ClientLog",
"relation": "client", "relation": "client",
"showField": "description" "showField": "description"
}, },
"options": { "options": {
"mysql": { "mysql": {
@ -35,7 +35,6 @@
"type": "number", "type": "number",
"required": true "required": true
} }
}, },
"relations": { "relations": {
"client": { "client": {
@ -52,6 +51,11 @@
"type": "belongsTo", "type": "belongsTo",
"model": "GreugeType", "model": "GreugeType",
"foreignKey": "greugeTypeFk" "foreignKey": "greugeTypeFk"
},
"user": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "userFk"
} }
} }
} }

View File

@ -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,8 @@
<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><span ng-click="workerDescriptor.show($event, greuge.user.id)"
class="link">{{::greuge.user.name}}</span></vn-td>
<vn-td> <vn-td>
<span title="{{::greuge.description}}">{{::greuge.description}}</span> <span title="{{::greuge.description}}">{{::greuge.description}}</span>
</vn-td> </vn-td>
@ -57,3 +60,4 @@
vn-bind="+" vn-bind="+"
fixed-bottom-right> fixed-bottom-right>
</vn-float-button> </vn-float-button>
<vn-worker-descriptor-popover vn-id="workerDescriptor"></vn-worker-descriptor-popover>

View File

@ -8,6 +8,12 @@ class Controller extends Section {
include: [ include: [
{ {
relation: 'greugeType', relation: 'greugeType',
scope: {
fields: ['id', 'name']
},
},
{
relation: 'user',
scope: { scope: {
fields: ['id', 'name'] fields: ['id', 'name']
} }

View File

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