From 93ef3c7feaa9f067673256e7c0800ded283e38cf Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Wed, 7 Feb 2018 08:49:27 +0100 Subject: [PATCH] item history js files implementation --- client/item/src/history/item-history.html | 36 ++++++++++++++++++--- client/item/src/locale/es.yml | 5 ++- services/item/common/methods/item/getLog.js | 27 ++++++++++++++++ services/item/common/models/item.js | 1 + 4 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 services/item/common/methods/item/getLog.js diff --git a/client/item/src/history/item-history.html b/client/item/src/history/item-history.html index 032f17033..1a5a65483 100644 --- a/client/item/src/history/item-history.html +++ b/client/item/src/history/item-history.html @@ -1,5 +1,33 @@ - - - Item history + + + + + Item history + + + + + + + + + + {{::itemLog.originFk}} + {{::itemLog.userFk}} + {{::itemLog.action}} + {{::itemLog.creationDate | date:'dd/MM/yyyy HH:mm'}} + {{::itemLog.description}} + + + No results + + + + + + - \ No newline at end of file + diff --git a/client/item/src/locale/es.yml b/client/item/src/locale/es.yml index d2a302af7..a80590f67 100644 --- a/client/item/src/locale/es.yml +++ b/client/item/src/locale/es.yml @@ -15,4 +15,7 @@ Niche: Nicho Picture: Foto Item pictures: Fotos del artículo Barcode: Código barras -Item barcode: Código de barras del artículo \ No newline at end of file +Item barcode: Código de barras del artículo +Changed by: Cambiado por +Action: Acción +Date: Fecha \ No newline at end of file diff --git a/services/item/common/methods/item/getLog.js b/services/item/common/methods/item/getLog.js new file mode 100644 index 000000000..50d563c08 --- /dev/null +++ b/services/item/common/methods/item/getLog.js @@ -0,0 +1,27 @@ +module.exports = Self => { + Self.remoteMethod('itemLog', { + description: 'Returns the item changes log', + accessType: 'READ', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }], + returns: { + arg: 'data', + type: ['Object'], + root: true + }, + http: { + path: `/:id/itemLog`, + verb: 'get' + } + }); + + Self.itemLog = itemFk => { + let query = `SELECT * FROM vn.itemLog WHERE itemFk = ?`; + return Self.rawSql(query, [itemFk]); + }; +}; diff --git a/services/item/common/models/item.js b/services/item/common/models/item.js index 2c193b587..3cbc622bd 100644 --- a/services/item/common/models/item.js +++ b/services/item/common/models/item.js @@ -1,5 +1,6 @@ module.exports = function(Self) { require('../methods/item/filter.js')(Self); + require('../methods/item/getLog.js')(Self); Self.validatesPresenceOf('name', {message: 'Cannot be blank'}); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});