From e0fd9f58ae1f7f025217e3ef605ba20a568043d6 Mon Sep 17 00:00:00 2001 From: florian <f.spreckelsen@inidscale.com> Date: Wed, 30 Nov 2022 10:54:26 +0100 Subject: [PATCH] FIX: Also hide properties of ReocrdTypes with matching names --- src/core/js/ext_prop_display.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core/js/ext_prop_display.js b/src/core/js/ext_prop_display.js index 0e362060..a9cdb8e5 100644 --- a/src/core/js/ext_prop_display.js +++ b/src/core/js/ext_prop_display.js @@ -25,7 +25,7 @@ * @requires log (singleton from loglevel library) * @requires load_config (function from webcaosdb.js) */ -var prop_display = new function ($, getEntityName, getPropertyElements, getPropertyName, getUserName, getUserRoles, logger, load_config, query) { +var prop_display = new function ($, getEntityName, getEntityRole, getPropertyElements, getPropertyName, getUserName, getUserRoles, logger, load_config, query) { /** * Return the property-display config file; `ext_prop_display.json` by @@ -58,8 +58,10 @@ var prop_display = new function ($, getEntityName, getPropertyElements, getPrope for (let ent of entities) { let parents = getParents(ent).map(par => par.name); let properties = getPropertyElements(ent); - if (parents.some(par => allTypes.allTypesOrChildren.includes(par))) { - console.log(parents); + // either the entity has matching parents OR it is the actual + // RecordType for which a rule is written. + if (parents.some(par => allTypes.allTypesOrChildren.includes(par)) || + (getEntityRole(ent) == "RecordType" && allTypes.allTypesOrChildren.includes(getEntityName(ent)))) { // we know that there is at least one rule for this type (it is // in `allTypes.allTypesOrChildren`), but we don't know which tp // apply yet. @@ -67,7 +69,8 @@ var prop_display = new function ($, getEntityName, getPropertyElements, getPrope let typeConf = conf[typeName]; let allNames = allTypes.typesWithChildren[typeName]; // only hide something if there is a match in at least one parent type - if (parents.some(par => allNames.includes(par))) { + if (parents.some(par => allNames.includes(par)) || + (getEntityRole(ent) == "RecordType" && allNames.includes(getEntityName(ent)))) { properties.forEach((prop, index) => { if (this._hide_property(getPropertyName(prop), userName, userRoles, typeConf)) { console.log(prop); @@ -151,6 +154,6 @@ var prop_display = new function ($, getEntityName, getPropertyElements, getPrope this._unhide_all_properties(); } } -}($, getEntityName, getPropertyElements, getPropertyName, getUserName, getUserRoles, log.getLogger("ext_prop_display"), load_config, query); +}($, getEntityName, getEntityRole, getPropertyElements, getPropertyName, getUserName, getUserRoles, log.getLogger("ext_prop_display"), load_config, query); $(document).ready(() => caosdb_modules.register(prop_display)); -- GitLab