Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ public function invokeVocabularyHome($request)

$vocabTypes = $this->model->getTypes($request->getVocabid(), $request->getLang());

$customLabels = $vocab->getConfig()->getPropertyLabelOverrides();

echo $template->render(
array(
'languages' => $this->languages,
Expand All @@ -561,7 +563,8 @@ public function invokeVocabularyHome($request)
'active_tab' => $defaultView,
'request' => $request,
'types' => $vocabTypes,
'plugin_params' => $pluginParameters
'plugin_params' => $pluginParameters,
'custom_labels' => $customLabels
)
);
}
Expand Down
8 changes: 7 additions & 1 deletion src/view/vocab-info.inc.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@

{% for key, values in vocabInfo %}
<div class="row property">
<div class="col-lg-4 ps-0 property-label"><h2>{{ key | trans }}</h2></div>
{%- set label = custom_labels[key]['label'][request.lang] | default(key | trans) -%}
{%- set tooltip = custom_labels[key]['description'][request.lang] | default('') -%}
<div class="col-lg-4 ps-0 property-label"><h2{% if tooltip is not empty %} class="tooltip-inline t-top" data-title="{{ tooltip }}"{% endif %}>{{ label }}</h2>
{%- if tooltip is not empty %}
<span class="visually-hidden">{{ tooltip }}</span>
{%- endif %}
</div>
<div class="col-lg-8 gx-0 gx-lg-4 align-self-center property-value">
<ul class="align-bottom">
{% for val in values %}
Expand Down
2 changes: 2 additions & 0 deletions tests/VocabularyConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ public function testGetPropertyLabelOverrides()
'description' => array( 'en' => 'Class Number') ),
'skos:exactMatch' => array( 'label' => array( 'fi' => 'vastaava luokka', 'sv' => 'motsvarande klasser', 'en' => 'exactly matching classes' ),
'description' => array( 'en' => 'exactly matching classes in another vocabulary.' ) ),
'unknown:vocabularyProperty' => array( 'label' => array( 'en' => 'Vocabulary Property' ),
'description' => array( 'en' => 'Vocabulary Property description' ) )
);
$this->assertEquals($expected, $overrides);
}
Expand Down
15 changes: 14 additions & 1 deletion tests/cypress/template/concept.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('Concept page', () => {
// Check that "my property" property label is capitalized correctly
cy.get('.prop-my_property .property-label h2').invoke('text').should('include', 'My property')
})
it('overrides property labels', () => {
it('overrides concept property labels', () => {
// Go to "Carp" concept page in vocab with property label overrides
cy.visit('/conceptPropertyLabels/en/page/ta112')
// Check that prefLabel property label is overridden correctly
Expand All @@ -155,6 +155,19 @@ describe('Concept page', () => {
// Check that mapping property title is overridden correctly
cy.get('.prop-mapping .property-label').eq(0).should('have.attr', 'title').and('contain', 'Exactly matching classes in another vocabulary.')
})
it('overrides vocabulary property labels', () => {
// Go to "Carp" concept page in vocab with property label overrides
cy.visit('/conceptPropertyLabels/en/')
// Loop through all .row.property and if the element has a .property-value ul li with text "Overridden property value", check the label and title of the .property-label for this row
cy.get('.row.property').each($row => {
cy.wrap($row).find('.property-value ul li').each($li => {
if ($li.text().includes('Overridden property value')) {
cy.wrap($row).find('.property-label h2').eq(0).invoke('text').should('include', 'Vocabulary Property')
cy.wrap($row).find('.property-label h2').eq(0).should('have.attr', 'data-title').and('contain', 'Vocabulary Property description')
}
})
})
})
it('contains SKOS XL information for concept prefLabel', () => {
cy.visit('/yso/en/page/p4625?clang=se') // go to "bronsaáigi" concept page ('Bronze Age' in Northern Sami)

Expand Down
2 changes: 2 additions & 0 deletions tests/test-vocab-data/conceptPropertyLabels.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix mads: <http://www.loc.gov/mads/rdf/v1#> .
@prefix unknown: <http://www.skosmos.skos/unknown/> .

test:ta112 a skos:Concept ;
skos:notation "665" ;
Expand Down Expand Up @@ -44,4 +45,5 @@ test:conceptscheme a skos:ConceptScheme ;
rdfs:label "Test conceptscheme"@en ;
dct:modified "2014-10-01T16:29:03+00:00"^^xsd:dateTime ;
owl:versionInfo "The latest and greatest version"^^xsd:string ;
unknown:vocabularyProperty "Overridden property value"^^xsd:string ;
skos:hasTopConcept test:ta1 .
6 changes: 5 additions & 1 deletion tests/testconfig.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@prefix my: <http://example.com/myns#> .
@prefix mdrtype: <http://publications.europa.eu/resource/authority/dataset-type/> .
@prefix test: <http://www.skosmos.skos/test/> .
@prefix unknown: <http://www.skosmos.skos/unknown/> .
@prefix : <http://base/#> .

# Skosmos main configuration
Expand Down Expand Up @@ -415,7 +416,10 @@
rdfs:comment "Class Number"@en ],
[ skosmos:property skos:exactMatch ;
rdfs:label "vastaava luokka"@fi, "motsvarande klasser"@sv, "exactly matching classes"@en ;
rdfs:comment "exactly matching classes in another vocabulary."@en ] ;
rdfs:comment "exactly matching classes in another vocabulary."@en ],
[ skosmos:property unknown:vocabularyProperty ;
rdfs:label "Vocabulary Property"@en ;
rdfs:comment "Vocabulary Property description"@en ] ;
skosmos:sparqlGraph <http://www.skosmos.skos/conceptPropertyLabels/> .

:cbd a skosmos:Vocabulary, void:Dataset ;
Expand Down
Loading