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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-webui
Commits
93ed9004
Commit
93ed9004
authored
2 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Allow sorting of properties
parent
fbf72ea0
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!89
Release v0.10.0
,
!88
ENH: Allow sorting of properties
Pipeline
#31437
passed
2 years ago
Stage: linting
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/js/ext_prop_display.js
+31
-5
31 additions, 5 deletions
src/core/js/ext_prop_display.js
test/core/js/modules/ext_prop_display.js.js
+81
-20
81 additions, 20 deletions
test/core/js/modules/ext_prop_display.js.js
with
112 additions
and
25 deletions
src/core/js/ext_prop_display.js
+
31
−
5
View file @
93ed9004
...
@@ -51,7 +51,7 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
...
@@ -51,7 +51,7 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
return
$
(
"
.caosdb-entity-panel,.caosdb-entity-preview
"
);
return
$
(
"
.caosdb-entity-panel,.caosdb-entity-preview
"
);
}
}
this
.
unhide
Properties
=
function
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
)
{
this
.
display
Properties
=
function
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
)
{
for
(
let
ent
of
entities
)
{
for
(
let
ent
of
entities
)
{
let
parents
=
getParents
(
ent
).
map
(
par
=>
par
.
name
);
let
parents
=
getParents
(
ent
).
map
(
par
=>
par
.
name
);
...
@@ -69,6 +69,7 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
...
@@ -69,6 +69,7 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
// only hide something if there is a match in at least one parent type
// 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
))))
{
(
getEntityRole
(
ent
)
==
"
RecordType
"
&&
allNames
.
includes
(
getEntityName
(
ent
))))
{
this
.
_sortProperties
(
ent
,
properties
,
typeConf
);
properties
.
forEach
((
prop
,
index
)
=>
{
properties
.
forEach
((
prop
,
index
)
=>
{
if
(
this
.
_hide_property
(
getPropertyName
(
prop
),
userName
,
userRoles
,
typeConf
))
{
if
(
this
.
_hide_property
(
getPropertyName
(
prop
),
userName
,
userRoles
,
typeConf
))
{
// Should be hidden by default but better safe than sorry
// Should be hidden by default but better safe than sorry
...
@@ -87,6 +88,31 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
...
@@ -87,6 +88,31 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
}
}
}
}
this
.
_sortProperties
=
function
(
entity
,
properties
,
conf
)
{
if
(
conf
.
order
==
undefined
||
conf
.
order
.
length
==
0
)
{
return
;
}
properties
.
sort
(
function
(
a
,
b
)
{
let
confIndexA
=
conf
.
order
.
indexOf
(
getPropertyName
(
a
));
let
confIndexB
=
conf
.
order
.
indexOf
(
getPropertyName
(
b
));
if
(
confIndexA
<
0
&&
confIndexB
<
0
)
{
// both are not part of order list
return
0
;
}
if
(
confIndexA
<
0
)
{
// only b is part of order list , so it is placed before a
return
1
;
}
if
(
confIndexB
<
0
)
{
// only a is part of order list, so it is placed before b
return
-
1
;
}
// From here, we can assume that both are in the order list:
return
confIndexA
-
confIndexB
;
});
$
(
entity
).
find
(
"
.caosdb-properties
"
).
append
(
properties
);
}
this
.
_hide_property
=
function
(
propname
,
userName
,
userRoles
,
conf
)
{
this
.
_hide_property
=
function
(
propname
,
userName
,
userRoles
,
conf
)
{
// is this property only shown for certain users/groups?
// is this property only shown for certain users/groups?
...
@@ -154,7 +180,7 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
...
@@ -154,7 +180,7 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
return
result
;
return
result
;
}
}
this
.
_
unhide
PropertiesWrapper
=
function
(
original
,
conf
,
allTypes
)
{
this
.
_
display
PropertiesWrapper
=
function
(
original
,
conf
,
allTypes
)
{
// Same as above, but for when there actually may be something to hide
// Same as above, but for when there actually may be something to hide
// (i.e., build variable is set and config is non-empty).
// (i.e., build variable is set and config is non-empty).
const
result
=
function
(
entitiy
)
{
const
result
=
function
(
entitiy
)
{
...
@@ -165,7 +191,7 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
...
@@ -165,7 +191,7 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
var
entities
=
prop_display
.
getEntitiesInView
();
var
entities
=
prop_display
.
getEntitiesInView
();
const
userName
=
getUserName
();
const
userName
=
getUserName
();
const
userRoles
=
getUserRoles
();
const
userRoles
=
getUserRoles
();
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
return
original_return
;
return
original_return
;
}
}
...
@@ -179,11 +205,11 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
...
@@ -179,11 +205,11 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
var
entities
=
this
.
getEntitiesInView
();
var
entities
=
this
.
getEntitiesInView
();
const
userName
=
getUserName
();
const
userName
=
getUserName
();
const
userRoles
=
getUserRoles
();
const
userRoles
=
getUserRoles
();
this
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
this
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
// If we are in the edit mode, (un)hide properties after ending
// If we are in the edit mode, (un)hide properties after ending
// the editing of an entity
// the editing of an entity
document
.
body
.
addEventListener
(
edit_mode
.
start_edit
.
type
,
(
e
)
=>
{
document
.
body
.
addEventListener
(
edit_mode
.
start_edit
.
type
,
(
e
)
=>
{
edit_mode
.
app
.
onAfterShowResults
=
this
.
_
unhide
PropertiesWrapper
(
edit_mode
.
app
.
onAfterShowResults
,
conf
,
allTypes
);
edit_mode
.
app
.
onAfterShowResults
=
this
.
_
display
PropertiesWrapper
(
edit_mode
.
app
.
onAfterShowResults
,
conf
,
allTypes
);
},
true
);
},
true
);
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
test/core/js/modules/ext_prop_display.js.js
+
81
−
20
View file @
93ed9004
...
@@ -48,7 +48,7 @@ QUnit.test("unhide all properties", function (assert) {
...
@@ -48,7 +48,7 @@ QUnit.test("unhide all properties", function (assert) {
QUnit
.
test
(
"
hide properties garbage type
"
,
function
(
assert
)
{
QUnit
.
test
(
"
hide properties garbage type
"
,
function
(
assert
)
{
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
unhide
Properties
,
"
unhide
Properties available
"
);
assert
.
ok
(
prop_display
.
display
Properties
,
"
display
Properties available
"
);
const
conf
=
{
const
conf
=
{
"
DoesntExist
"
:
{
"
DoesntExist
"
:
{
"
hide
"
:
[{
"
hide
"
:
[{
...
@@ -70,14 +70,14 @@ QUnit.test("hide properties garbage type", function (assert) {
...
@@ -70,14 +70,14 @@ QUnit.test("hide properties garbage type", function (assert) {
const
entities
=
prop_display
.
getEntitiesInView
();
const
entities
=
prop_display
.
getEntitiesInView
();
assert
.
equal
(
entities
.
length
,
1
,
"
only one entity in test data
"
);
assert
.
equal
(
entities
.
length
,
1
,
"
only one entity in test data
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all properties hidden initially
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all properties hidden initially
"
);
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
0
,
"
no garbage-type entity, so no hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
0
,
"
no garbage-type entity, so no hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all properties are being shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all properties are being shown
"
);
});
});
QUnit
.
test
(
"
hide properties garbage property
"
,
function
(
assert
)
{
QUnit
.
test
(
"
hide properties garbage property
"
,
function
(
assert
)
{
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
unhide
Properties
,
"
unhide
Properties available
"
);
assert
.
ok
(
prop_display
.
display
Properties
,
"
display
Properties available
"
);
const
conf
=
{
const
conf
=
{
"
MusicalInstrument
"
:
{
"
MusicalInstrument
"
:
{
"
hide
"
:
[{
"
hide
"
:
[{
...
@@ -98,7 +98,7 @@ QUnit.test("hide properties garbage property", function (assert) {
...
@@ -98,7 +98,7 @@ QUnit.test("hide properties garbage property", function (assert) {
const
entities
=
prop_display
.
getEntitiesInView
();
const
entities
=
prop_display
.
getEntitiesInView
();
assert
.
equal
(
entities
.
length
,
1
,
"
only one entity in test data
"
);
assert
.
equal
(
entities
.
length
,
1
,
"
only one entity in test data
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all properties hidden initially
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all properties hidden initially
"
);
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
0
,
"
no garbage property, so no hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
0
,
"
no garbage property, so no hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all properties are being shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all properties are being shown
"
);
});
});
...
@@ -106,7 +106,7 @@ QUnit.test("hide properties garbage property", function (assert) {
...
@@ -106,7 +106,7 @@ QUnit.test("hide properties garbage property", function (assert) {
QUnit
.
test
(
"
hide properties
"
,
function
(
assert
)
{
QUnit
.
test
(
"
hide properties
"
,
function
(
assert
)
{
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
unhide
Properties
,
"
unhide
Properties available
"
);
assert
.
ok
(
prop_display
.
display
Properties
,
"
display
Properties available
"
);
const
conf
=
{
const
conf
=
{
"
MusicalInstrument
"
:
{
"
MusicalInstrument
"
:
{
"
hide
"
:
[{
"
hide
"
:
[{
...
@@ -138,7 +138,7 @@ QUnit.test("hide properties", function (assert) {
...
@@ -138,7 +138,7 @@ QUnit.test("hide properties", function (assert) {
const
entities
=
prop_display
.
getEntitiesInView
();
const
entities
=
prop_display
.
getEntitiesInView
();
assert
.
equal
(
entities
.
length
,
1
,
"
only one entity in test data
"
);
assert
.
equal
(
entities
.
length
,
1
,
"
only one entity in test data
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all properties hidden initially
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all properties hidden initially
"
);
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
1
,
"
exactly one hidden property
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
1
,
"
exactly one hidden property
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
2
,
"
the remaining two are shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
2
,
"
the remaining two are shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
first prop hidden
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
first prop hidden
"
);
...
@@ -146,11 +146,11 @@ QUnit.test("hide properties", function (assert) {
...
@@ -146,11 +146,11 @@ QUnit.test("hide properties", function (assert) {
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
third prop shown
"
);
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
third prop shown
"
);
// reset
// reset
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all shown after reset
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all shown after reset
"
);
userRoles
=
[
"
some_other_role
"
];
userRoles
=
[
"
some_other_role
"
];
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
2
,
"
two hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
2
,
"
two hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
1
,
"
the remaining one is shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
1
,
"
the remaining one is shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
first prop hidden
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
first prop hidden
"
);
...
@@ -158,11 +158,11 @@ QUnit.test("hide properties", function (assert) {
...
@@ -158,11 +158,11 @@ QUnit.test("hide properties", function (assert) {
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
third prop hidden
"
);
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
third prop hidden
"
);
// reset
// reset
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all shown after reset
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all shown after reset
"
);
userName
=
"
someone else
"
;
userName
=
"
someone else
"
;
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
2
,
"
two hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
2
,
"
two hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
1
,
"
the remaining one is shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
1
,
"
the remaining one is shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
first prop shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
first prop shown
"
);
...
@@ -170,11 +170,11 @@ QUnit.test("hide properties", function (assert) {
...
@@ -170,11 +170,11 @@ QUnit.test("hide properties", function (assert) {
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
third prop hidden
"
);
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
third prop hidden
"
);
// reset
// reset
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all shown after reset
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
all shown after reset
"
);
userRoles
=
[
"
some_role
"
,
"
some_other_role
"
]
userRoles
=
[
"
some_role
"
,
"
some_other_role
"
]
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
two hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
two hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
0
,
"
None is shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
0
,
"
None is shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
first prop hidden
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
first prop hidden
"
);
...
@@ -185,7 +185,7 @@ QUnit.test("hide properties", function (assert) {
...
@@ -185,7 +185,7 @@ QUnit.test("hide properties", function (assert) {
QUnit
.
test
(
"
show properties
"
,
function
(
assert
)
{
QUnit
.
test
(
"
show properties
"
,
function
(
assert
)
{
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
unhide
Properties
,
"
unhide
Properties available
"
);
assert
.
ok
(
prop_display
.
display
Properties
,
"
display
Properties available
"
);
const
conf
=
{
const
conf
=
{
"
MusicalInstrument
"
:
{
"
MusicalInstrument
"
:
{
"
show
"
:
[{
"
show
"
:
[{
...
@@ -217,7 +217,7 @@ QUnit.test("show properties", function (assert) {
...
@@ -217,7 +217,7 @@ QUnit.test("show properties", function (assert) {
const
entities
=
prop_display
.
getEntitiesInView
();
const
entities
=
prop_display
.
getEntitiesInView
();
assert
.
equal
(
entities
.
length
,
1
,
"
only one entity in test data
"
);
assert
.
equal
(
entities
.
length
,
1
,
"
only one entity in test data
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all properties hidden initially
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all properties hidden initially
"
);
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
2
,
"
two hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
2
,
"
two hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
1
,
"
the remaining one shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
1
,
"
the remaining one shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
first prop shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
first prop shown
"
);
...
@@ -225,11 +225,11 @@ QUnit.test("show properties", function (assert) {
...
@@ -225,11 +225,11 @@ QUnit.test("show properties", function (assert) {
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
third prop hidden
"
);
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
third prop hidden
"
);
// reset
// reset
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all hidden after reset
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all hidden after reset
"
);
userRoles
=
[
"
some_other_role
"
];
userRoles
=
[
"
some_other_role
"
];
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
1
,
"
one hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
1
,
"
one hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
2
,
"
the remaining two are shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
2
,
"
the remaining two are shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
first prop shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
first prop shown
"
);
...
@@ -237,11 +237,11 @@ QUnit.test("show properties", function (assert) {
...
@@ -237,11 +237,11 @@ QUnit.test("show properties", function (assert) {
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
third prop shown
"
);
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
third prop shown
"
);
// reset
// reset
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all hidden after reset
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all hidden after reset
"
);
userName
=
"
someone else
"
;
userName
=
"
someone else
"
;
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
1
,
"
one hidden property
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
1
,
"
one hidden property
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
2
,
"
the remaining ones are shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
2
,
"
the remaining ones are shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
first prop hidden
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-hidden-property
"
),
true
,
"
first prop hidden
"
);
...
@@ -249,11 +249,11 @@ QUnit.test("show properties", function (assert) {
...
@@ -249,11 +249,11 @@ QUnit.test("show properties", function (assert) {
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
third prop shown
"
);
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
third prop shown
"
);
// reset
// reset
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
""
,
[]);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all hidden after reset
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
3
,
"
all hidden after reset
"
);
userRoles
=
[
"
some_role
"
,
"
some_other_role
"
]
userRoles
=
[
"
some_role
"
,
"
some_other_role
"
]
prop_display
.
unhide
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
prop_display
.
display
Properties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
0
,
"
no hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-hidden-property
"
).
length
,
0
,
"
no hidden properties
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
All are shown
"
);
assert
.
equal
(
$
(
document
).
find
(
"
.caosdb-v-show-property
"
).
length
,
3
,
"
All are shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
first prop shown
"
);
assert
.
equal
(
$
(
"
#1
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
first prop shown
"
);
...
@@ -261,3 +261,64 @@ QUnit.test("show properties", function (assert) {
...
@@ -261,3 +261,64 @@ QUnit.test("show properties", function (assert) {
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
third prop shown
"
);
assert
.
equal
(
$
(
"
#3
"
).
hasClass
(
"
caosdb-v-show-property
"
),
true
,
"
third prop shown
"
);
});
});
QUnit
.
test
(
"
Sort properties
"
,
function
(
assert
)
{
assert
.
ok
(
prop_display
.
getEntitiesInView
,
"
getEntitiesInView available
"
);
assert
.
ok
(
prop_display
.
displayProperties
,
"
displayProperties available
"
);
var
conf
=
{
"
MusicalInstrument
"
:
{
"
order
"
:
[
"
third prop
"
,
"
first prop
"
,
"
second prop
"
]
}
};
const
allTypes
=
{
"
typesWithChildren
"
:
{
"
MusicalInstrument
"
:
[
"
MusicalInstrument
"
,
"
Guitar
"
]
},
"
allTypesOrChildren
"
:
[
"
MusicalInstrument
"
,
"
Guitar
"
]
};
// username and roles don't matter for sorting
const
userName
=
""
;
const
userRoles
=
[];
// initial order
var
properties
=
$
(
document
).
find
(
"
.caosdb-v-property-row
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#1
"
)),
0
,
"
first prop at first position
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#2
"
)),
1
,
"
second prop at second position
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#3
"
)),
2
,
"
third prop at third position
"
);
var
entities
=
prop_display
.
getEntitiesInView
();
prop_display
.
displayProperties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
properties
=
$
(
document
).
find
(
"
.caosdb-v-property-row
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#1
"
)),
1
,
"
first prop at second position
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#2
"
)),
2
,
"
second prop at third position
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#3
"
)),
0
,
"
third prop at first position
"
);
// only specify first prop, the rest is appended in the previous order.
conf
=
{
"
MusicalInstrument
"
:
{
"
order
"
:
[
"
first prop
"
]
}
};
entities
=
prop_display
.
getEntitiesInView
();
prop_display
.
displayProperties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
properties
=
$
(
document
).
find
(
"
.caosdb-v-property-row
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#1
"
)),
0
,
"
first prop at first position
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#2
"
)),
2
,
"
second prop at third position
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#3
"
)),
1
,
"
third prop at second position
"
);
// two specified, the remaining prop is appended
conf
=
{
"
MusicalInstrument
"
:
{
"
order
"
:
[
"
second prop
"
,
"
first prop
"
]
}
};
entities
=
prop_display
.
getEntitiesInView
();
prop_display
.
displayProperties
(
entities
,
conf
,
allTypes
,
userName
,
userRoles
);
properties
=
$
(
document
).
find
(
"
.caosdb-v-property-row
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#1
"
)),
1
,
"
first prop at second position
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#2
"
)),
0
,
"
second prop at first position
"
);
assert
.
equal
(
properties
.
index
(
$
(
"
#3
"
)),
2
,
"
third prop at third position
"
);
});
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