diff --git a/e2e/paths/02-client/07_edit_web_access.spec.js b/e2e/paths/02-client/07_edit_web_access.spec.js index 5386d12bd..3847ec7cd 100644 --- a/e2e/paths/02-client/07_edit_web_access.spec.js +++ b/e2e/paths/02-client/07_edit_web_access.spec.js @@ -5,8 +5,8 @@ const $ = { userName: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.name"]', email: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.email"]', saveButton: 'vn-client-web-access button[type=submit]', - nameValue: 'vn-client-log .change:nth-child(1) .basic-json:nth-child(2) vn-json-value', - activeValue: 'vn-client-log .change:nth-child(2) .basic-json:nth-child(1) vn-json-value' + nameValue: 'vn-client-log .changes-log:nth-child(2) .basic-json:nth-child(2) vn-json-value', + activeValue: 'vn-client-log .changes-log:nth-child(3) .basic-json:nth-child(1) vn-json-value' }; describe('Client web access path', () => { diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index ac4e5cb6e..e0465b840 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -33,16 +33,16 @@ ng-src="/api/Images/user/160x160/{{::userLog.userFk}}/download?access_token={{::$ctrl.vnToken.token}}"> -
+
-
+
+ ng-click="$ctrl.filterByRecord(modelLog)"> diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index ecbeaefe7..822a31801 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -67,8 +67,7 @@ export default class Controller extends Section { $onInit() { const match = this.url?.match(/(.*)Logs$/); - this.model = match && match[1]; - this.modelI18n = this.translateModel(this.model); + this.modelI18n = this.translateModel(match && match[1]); } $postLink() { @@ -279,7 +278,7 @@ export default class Controller extends Section { if (value == null || value == '') return null; switch (prop) { case 'search': - if (/^\s*[0-9]+\s*$/.test(value) || this.byEntity) + if (/^\s*[0-9]+\s*$/.test(value) || this.byRecord) return {changedModelId: value.trim()}; else return {changedModelValue: {like: `%${value}%`}}; @@ -332,8 +331,8 @@ export default class Controller extends Section { const and = []; if (!filter.search || !filter.changedModel) - this.byEntity = false; - if (!this.byEntity) + this.byRecord = false; + if (!this.byRecord) and.push({originFk: this.originId}); for (const prop in filter) { @@ -348,8 +347,8 @@ export default class Controller extends Section { return this.$.model.applyFilter(lbFilter); } - filterByEntity(modelLog) { - this.byEntity = true; + filterByRecord(modelLog) { + this.byRecord = true; this.$.filter = { who: 'all', search: modelLog.id, diff --git a/front/salix/components/log/style.scss b/front/salix/components/log/style.scss index 8c39559fc..f11fc2f25 100644 --- a/front/salix/components/log/style.scss +++ b/front/salix/components/log/style.scss @@ -74,7 +74,8 @@ vn-log { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; - margin-top: 6px; + margin-top: 5px; + min-height: 22px; & > .model-name { display: inline-block; @@ -131,7 +132,7 @@ vn-log { & > vn-icon.pit { @extend %clickable-light; vertical-align: middle; - font-size: 18px; + font-size: 20px; color: $color-font-secondary; display: none; diff --git a/loopback/common/methods/log/pitInstance.js b/loopback/common/methods/log/pitInstance.js index 3cbe013b3..1c054c53e 100644 --- a/loopback/common/methods/log/pitInstance.js +++ b/loopback/common/methods/log/pitInstance.js @@ -1,3 +1,5 @@ +const NotFoundError = require('vn-loopback/util/not-found-error'); + module.exports = Self => { Self.remoteMethod('pitInstance', { description: 'Gets the status of instance at specific point in time', @@ -21,24 +23,40 @@ module.exports = Self => { Self.pitInstance = async function(id) { const log = await Self.findById(id, { - fields: ['changedModel', 'changedModelId'] + fields: [ + 'changedModel', + 'changedModelId', + 'creationDate' + ] }); + if (!log) + throw new NotFoundError(); const where = { changedModel: log.changedModel, changedModelId: log.changedModelId }; - const createdWhere = {action: 'insert'}; + const createdWhere = { + action: 'insert', + creationDate: {lte: log.creationDate} + }; const createdLog = await Self.findOne({ - fields: ['id'], - where: Object.assign(createdWhere, where) + fields: ['id', 'creationDate'], + where: Object.assign(createdWhere, where), + order: 'creationDate DESC' }); + if (!createdLog) + throw new NotFoundError('Cannot find creation log'); const logsWhere = { id: {between: [ Math.min(id, createdLog.id), Math.max(id, createdLog.id) + ]}, + creationDate: {between: [ + createdLog.creationDate, + log.creationDate ]} }; const logs = await Self.find({ @@ -46,6 +64,8 @@ module.exports = Self => { where: Object.assign(logsWhere, where), order: 'creationDate' }); + if (!logs.length) + throw new NotFoundError('No logs found for record'); const instance = {}; for (const log of logs)