log refactor
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
857b876808
commit
ba156a2e42
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue