Group Field
Description
It's possible to group related fields in a recordtype in a number of ways.
Displaygroup
This will visually group the fields together in the form.
A complete example of 2 fields in the image:DisplayGroup
display group looks like the following.
| @prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix memorix: <http://memorix.io/ontology#> .
@prefix recordtypes: </resources/recordtypes/> .
@prefix image: </resources/recordtypes/Image#> .
recordtypes:Image
a memorix:Recordtype, sh:NodeShape ;
rdfs:label "Image" ;
dc:identifier "Image" ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) ;
sh:targetClass recordtypes:Image ;
# First field
sh:property [
rdfs:label "Title" ;
sh:path image:title ;
sh:maxCount 1 ;
sh:order 1.0 ;
sh:group image:DisplayGroup ;
sh:datatype xsd:string ;
dash:editor dash:TextFieldEditor ;
dash:singleLine true ;
] ;
# Second field
sh:property [
rdf:type sh:PropertyShape ;
rdfs:label "Date"@en ;
sh:path image:date ;
sh:order 2.0 ;
sh:datatype xsd:date ;
sh:group image:DisplayGroup ;
] ;
.
This will render as following:
!["Displaygroup"](../assets/groups/displaygroup.png)
# The group that the fields are rendered in
image:DisplayGroup
rdf:type sh:PropertyGroup ;
rdfs:label "Image group" ;
sh:order 1.0
.
|
Group
It's also possible to group fields in a different way, this is required
if the grouped fields need to have a different target class, for example
a birth event which contains a date and a location field.
| @prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix memorix: <http://memorix.io/ontology#> .
@prefix recordtypes: </resources/recordtypes/> .
@prefix person: </resources/recordtypes/Person#> .
recordtypes:Person
a memorix:Recordtype, sh:NodeShape ;
rdfs:label "Person" ;
dc:identifier "Person" ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) ;
sh:targetClass recordtypes:Person ;
# Group of date event
sh:property [
rdfs:label "Birth event" ;
sh:group person:DisplayGroup ;
sh:path person:birth ;
sh:order 6 ;
sh:maxCount 1 ;
sh:nodeKind sh:BlankNode ;
sh:class person:DateEvent ;
] ;
.
person:DateEvent
a sh:NodeShape ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) ;
sh:targetClass person:DateEvent ;
sh:property [
rdfs:label "date"@en ;
sh:path person:date ;
sh:order 1.0 ;
sh:datatype xsd:date ;
sh:maxCount 1 ;
] ;
sh:property [
rdfs:label "place"@en ;
sh:path person:place ;
sh:order 2.0 ;
sh:datatype xsd:string ;
sh:maxCount 1 ;
] ;
.
person:DisplayGroup
rdf:type sh:PropertyGroup ;
rdfs:label "Person" ;
sh:order 1.0
.
|
This will render as following:
!["Group"](../../assets/groups/group.png)
Repeatable group
A repeatable group can be created in a similiar fashion as a normal group as above
but without sh:maxCount 1 ;
.
The order of the items will be random if the order is important see "Repeatable ordered group"
So the entire field would become:
| # Group of date events
sh:property [
rdfs:label "Birth event" ;
sh:group person:DisplayGroup ;
sh:path person:birth ;
sh:order 6 ;
sh:nodeKind sh:BlankNode ;
sh:class person:DateEvent ;
] ;
|
This will render as following:
!["Repeatable group"](../../assets/groups/repeatable-group.png)
Repeatable ordered group
A repeatable group where order of items are important will need to contain the following field.
| sh:property [
rdfs:label "order"@en ;
memorix:hidden true ;
sh:description "This field is required for persistent order of group items" ;
sh:path memorix:order ;
sh:order 0.0 ;
sh:datatype xsd:integer ;
sh:minCount 1 ;
sh:maxCount 1 ;
] ;
|
A full example would look like below:
| @prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix memorix: <http://memorix.io/ontology#> .
@prefix recordtypes: </resources/recordtypes/> .
@prefix person: </resources/recordtypes/Person#> .
recordtypes:Person
a memorix:Recordtype, sh:NodeShape ;
rdfs:label "Person" ;
dc:identifier "Person4" ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) ;
sh:targetClass recordtypes:Person ;
# Group of date event
sh:property [
rdfs:label "Birth event" ;
sh:group person:DisplayGroup ;
sh:path person:birth ;
sh:order 6 ;
sh:nodeKind sh:BlankNode ;
sh:class person:DateEvent ;
] ;
.
person:DateEvent
a sh:NodeShape ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) ;
sh:targetClass person:DateEvent ;
sh:property [
rdfs:label "order"@en ;
memorix:hidden true ;
sh:description "This field is required for persistent order of group items" ;
sh:path memorix:order ;
sh:order 0.0 ;
sh:datatype xsd:integer ;
sh:minCount 1 ;
sh:maxCount 1 ;
] ;
sh:property [
rdfs:label "date"@en ;
sh:path person:date ;
sh:order 1.0 ;
sh:datatype xsd:date ;
sh:maxCount 1 ;
] ;
sh:property [
rdfs:label "place"@en ;
sh:path person:place ;
sh:order 2.0 ;
sh:datatype xsd:string ;
sh:maxCount 1 ;
] ;
.
person:DisplayGroup
rdf:type sh:PropertyGroup ;
rdfs:label "Person" ;
sh:order 1.0
.
|
And render in the UI as following:
!["Repeatable ordered group"](../../assets/groups/repeatable-ordered-group.png)