From 4f019915502b0c2fba835afc648940a20b2aadd7 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Franel Date: Tue, 21 Apr 2026 15:03:12 +0200 Subject: [PATCH 1/4] feat: add custom label overrides and tooltips for vocabulary properties --- src/controller/WebController.php | 5 ++++- src/view/vocab-info.inc.twig | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/controller/WebController.php b/src/controller/WebController.php index 4c25f9c18..9e4220230 100644 --- a/src/controller/WebController.php +++ b/src/controller/WebController.php @@ -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, @@ -561,7 +563,8 @@ public function invokeVocabularyHome($request) 'active_tab' => $defaultView, 'request' => $request, 'types' => $vocabTypes, - 'plugin_params' => $pluginParameters + 'plugin_params' => $pluginParameters, + 'custom_labels' => $customLabels ) ); } diff --git a/src/view/vocab-info.inc.twig b/src/view/vocab-info.inc.twig index fcc550b4b..fc195a6d4 100644 --- a/src/view/vocab-info.inc.twig +++ b/src/view/vocab-info.inc.twig @@ -14,7 +14,13 @@ {% for key, values in vocabInfo %}
-

{{ key | trans }}

+ {%- set label = custom_labels[key]['label'][request.lang] | default(key | trans) -%} + {%- set tooltip = custom_labels[key]['description'][request.lang] | default('') -%} +
{{ label }} + {%- if tooltip is not empty %} + {{ tooltip }} + {%- endif %} +
    {% for val in values %} From a4fc220fa3f52df6149808570c9a59bfe8f41445 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Franel Date: Wed, 22 Apr 2026 09:42:34 +0200 Subject: [PATCH 2/4] test: add cypress tests for vocabulary property label overrides --- tests/cypress/template/concept.cy.js | 10 +++++++++- tests/test-vocab-data/conceptPropertyLabels.ttl | 2 ++ tests/testconfig.ttl | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/cypress/template/concept.cy.js b/tests/cypress/template/concept.cy.js index ddaf51230..4048b890e 100644 --- a/tests/cypress/template/concept.cy.js +++ b/tests/cypress/template/concept.cy.js @@ -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 @@ -155,6 +155,14 @@ 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/') + // Check that there is a .row .property-label with the overridden property label + cy.get('.row .property-label').eq(0).invoke('text').should('include', 'Vocabulary Property') + // Check that there is a .row .property-label with the overridden property label description as title + cy.get('.row .property-label').eq(0).should('have.attr', '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) diff --git a/tests/test-vocab-data/conceptPropertyLabels.ttl b/tests/test-vocab-data/conceptPropertyLabels.ttl index f363fe12c..009418d8b 100644 --- a/tests/test-vocab-data/conceptPropertyLabels.ttl +++ b/tests/test-vocab-data/conceptPropertyLabels.ttl @@ -10,6 +10,7 @@ @prefix xml: . @prefix xsd: . @prefix mads: . +@prefix unknown: . test:ta112 a skos:Concept ; skos:notation "665" ; @@ -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 . diff --git a/tests/testconfig.ttl b/tests/testconfig.ttl index 4ce246cba..1cec10831 100644 --- a/tests/testconfig.ttl +++ b/tests/testconfig.ttl @@ -16,6 +16,7 @@ @prefix my: . @prefix mdrtype: . @prefix test: . +@prefix unknown: . @prefix : . # Skosmos main configuration @@ -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 . :cbd a skosmos:Vocabulary, void:Dataset ; From 160bbac96017ac5d04667c794a9b87e1607fdca9 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Franel Date: Wed, 22 Apr 2026 09:48:20 +0200 Subject: [PATCH 3/4] test: fix unit test after adding vocabulary property label overrides --- tests/VocabularyConfigTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/VocabularyConfigTest.php b/tests/VocabularyConfigTest.php index aeb21f853..28c8a4d54 100644 --- a/tests/VocabularyConfigTest.php +++ b/tests/VocabularyConfigTest.php @@ -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); } From 940ff9fe73cc0b948a567026847e5f08199f499f Mon Sep 17 00:00:00 2001 From: Jean-Daniel Franel Date: Wed, 22 Apr 2026 12:42:23 +0200 Subject: [PATCH 4/4] test: fix cypress test overridden property lookup --- tests/cypress/template/concept.cy.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/cypress/template/concept.cy.js b/tests/cypress/template/concept.cy.js index 4048b890e..2b174005c 100644 --- a/tests/cypress/template/concept.cy.js +++ b/tests/cypress/template/concept.cy.js @@ -158,10 +158,15 @@ describe('Concept page', () => { it('overrides vocabulary property labels', () => { // Go to "Carp" concept page in vocab with property label overrides cy.visit('/conceptPropertyLabels/en/') - // Check that there is a .row .property-label with the overridden property label - cy.get('.row .property-label').eq(0).invoke('text').should('include', 'Vocabulary Property') - // Check that there is a .row .property-label with the overridden property label description as title - cy.get('.row .property-label').eq(0).should('have.attr', 'title').and('contain', 'Vocabulary Property description') + // 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)