diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html
index 79dfcef8c8..4bb5afd22c 100644
--- a/front/salix/components/log/index.html
+++ b/front/salix/components/log/index.html
@@ -29,7 +29,7 @@
{{::log.user.name || 'System' | translate}}
@@ -54,8 +54,8 @@
{{prop.name}} |
- {{prop.old}} |
- {{prop.new}} |
+ {{prop.old}} |
+ {{prop.new}} |
@@ -69,5 +69,11 @@
-
+
+
+
+
+
+
+
diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js
index 1c54aa9b8d..03745a0e76 100644
--- a/front/salix/components/log/index.js
+++ b/front/salix/components/log/index.js
@@ -7,6 +7,7 @@ const validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[
export default class Controller extends Section {
constructor($element, $) {
super($element, $);
+ this.descriptors = new Map();
this.actionsText = {
insert: 'Creates',
update: 'Updates',
@@ -39,24 +40,37 @@ export default class Controller extends Section {
const empty = {};
const validations = window.validations;
for (const log of value) {
+ if(log.changedModel && !this.descriptors.get(log.changedModel))
+ this.fillDescriptorsMap(log.changedModel);
+
const oldValues = log.oldInstance || empty;
const newValues = log.newInstance || empty;
const locale = validations[log.changedModel]?.locale || empty;
let props = Object.keys(oldValues).concat(Object.keys(newValues));
props = [...new Set(props)];
-
log.props = [];
for (const prop of props) {
+ const descriptor = this.descriptors.get(log.changedModel).get(prop);
log.props.push({
name: locale[prop] || prop,
old: this.formatValue(oldValues[prop]),
- new: this.formatValue(newValues[prop])
+ new: this.formatValue(newValues[prop]),
+ descriptor
});
}
}
}
+ fillDescriptorsMap(changedModel) {
+ const relations = new Map();
+ Object.values(window.validations[changedModel].relations).forEach(relation => {
+ if(relation.type == "belongsTo")
+ relations.set(relation.keyFrom, relation.modelTo);
+ });
+ this.descriptors.set(changedModel, relations);
+ }
+
get showModelName() {
return !(this.changedModel && this.changedModelId);
}
@@ -88,9 +102,9 @@ export default class Controller extends Section {
}
}
- showWorkerDescriptor(event, workerId) {
- if (!workerId) return;
- this.$.workerDescriptor.show(event.target, workerId);
+ showDescriptor(descriptor, event, id) {
+ if (!descriptor || !this.$[descriptor]) return;
+ this.$[descriptor].show(event.target, id);
}
}
diff --git a/loopback/common/methods/schema/model-info.js b/loopback/common/methods/schema/model-info.js
index 6a4db033d5..4601b1ed5e 100644
--- a/loopback/common/methods/schema/model-info.js
+++ b/loopback/common/methods/schema/model-info.js
@@ -93,6 +93,7 @@ module.exports = Self => {
json[modelName] = {
properties: model.definition.rawProperties,
+ relations: model.relations,
validations: jsonValidations,
locale
};