From 4d1609c445d0f2912eb6d514bdd95c08c1609354 Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 27 Mar 2018 14:24:47 +0200 Subject: [PATCH] Tarea #170 Mostrar modelo ticketTracking --- client/ticket/routes.json | 16 +++++++++++++++- client/ticket/src/ticket.js | 3 ++- .../src/tracking/{tracking.html => index.html} | 10 ++++------ .../src/tracking/{tracking.js => index.js} | 2 +- client/ticket/src/tracking/locale/es.yml | 5 ----- services/ticket/common/models/ticketTracking.js | 11 +++++++++++ .../ticket/common/models/ticketTracking.json | 3 ++- 7 files changed, 35 insertions(+), 15 deletions(-) rename client/ticket/src/tracking/{tracking.html => index.html} (90%) rename client/ticket/src/tracking/{tracking.js => index.js} (79%) delete mode 100644 client/ticket/src/tracking/locale/es.yml diff --git a/client/ticket/routes.json b/client/ticket/routes.json index 49cb84b9c..41cb8057b 100644 --- a/client/ticket/routes.json +++ b/client/ticket/routes.json @@ -107,8 +107,14 @@ } }, { - "url" : "/tracking", + "url": "/tracking", "state": "ticket.card.tracking", + "abstract": true, + "component": "ui-view" + }, + { + "url" : "/index", + "state": "ticket.card.tracking.index", "component": "vn-ticket-tracking", "params": { "ticket": "$ctrl.ticket" @@ -118,6 +124,14 @@ "icon": "remove_red_eye" } }, + { + "url": "/edit", + "state": "ticket.card.tracking.edit", + "component": "vn-ticket-tracking-edit", + "params": { + "ticket": "$ctrl.ticket" + } + }, { "url": "/create", "state": "ticket.card.tracking.create", diff --git a/client/ticket/src/ticket.js b/client/ticket/src/ticket.js index 5a84ce427..c90465231 100644 --- a/client/ticket/src/ticket.js +++ b/client/ticket/src/ticket.js @@ -10,6 +10,7 @@ import './expedition/ticket-expedition'; import './volume/ticket-volume'; import './package/package'; import './sale/sale'; -import './tracking/tracking'; +import './tracking/index'; +import './tracking/edit/edit'; import './fetched-tags/fetched-tags'; import './sale-checked/sale-checked'; diff --git a/client/ticket/src/tracking/tracking.html b/client/ticket/src/tracking/index.html similarity index 90% rename from client/ticket/src/tracking/tracking.html rename to client/ticket/src/tracking/index.html index ec827fac3..3d287d940 100644 --- a/client/ticket/src/tracking/tracking.html +++ b/client/ticket/src/tracking/index.html @@ -1,5 +1,5 @@ - + Tracking @@ -7,7 +7,6 @@ - {{::ticket.state.name}} - {{::ticket.worker.firstName}} {{::ticket.worker.name}} - {{::ticket.created | date:'dd/MM/yyyy HH:mm' }} - + {{::ticket.worker.firstName}} {{ticket.worker.name}} + {{::ticket.created | date:'dd/MM/yyyy HH:mm'}} No results @@ -26,6 +24,6 @@ - + \ No newline at end of file diff --git a/client/ticket/src/tracking/tracking.js b/client/ticket/src/tracking/index.js similarity index 79% rename from client/ticket/src/tracking/tracking.js rename to client/ticket/src/tracking/index.js index be147ed91..fc0777775 100644 --- a/client/ticket/src/tracking/tracking.js +++ b/client/ticket/src/tracking/index.js @@ -2,6 +2,6 @@ import ngModule from '../module'; import FilterTicketList from '../filter-ticket-list'; ngModule.component('vnTicketTracking', { - template: require('./tracking.html'), + template: require('./index.html'), controller: FilterTicketList }); diff --git a/client/ticket/src/tracking/locale/es.yml b/client/ticket/src/tracking/locale/es.yml deleted file mode 100644 index e61e1dd24..000000000 --- a/client/ticket/src/tracking/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Date : Fecha -Employee : Empleado -State: Estado -Tracking: Revisión -Created : Añadido \ No newline at end of file diff --git a/services/ticket/common/models/ticketTracking.js b/services/ticket/common/models/ticketTracking.js index ab8a13f1e..91f890af5 100644 --- a/services/ticket/common/models/ticketTracking.js +++ b/services/ticket/common/models/ticketTracking.js @@ -1,3 +1,14 @@ module.exports = function(Self) { require('../methods/ticketTracking/filter')(Self); + + Self.observe('before save', function(ctx, next) { + let token = ctx.options.accessToken; + let userId = token && token.userId; + + Self.app.models.Worker.findOne({where: {userFk: userId}}, (err, user) => { + if (err) return next(err); + ctx.instance.workerFk = user.id; + next(); + }); + }); }; diff --git a/services/ticket/common/models/ticketTracking.json b/services/ticket/common/models/ticketTracking.json index b1f2769d4..176f84b27 100644 --- a/services/ticket/common/models/ticketTracking.json +++ b/services/ticket/common/models/ticketTracking.json @@ -3,7 +3,8 @@ "base": "VnModel", "options": { "mysql": { - "table": "ticketTracking" + "table": "ticketTracking", + "database": "vn" } }, "properties": {