From 86f6253ed75b0c60932d190af5983cb8014b5668 Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 23 Oct 2018 11:34:07 +0200 Subject: [PATCH] #707 Loggable --- client/client/src/history/index.html | 69 ++++++++++++++++--------- client/client/src/history/index.js | 18 ++++--- client/client/src/history/index.spec.js | 10 ++-- client/client/src/history/locale/es.yml | 6 +-- client/client/src/history/style.scss | 30 +++++++++++ 5 files changed, 96 insertions(+), 37 deletions(-) create mode 100644 client/client/src/history/style.scss diff --git a/client/client/src/history/index.html b/client/client/src/history/index.html index 0eb658fe8..a88e27dbd 100644 --- a/client/client/src/history/index.html +++ b/client/client/src/history/index.html @@ -1,10 +1,9 @@ + data="$ctrl.logs"> @@ -15,39 +14,63 @@ Date - Model - Action - Changed by - Before - After + Changed by + Model + Action + Instance + Before + After - + {{::clientLog.creationDate | date:'dd/MM/yyyy HH:mm'}} +
+
+ Changed by: + {{::clientLog.user.name}} +
+
+ Model: + {{::clientLog.changedModel}} +
+
+ Action: + {{::clientLog.action}} +
+
+ Instance: + {{::clientLog.changedModelValue}} +
+
- - {{::clientLog.model}} - - - {{::clientLog.action}} - - + {{::clientLog.user.name}} - + + {{::clientLog.changedModel}} + + + {{::clientLog.action}} + + + {{::clientLog.changedModelValue}} + + - - +
+ {{::old.key}}: + {{::old.value}} +
- + - - +
+ {{::new.key}}: + {{::new.value}} +
diff --git a/client/client/src/history/index.js b/client/client/src/history/index.js index dbabcbfe0..7f63b674e 100644 --- a/client/client/src/history/index.js +++ b/client/client/src/history/index.js @@ -1,4 +1,5 @@ import ngModule from '../module'; +import './style.scss'; class Controller { constructor($scope, $stateParams) { @@ -14,13 +15,18 @@ class Controller { }; } - onDataChange() { - let logs = this.$scope.model.data; + get logs() { + return this._logs; + } - logs.forEach(log => { - log.oldProperties = this.getInstance(log.oldInstance); - log.newProperties = this.getInstance(log.newInstance); - }); + set logs(value) { + this._logs = value; + + if (this.logs) + this.logs.forEach(log => { + log.oldProperties = this.getInstance(log.oldInstance); + log.newProperties = this.getInstance(log.newInstance); + }); } getInstance(instance) { diff --git a/client/client/src/history/index.spec.js b/client/client/src/history/index.spec.js index 15785d041..99f75b201 100644 --- a/client/client/src/history/index.spec.js +++ b/client/client/src/history/index.spec.js @@ -7,20 +7,20 @@ describe('Client', () => { let controller; beforeEach(() => { - angular.mock.module('client'); + ngModule('client'); }); beforeEach(angular.mock.inject((_$componentController_, $rootScope) => { $componentController = _$componentController_; $scope = $rootScope.$new(); controller = $componentController('vnClientHistory', {$scope: $scope}); - controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]} + controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]}; })); - describe('onDataChange()', () => { + describe('logs setter', () => { it('should call the function getInstance() twice', () => { - spyOn(controller, 'getInstance').and.callFake(() => {}); - controller.onDataChange(); + spyOn(controller, 'getInstance'); + controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}]; expect(controller.getInstance.calls.count()).toBe(2); expect(controller.getInstance).toHaveBeenCalledWith({id: 1}); diff --git a/client/client/src/history/locale/es.yml b/client/client/src/history/locale/es.yml index d1c4318ee..75deeb63b 100644 --- a/client/client/src/history/locale/es.yml +++ b/client/client/src/history/locale/es.yml @@ -3,7 +3,7 @@ Action: Acción Changed by: Cambiado por Before: Antes After: Despues -update: Actualizar -Create: Crear History: Historial -insert: Crear \ No newline at end of file +insert: Crear +delete: Eliminar +update: Actualizar \ No newline at end of file diff --git a/client/client/src/history/style.scss b/client/client/src/history/style.scss new file mode 100644 index 000000000..f36e158cb --- /dev/null +++ b/client/client/src/history/style.scss @@ -0,0 +1,30 @@ +@import 'colors'; + +vn-client-history { + vn-td { + vertical-align: initial !important; + } + .changes { + display: none; + } + .label { + color: $secondary-font-color; + } + .value { + color: $main-font-color; + } + + .after, .before { + max-width: 250px; + } + + @media screen and (max-width: 1570px) { + .expendable { + display: none; + } + .changes { + padding-top: 10px; + display: block; + } + } +} \ No newline at end of file