Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-webui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-webui
Commits
e7566b6d
Commit
e7566b6d
authored
2 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Hide hidden properties
parent
11061075
No related branches found
No related tags found
2 merge requests
!89
Release v0.10.0
,
!86
F hide properties
Pipeline
#31037
passed
2 years ago
Stage: linting
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/css/webcaosdb.css
+4
-0
4 additions, 0 deletions
src/core/css/webcaosdb.css
src/core/js/ext_prop_display.js
+83
-3
83 additions, 3 deletions
src/core/js/ext_prop_display.js
with
87 additions
and
3 deletions
src/core/css/webcaosdb.css
+
4
−
0
View file @
e7566b6d
...
...
@@ -381,6 +381,10 @@ h5 {
margin-right
:
0px
;
}
.caosdb-v-hidden-property
{
display
:
None
;
}
.caosdb-v-edit-drag
{
padding
:
5px
;
}
...
...
This diff is collapsed.
Click to expand it.
src/core/js/ext_prop_display.js
+
83
−
3
View file @
e7566b6d
...
...
@@ -25,7 +25,7 @@
* @requires log (singleton from loglevel library)
* @requires load_config (function from webcaosdb.js)
*/
var
prop_display
=
new
function
(
$
,
logger
,
load_config
)
{
var
prop_display
=
new
function
(
$
,
getEntityName
,
getPropertyElements
,
getPropertyName
,
getUserName
,
getUserRoles
,
logger
,
load_config
,
query
)
{
/**
* Return the property-display config file; `ext_prop_display.json` by
...
...
@@ -47,10 +47,90 @@ var prop_display = new function ($, logger, load_config) {
return
conf
;
}
this
.
init
=
async
function
()
{
this
.
_get_entities_in_view
=
function
()
{
// Use all entities, both in entity panel and in preview.
return
$
(
"
.caosdb-entity-panel,.caosdb-entity-preview
"
)
}
this
.
_hide_properties
=
function
(
entities
,
conf
,
typesWithChildren
)
{
const
userName
=
getUserName
();
const
userRoles
=
getUserRoles
();
for
(
let
typeName
of
Object
.
keys
(
conf
))
{
let
typeConf
=
conf
[
typeName
];
let
allNames
=
typesWithChildren
[
typeName
];
for
(
let
ent
of
entities
)
{
let
parents
=
getParents
(
ent
).
map
(
par
=>
par
.
name
);
// only hide something if there is a match in at least one parent type
if
(
parents
.
some
(
par
=>
allNames
.
includes
(
par
)))
{
let
properties
=
getPropertyElements
(
ent
);
for
(
let
prop
of
properties
)
{
if
(
this
.
_hide_property
(
getPropertyName
(
prop
),
userName
,
userRoles
,
typeConf
))
{
console
.
log
(
prop
);
$
(
prop
).
toggleClass
(
"
caosdb-v-hidden-property
"
);
}
else
{
$
(
prop
).
toggleClass
(
"
caosdb-v-show-property
"
);
}
}
}
}
}
}
this
.
_hide_property
=
function
(
propname
,
userName
,
userRoles
,
conf
)
{
// is this property only shown for certain users/groups?
if
((
conf
.
show
!=
undefined
)
&&
conf
.
show
.
length
>
0
)
{
for
(
let
def
of
conf
.
show
)
{
if
(
propname
.
toLowerCase
()
==
def
.
name
.
toLowerCase
())
{
if
(
!
(
def
.
users
.
includes
(
userName
))
&&
!
(
userRoles
.
some
(
role
=>
def
.
roles
.
includes
(
role
))))
{
return
true
}
}
}
}
// is this property hidden for certain users/groups?
if
((
conf
.
hide
!=
undefined
)
&&
conf
.
hide
.
length
>
0
)
{
for
(
let
def
of
conf
.
hide
)
{
if
(
propname
.
toLowerCase
()
==
def
.
name
.
toLowerCase
())
{
console
.
log
(
propname
);
console
.
log
(
`
${
userName
}
-
${
def
.
users
}
`
);
console
.
log
(
`
${
userRoles
}
-
${
def
.
roles
}
`
);
if
(
def
.
users
.
includes
(
userName
)
||
userRoles
.
some
(
role
=>
def
.
roles
.
includes
(
role
)))
{
return
true
}
}
}
}
return
false
;
}
this
.
_getRecordTypes
=
async
function
(
conf
)
{
const
parentTypes
=
Object
.
keys
(
conf
);
var
typesWithChildren
=
{};
for
(
let
parentName
of
parentTypes
)
{
const
children
=
await
query
(
`FIND RECORDTYPE "
${
parentName
}
"`
);
const
names
=
children
.
map
(
ent
=>
getEntityName
(
ent
));
typesWithChildren
[
parentName
]
=
names
;
}
return
typesWithChildren
;
}
this
.
init
=
async
function
()
{
console
.
log
(
"
initializing ext_prop_display.js
"
);
const
conf
=
await
this
.
load_config
();
const
typesWithChildren
=
await
this
.
_getRecordTypes
(
conf
);
var
entities
=
this
.
_get_entities_in_view
();
this
.
_hide_properties
(
entities
,
conf
,
typesWithChildren
)
}
}(
$
,
log
.
getLogger
(
"
ext_prop_display
"
),
load_config
);
}(
$
,
getEntityName
,
getPropertyElements
,
getPropertyName
,
getUserName
,
getUserRoles
,
log
.
getLogger
(
"
ext_prop_display
"
),
load_config
,
query
);
$
(
document
).
ready
(()
=>
caosdb_modules
.
register
(
prop_display
));
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment