Skip to content

Commit

Permalink
Content type legend
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Jun 28, 2024
1 parent 37a189c commit 8a6013a
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 33 deletions.
23 changes: 23 additions & 0 deletions resources/css/calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -834,3 +834,26 @@ tbody,
float: left;
}
}

/* Calendar type legend */
.calendar-type-legend .calendar-type-item {
display: inline-block;
background: var(--background-color-secondary);
color: var(--text-color-main);
border-radius: 4px;
padding: 4px 16px;
margin-right: 8px;
margin-bottom: 8px;
font-size: 14px;
font-weight: 500;
}
.calendar-type-legend .calendar-type-color {
display: inline-block;
width: 16px;
height: 16px;
border: 1px solid var(--text-color-soft3);
border-radius: 4px;
margin-right: 6px;
position: relative;
top: 2px;
}
2 changes: 1 addition & 1 deletion resources/css/calendar.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions views/global/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use humhub\modules\calendar\helpers\Url;
use humhub\modules\calendar\widgets\CalendarControls;
use humhub\modules\calendar\widgets\CalendarFilterBar;
use humhub\modules\calendar\widgets\CalendarTypeLegend;
use humhub\modules\calendar\widgets\ConfigureButton;
use humhub\modules\calendar\widgets\FullCalendar;
use humhub\modules\ui\view\helpers\ThemeHelper;
Expand All @@ -11,6 +12,7 @@
/* @var $this \humhub\modules\ui\view\components\View */
/* @var $selectors array */
/* @var $filters array */
/* @var $editUrl string */

$isFluid = ThemeHelper::isFluid();
$containerClass = $isFluid ? 'container-fluid' : 'container';
Expand Down Expand Up @@ -48,6 +50,8 @@
]) ?>
</div>
</div>

<?= CalendarTypeLegend::widget() ?>
</div>

<?= FooterMenu::widget(['location' => FooterMenu::LOCATION_FULL_PAGE]) ?>
12 changes: 7 additions & 5 deletions views/view/index.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
use humhub\modules\calendar\widgets\CalendarFilterBar;
use humhub\modules\calendar\widgets\CalendarTypeLegend;
use humhub\modules\calendar\widgets\FullCalendar;
use humhub\modules\calendar\helpers\Url;
use humhub\modules\content\components\ContentContainerActiveRecord;
use humhub\modules\ui\view\helpers\ThemeHelper;

$loadAjaxUrl = Url::toAjaxLoad($contentContainer);

/* @var $filters array */
/* @var $canConfigure bool */
/* @var $canAddEntries bool */

/* @var $contentContainer ContentContainerActiveRecord */
?>
<div class="panel panel-default">
<div class="panel-body" style="background-color:<?= $this->theme->variable('background-color-secondary') ?>">
Expand All @@ -21,10 +21,12 @@
<div class="panel-body">
<?= FullCalendar::widget([
'canWrite' => $canAddEntries,
'loadUrl' => $loadAjaxUrl,
'loadUrl' => Url::toAjaxLoad($contentContainer),
'contentContainer' => $contentContainer,
'aspectRatio' => ThemeHelper::isFluid() ? 2 : 1.7
]);
?>
</div>
</div>
</div>

<?= CalendarTypeLegend::widget(['contentContainer' => $contentContainer]) ?>
42 changes: 42 additions & 0 deletions widgets/CalendarTypeLegend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\calendar\widgets;

use humhub\components\Widget;
use humhub\modules\calendar\models\CalendarEntryType;
use humhub\modules\content\components\ContentContainerActiveRecord;

class CalendarTypeLegend extends Widget
{
public ?ContentContainerActiveRecord $contentContainer = null;

public function run()
{
$calendarTypes = $this->getCalendarTypes();

if (empty($calendarTypes)) {
return '';
}

return $this->render('calendarTypeLegend', [
'calendarTypes' => $calendarTypes,
]);
}

/**
* @return CalendarEntryType[]
*/
public function getCalendarTypes(): array
{
$query = $this->contentContainer
? CalendarEntryType::findByContainer($this->contentContainer, true)
: CalendarEntryType::find();

return $query->all();
}
}
27 changes: 0 additions & 27 deletions widgets/CalendarTypeListView.php

This file was deleted.

24 changes: 24 additions & 0 deletions widgets/views/calendarTypeLegend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

use humhub\modules\calendar\models\CalendarEntryType;

/* @var CalendarEntryType[] $calendarTypes */
?>
<div class="panel panel-default calendar-type-legend">
<div class="panel-heading">
<strong><?= Yii::t('CalendarModule.base', 'Calendar Types') ?></strong>
</div>
<div class="panel-body">
<?php foreach ($calendarTypes as $calendarType) : ?>
<div class="calendar-type-item">
<span class="calendar-type-color" style="background:<?= $calendarType->color ?>"></span>
<?= $calendarType->name ?>
</div>
<?php endforeach; ?>
</div>
</div>

0 comments on commit 8a6013a

Please sign in to comment.