From 993ae11277c7a96171a0408a0f9231b699f58172 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 9 Nov 2022 09:19:56 +0100 Subject: [PATCH] refs #3302 --- front/salix/components/log/index.html | 55 ++++++++++++--------------- front/salix/components/log/index.js | 31 ++++++++++++--- front/salix/components/log/style.scss | 18 ++++++++- 3 files changed, 68 insertions(+), 36 deletions(-) diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index 0a0449038..ecee89097 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -1,10 +1,10 @@ - @@ -13,12 +13,11 @@ Date - Author + User Model Action Name - Before - After + Changes @@ -62,27 +61,23 @@ {{::log.changedModelValue}} - - -
- - -
-
-
- -
- - -
-
+ + + + + + + + + + + + + + + +
FieldBeforeAfter
{{prop.name}}{{::$ctrl.formatValue(prop.old)}}{{::$ctrl.formatValue(prop.new)}}
{{::log.description}} @@ -96,4 +91,4 @@ - \ No newline at end of file + diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index c5a4febcc..d7619e34c 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -33,12 +33,33 @@ export default class Controller extends Section { set logs(value) { this._logs = value; + if (!this.logs) return; + for (const log of value) { + // log.oldProperties = this.getInstance(log.oldInstance); + // log.newProperties = this.getInstance(log.newInstance); - if (this.logs) { - this.logs.forEach(log => { - log.oldProperties = this.getInstance(log.oldInstance); - log.newProperties = this.getInstance(log.newInstance); - }); + let props = [].concat( + Object.keys(log.oldInstance), + Object.keys(log.newInstance) + ); + props = [...new Set(props)]; + log.props = []; + for (const prop of props) { + log.props.push({ + name: prop, + old: log.oldInstance[prop], + new: log.newInstance[prop] + }); + } + } + } + + formatValue(value) { + switch (typeof value) { + case 'boolean': + return value ? '✓' : '✗'; + default: + return value; } } diff --git a/front/salix/components/log/style.scss b/front/salix/components/log/style.scss index ca1de113a..58e4b8e3f 100644 --- a/front/salix/components/log/style.scss +++ b/front/salix/components/log/style.scss @@ -23,6 +23,22 @@ vn-log { display: block; } } + .attributes { + width: 100%; + + tr { + height: 10px; + + & > td { + padding: 2px; + width: 33%; + } + & > td.field, + & > th.field { + color: gray; + } + } + } } .ellipsis { white-space: nowrap; @@ -40,4 +56,4 @@ vn-log { .alignSpan { overflow: hidden; display: inline-block; -} \ No newline at end of file +}