log refactor
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Bernat Exposito 2020-11-27 11:56:41 +01:00
parent 857b876808
commit ba156a2e42
1 changed files with 8 additions and 3 deletions

View File

@ -5,7 +5,6 @@
*/
exports.translateValues = async(instance, changes) => {
const models = instance.app.models;
function getRelation(instance, property) {
const relations = instance.definition.settings.relations;
for (let relationName in relations) {
@ -38,12 +37,18 @@ exports.translateValues = async(instance, changes) => {
for (let property in properties) {
const relation = getRelation(instance, property);
const value = properties[property];
let finalValue = value;
if (relation) {
let fieldsToShow = ['alias', 'name', 'code', 'description'];
const log = instance.definition.settings.log;
if (log && log.showField)
fieldsToShow = log.showField;
const model = relation.model;
const row = await models[model].findById(value, {
fields: ['alias', 'name', 'code', 'description']
fields: fieldsToShow
});
const newValue = getValue(row);
if (newValue) finalValue = newValue;