diff --git a/front/salix/components/index.js b/front/salix/components/index.js index 5167b21d69..ce4ad585aa 100644 --- a/front/salix/components/index.js +++ b/front/salix/components/index.js @@ -15,3 +15,4 @@ import './topbar/topbar'; import './user-popover'; import './upload-photo'; import './bank-entity'; +import './log'; diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html new file mode 100644 index 0000000000..bcb17d8d7b --- /dev/null +++ b/front/salix/components/log/index.html @@ -0,0 +1,93 @@ + + + + + + + + Date + Author + Model + Action + Name + Before + After + + + + + + {{::log.creationDate | date:'dd/MM/yyyy HH:mm'}} + + + Changed by: + {{::log.user.name || 'System' | translate}} + + + + Model: + {{::log.changedModel | dashIfEmpty}} + + + Action: + {{::$ctrl.actionsText[log.action] | dashIfEmpty}} + + + Name: + {{::log.changedModelValue | dashIfEmpty}} + + + + + {{::log.user.name || 'System' | translate}} + + + + {{::log.changedModel}} + + + {{::$ctrl.actionsText[log.action]}} + + + {{::log.changedModelValue}} + + + + + {{::old.key}}: + + {{::old.value | dashIfEmpty}} + + + + + + + + {{::new.key}}: + + {{::new.value | dashIfEmpty}} + + + + + + {{::log.description}} + + + + + + + + + + + \ No newline at end of file diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js new file mode 100644 index 0000000000..c5a4febcc8 --- /dev/null +++ b/front/salix/components/log/index.js @@ -0,0 +1,75 @@ +import ngModule from '../../module'; +import Section from '../section'; +import './style.scss'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + this.actionsText = { + 'insert': 'Creates', + 'update': 'Updates', + 'delete': 'Deletes', + 'select': 'Views' + }; ``; + this.filter = { + include: [{ + relation: 'user', + scope: { + fields: ['name'], + include: { + relation: 'worker', + scope: { + fields: ['id'] + } + } + }, + }], + }; + } + + get logs() { + return this._logs; + } + + 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) { + const properties = []; + let validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/; + + if (typeof instance == 'object' && instance != null) { + Object.keys(instance).forEach(property => { + if (validDate.test(instance[property])) + instance[property] = new Date(instance[property]).toLocaleString('es-ES'); + + properties.push({key: property, value: instance[property]}); + }); + return properties; + } + return null; + } + + showWorkerDescriptor(event, workerId) { + if (!workerId) return; + this.$.workerDescriptor.show(event.target, workerId); + } +} + +ngModule.vnComponent('vnLog', { + controller: Controller, + template: require('./index.html'), + bindings: { + model: '<', + originId: '<', + url: '@' + } +}); diff --git a/modules/worker/front/log/locale/es.yml b/front/salix/components/log/locale/es.yml similarity index 100% rename from modules/worker/front/log/locale/es.yml rename to front/salix/components/log/locale/es.yml diff --git a/modules/worker/front/log/style.scss b/front/salix/components/log/style.scss similarity index 86% rename from modules/worker/front/log/style.scss rename to front/salix/components/log/style.scss index 351ceccbd9..ca1de113a3 100644 --- a/modules/worker/front/log/style.scss +++ b/front/salix/components/log/style.scss @@ -31,6 +31,12 @@ vn-log { text-overflow: ellipsis; display: inline-block; } +.no-ellipsize, +[no-ellipsize] { + text-overflow: ''; + white-space: normal; + overflow: auto; +} .alignSpan { overflow: hidden; display: inline-block; diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js index 00b4bdaa85..f703e7c213 100644 --- a/modules/worker/front/index.js +++ b/modules/worker/front/index.js @@ -13,7 +13,6 @@ import './department'; import './calendar'; import './time-control'; import './log'; -import './worker-log'; import './dms/index'; import './dms/create'; import './dms/edit'; diff --git a/modules/worker/front/log/index.html b/modules/worker/front/log/index.html index f8e03239e5..090dbf2e3d 100644 --- a/modules/worker/front/log/index.html +++ b/modules/worker/front/log/index.html @@ -1,113 +1 @@ - - - - - - - - Date - Author - Model - Action - Name - Before - After - - - - - - {{::log.creationDate | date:'dd/MM/yyyy HH:mm'}} - - - Changed by: - {{::log.user.name || 'System' | translate}} - - - - Model: - {{::log.changedModel | dashIfEmpty}} - - - Action: - {{::$ctrl.actionsText[log.action] | dashIfEmpty}} - - - Name: - {{::log.changedModelValue | dashIfEmpty}} - - - - - {{::log.user.name || 'System' | translate}} - - - - {{::log.changedModel}} - - - {{::$ctrl.actionsText[log.action]}} - - - {{::log.changedModelValue}} - - - - - {{::old.key}}: - - {{::old.value | dashIfEmpty}} - - - - - - - - {{::new.key}}: - - {{::new.value | dashIfEmpty}} - - - - - - {{::log.description}} - - - - - - - - - - - + \ No newline at end of file diff --git a/modules/worker/front/log/index.js b/modules/worker/front/log/index.js index ca64bed17f..e30ce7e229 100644 --- a/modules/worker/front/log/index.js +++ b/modules/worker/front/log/index.js @@ -1,75 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -import './style.scss'; -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.actionsText = { - 'insert': 'Creates', - 'update': 'Updates', - 'delete': 'Deletes', - 'select': 'Views' - }; - this.filter = { - include: [{ - relation: 'user', - scope: { - fields: ['name'], - include: { - relation: 'worker', - scope: { - fields: ['id'] - } - } - }, - }], - }; - } - - get logs() { - return this._logs; - } - - 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) { - const properties = []; - let validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/; - - if (typeof instance == 'object' && instance != null) { - Object.keys(instance).forEach(property => { - if (validDate.test(instance[property])) - instance[property] = new Date(instance[property]).toLocaleString('es-ES'); - - properties.push({key: property, value: instance[property]}); - }); - return properties; - } - return null; - } - - showWorkerDescriptor(event, workerId) { - if (!workerId) return; - this.$.workerDescriptor.show(event.target, workerId); - } -} - -ngModule.vnComponent('vnLog', { - controller: Controller, +ngModule.vnComponent('vnWorkerLog', { template: require('./index.html'), - bindings: { - model: '<', - originId: '<', - url: '@' - } + controller: Section, }); diff --git a/modules/worker/front/worker-log/index.html b/modules/worker/front/worker-log/index.html deleted file mode 100644 index 090dbf2e3d..0000000000 --- a/modules/worker/front/worker-log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/worker/front/worker-log/index.js b/modules/worker/front/worker-log/index.js deleted file mode 100644 index e30ce7e229..0000000000 --- a/modules/worker/front/worker-log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnWorkerLog', { - template: require('./index.html'), - controller: Section, -});