Skip to content

Commit

Permalink
Move browse all link construction to presenter [PUB-205]
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Jul 15, 2024
1 parent cb0a06e commit ac57872
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/Presenters/Admin/DigitalPublicationArticlePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Presenters\Admin;


use Illuminate\Support\Str;
use App\Presenters\BasePresenter;

class DigitalPublicationArticlePresenter extends BasePresenter
Expand Down Expand Up @@ -37,6 +39,23 @@ public function getArticleUrl($digitalPublication, $article = null)
]);
}

public function getBrowseMoreLink($showAll = false)
{
if ($this->entity->children->count() > 0 && !$showAll) {
return [
[
'label' => 'Browse all '. $this->entity->children->count(). ' '. $this->entity->title,
'href' => route('collection.publications.digital-publications.showListing',
[
'id' => $this->entity->digitalPublication->id,
'slug' => $this->entity->digitalPublication->getSlug()
]) . '#' . Str::kebab($this->entity->title)
]
];
}
return '';
}

public function references()
{
if (empty($this->entity->references)) {
Expand Down
2 changes: 1 addition & 1 deletion resources/views/site/digitalPublicationDetail.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
@component('components.molecules._m-title-bar', [
'variation' => 'm-title-bar--compact m-title-bar--light',
])
@slot('links', $topLevelArticle->children->count() > 0 && !$showAll ? ([['label' => 'Browse all '. $topLevelArticle->children->count(). ' '. $topLevelArticle->title, 'href' => route('collection.publications.digital-publications.showListing', ['id' => $item->id, 'slug' => $item->getSlug()]) . '#' . Str::kebab($topLevelArticle->title)]]) : '')
@slot('links', $topLevelArticle->present()->getBrowseMoreLink($showAll))
{!! $topLevelArticle->title !!}
@endcomponent

Expand Down

0 comments on commit ac57872

Please sign in to comment.