Skip to content

Commit

Permalink
Enh: Show the "Filter by types" filter only if a list a type is avail…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
marc-farre committed Jan 22, 2025
1 parent 9046e57 commit a00409a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.7.2 (Unreleased)
------------------------
- Fix #525: Fix Space calendar header
- Enh: Show the "Filter by types" filter only if a list a type is available

1.7.1 (January 17, 2025)
------------------------
Expand Down
10 changes: 10 additions & 0 deletions widgets/CalendarFilterBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
namespace humhub\modules\calendar\widgets;

use humhub\components\Widget;
use humhub\modules\calendar\models\CalendarEntryType;
use humhub\modules\content\helpers\ContentContainerHelper;
use humhub\modules\content\models\ContentTag;
use Yii;

/**
Expand All @@ -34,6 +37,13 @@ public function run()
return '';
}

$currentContentContainer = ContentContainerHelper::getCurrent();
$typesQuery = ContentTag::find()->where(['type' => CalendarEntryType::class]);
if ($currentContentContainer) {
$typesQuery->andWhere(['contentcontainer_id' => $currentContentContainer->contentcontainer_id]);
}
$this->showTypes = $this->showTypes && $typesQuery->exists();

return $this->render('calendarFilterBar', [
'filters' => $this->filters,
'canConfigure' => $this->canConfigure,
Expand Down

0 comments on commit a00409a

Please sign in to comment.