Skip to content

Commit

Permalink
#19776 available date ordering added
Browse files Browse the repository at this point in the history
  • Loading branch information
nczirjak-acdh committed Dec 6, 2021
1 parent 15dcb21 commit 013108b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
9 changes: 9 additions & 0 deletions css/acdh_repo_gui.css
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,13 @@ i.material-icons.breadcrumb-icon {
font-size: 12px !important;
padding-top: 4px !important;
padding-right: 5px !important;
}

div.search-result-warning {
background-color: #faeb90;
margin: 0 0 5px;
padding: 4px 0 2px 0;
border-radius: 0px;
font-weight: normal;
text-align: center;
}
5 changes: 3 additions & 2 deletions inst/dbfunctions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ LANGUAGE 'plpgsql';
*/
DROP FUNCTION IF EXISTS gui.breadcrumb_view_func(bigint, text );
CREATE FUNCTION gui.breadcrumb_view_func(_pid bigint, _lang text DEFAULT 'en' )
RETURNS table (mainid bigint, parentid bigint, parentTitle text, depth integer, direct_parent bigint)
RETURNS table (mainid bigint, parentid bigint, parentTitle text, depth integer, direct_parent bigint, avdate date)
AS $func$
with parents as (
select *
Expand All @@ -371,7 +371,8 @@ AS $func$
p.id as parentid,
(array_agg(mv.value order by case mv.lang when _lang then 0 when 'en' then 1 else 2 end))[1] as parenttitle,
abs(p.n) as depth,
(select r.target_id from relations as r where r.id = p.id and r.property = 'https://vocabs.acdh.oeaw.ac.at/schema#isPartOf' limit 1) as direct_parent
(select r.target_id from relations as r where r.id = p.id and r.property = 'https://vocabs.acdh.oeaw.ac.at/schema#isPartOf' limit 1) as direct_parent,
(select CAST(avd.value as DATE) from metadata_view as avd where avd.id = p.id and avd.property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasAvailableDate') as avdate
from
parents p
join resources rs using (id)
Expand Down
22 changes: 16 additions & 6 deletions src/Object/BreadCrumbObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function __construct(array $data)
* @return string
*/
public function getBreadCrumb(): string
{
{
$multiple = $this->checkMultipleBreadCrumb();

if (count($multiple) > 1) {
$this->createMultiBreadcrumb($multiple);
$this->createMultiBreadcrumb($this->reOrderBreadCrumbByDate($multiple));
} else {
$this->createSingleBreadcrumb();
}
Expand Down Expand Up @@ -82,8 +82,8 @@ private function createSingleBreadcrumb()
* Create the string from the multiple breadcrumbs
* @param array $multiple
*/
private function createMultiBreadcrumb(array $multiple)
{
private function createMultiBreadcrumb(array $multiple)
{
foreach ($multiple as $m) {
$this->i = 0;
$this->str .= '<i class="material-icons breadcrumb-icon">label</i>';
Expand All @@ -108,7 +108,17 @@ private function buildTree(array $elements, $parentId = 0)
$this->i++;
}
}

return $branch;
}

/**
* We have to reorder the actual roots by the avilable date
*/
private function reOrderBreadCrumbByDate(array $roots): array {
uasort($roots,function($a,$b){
return strcmp($a->avdate,$b->avdate);
});
return $roots;
}

}

0 comments on commit 013108b

Please sign in to comment.