Merge pull request 'log refactor' (#469) from 2610-log_refactor into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #469 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
5dbf4f3926
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
exports.translateValues = async(instance, changes) => {
|
exports.translateValues = async(instance, changes) => {
|
||||||
const models = instance.app.models;
|
const models = instance.app.models;
|
||||||
|
|
||||||
function getRelation(instance, property) {
|
function getRelation(instance, property) {
|
||||||
const relations = instance.definition.settings.relations;
|
const relations = instance.definition.settings.relations;
|
||||||
for (let relationName in relations) {
|
for (let relationName in relations) {
|
||||||
|
@ -38,12 +37,18 @@ exports.translateValues = async(instance, changes) => {
|
||||||
for (let property in properties) {
|
for (let property in properties) {
|
||||||
const relation = getRelation(instance, property);
|
const relation = getRelation(instance, property);
|
||||||
const value = properties[property];
|
const value = properties[property];
|
||||||
|
|
||||||
let finalValue = value;
|
let finalValue = value;
|
||||||
|
|
||||||
if (relation) {
|
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 model = relation.model;
|
||||||
const row = await models[model].findById(value, {
|
const row = await models[model].findById(value, {
|
||||||
fields: ['alias', 'name', 'code', 'description']
|
fields: fieldsToShow
|
||||||
});
|
});
|
||||||
const newValue = getValue(row);
|
const newValue = getValue(row);
|
||||||
if (newValue) finalValue = newValue;
|
if (newValue) finalValue = newValue;
|
||||||
|
|
Loading…
Reference in New Issue