diff --git a/src/components/common/VnLog.vue b/src/components/common/VnLog.vue index 14e4789fc..b0a9f230c 100644 --- a/src/components/common/VnLog.vue +++ b/src/components/common/VnLog.vue @@ -168,17 +168,17 @@ function getLogTree(data) { let originLog = null; let userLog = null; let modelLog = null; - let prevLog; let nLogs; - data.forEach((log) => { + for (let i = 0; i < data.length; i++) { + let log = data[i]; + let prevLog = i > 0 ? data[i - 1] : null; const locale = validations[log.changedModel]?.locale || {}; // Origin const originChanged = !prevLog || log.originFk != prevLog.originFk; if (originChanged) { logs.push((originLog = { originFk: log.originFk, logs: [] })); - prevLog = log; } // User const userChanged = originChanged || log.userFk != prevLog.userFk; @@ -197,6 +197,7 @@ function getLogTree(data) { log.changedModel != prevLog.changedModel || log.changedModelId != prevLog.changedModelId || nLogs >= 6; + if (modelChanged) { userLog.logs.push( (modelLog = { @@ -221,7 +222,7 @@ function getLogTree(data) { propNames = [...new Set(propNames)]; log.props = parseProps(propNames, locale, vals, olds); - }); + } return logs; }