Skip to content
Snippets Groups Projects
Commit e0fd9f58 authored by florian's avatar florian
Browse files

FIX: Also hide properties of ReocrdTypes with matching names

parent 66501bc6
No related branches found
No related tags found
2 merge requests!89Release v0.10.0,!86F hide properties
Pipeline #31226 passed
......@@ -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));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment