Skip to content

Commit

Permalink
Add configuration option for default concept page sidebar view
Browse files Browse the repository at this point in the history
  • Loading branch information
UnniKohonen committed Aug 30, 2023
1 parent 645216e commit 2cdbacf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/model/VocabularyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,23 @@ public function getDefaultSidebarView()
return $value;
}
}
return 'alphabetical'; // if not defined displaying the alphabetical index
return 'alphabetical'; // if not defined displaying alphabetical index
}

/**
* Returns the concept page default sidebar view.
* @return string name of the view
*/
public function getDefaultConceptSidebarView()
{
$defview = $this->resource->getLiteral('skosmos:defaultConceptSidebarView');
if ($defview) {
$value = $defview->getValue();
if (in_array($value, ['hierarchy', 'alphabetical', 'fullalphabetical', 'changes', 'groups'])) {
return $value;
}
}
return 'hierarchy'; // if not defined displaying hierachy
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/VocabularyConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ public function testGetDefaultSidebarViewWhenNotSet()
$this->assertEquals('alphabetical', $default);
}

/**
* @covers VocabularyConfig::getDefaultConceptSidebarView
*/
public function testGetDefaultConceptSidebarView()
{
$vocab = $this->model->getVocabulary('testdiff');
$default = $vocab->getConfig()->getDefaultConceptSidebarView();
$this->assertEquals('groups', $default);
}

/**
* @covers VocabularyConfig::getDefaultConcpetSidebarView
*/
public function testGetDefaultConceptSidebarViewWhenNotSet()
{
$vocab = $this->model->getVocabulary('test');
$default = $vocab->getConfig()->getDefaultConceptSidebarView();
$this->assertEquals('hierarchy', $default);
}

/**
* @covers VocabularyConfig::getSidebarViews
*/
Expand Down
1 change: 1 addition & 0 deletions tests/testconfig.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
skosmos:fullAlphabeticalIndex "true";
skosmos:explicitLanguageTags "true";
skosmos:defaultSidebarView "groups";
skosmos:defaultConceptSidebarView "groups";
skosmos:sidebarViews ( "alphabetical" "hierarchy" "groups" );
skosmos:showTopConcepts "false";
skosmos:hierarchyProperty isothes:broaderGeneric;
Expand Down

0 comments on commit 2cdbacf

Please sign in to comment.