diff --git a/src/core/js/ext_prop_display.js b/src/core/js/ext_prop_display.js index 0e3620601963be448e0092083c1c1b7e9af33469..a9cdb8e5bfb8f3f43cb20f271f4d1b74b633ebca 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));