Skip to content

Commit

Permalink
Merge pull request #527 from humhub/enh/526-display-select-space-prompt
Browse files Browse the repository at this point in the history
Enh #526: New event from the global calendar: display "Select space..…
  • Loading branch information
luke- authored Jan 24, 2025
2 parents f0f70c4 + 92ce780 commit 22e0e4b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions controllers/GlobalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ private function getFilterSettings()
public function actionSelect($start = null, $end = null)
{
/* @var $user User */
$contentContainerSelection = [];
$user = Yii::$app->user->getIdentity();
$canSelectProfileCalendar = $user->moduleManager->isEnabled('calendar') || $user->moduleManager->canEnable('calendar');

if ($user->moduleManager->isEnabled('calendar') || $user->moduleManager->canEnable('calendar')) {
$contentContainerSelection = [];
if ($canSelectProfileCalendar) {
$contentContainerSelection[$user->contentcontainer_id] = Yii::t('CalendarModule.base', 'Profile Calendar');
}

Expand All @@ -157,6 +158,7 @@ public function actionSelect($start = null, $end = null)

return $this->renderAjax('selectContainerModal', [
'contentContainerSelection' => $contentContainerSelection,
'canSelectProfileCalendar' => $canSelectProfileCalendar,
'submitUrl' => Url::to(['/calendar/global/select-submit', 'start' => $start, 'end' => $end]),
]);
}
Expand Down
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 #526: New event from the global calendar: display "Select space..." or "Select calendar..." prompt instead of first Space
- Enh: Show the "Filter by types" filter only if a list a type is available

1.7.1 (January 17, 2025)
Expand Down
2 changes: 2 additions & 0 deletions tests/codeception/acceptance/GlobalCalendarCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function testGlobalCalendarCreateEntry(AcceptanceTester $I)
$I->click('.fc-today');
$I->expectTo('see the choose calendar modal');
$I->waitForText('Choose target calendar');
$I->click('.select2-selection--single');
$I->click('.select2-results__option:nth-child(2)');
$I->click('Next', '#globalModal');


Expand Down
9 changes: 8 additions & 1 deletion views/global/selectContainerModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use humhub\widgets\ModalDialog;

/* @var $contentContainerSelection array */
/* @var $canSelectProfileCalendar bool */
/* @var $submitUrl array */

?>
Expand All @@ -20,7 +21,13 @@
<?php if ($contentContainerSelection): ?>
<?php $form = ActiveForm::begin() ?>
<div class="modal-body">
<?= Html::dropDownList('contentContainerId', null, $contentContainerSelection, ['class' => 'form-control', 'data-ui-select2' => '']) ?>
<?= Html::dropDownList('contentContainerId', null, $contentContainerSelection, [
'class' => 'form-control',
'data-ui-select2' => '',
'prompt' => $canSelectProfileCalendar ?
Yii::t('CalendarModule.base', 'Select calendar...') :
Yii::t('CalendarModule.base', 'Select space...'),
]) ?>
</div>
<div class="modal-footer">
<?= ModalButton::submitModal($submitUrl, Yii::t('CalendarModule.base', 'Next')) ?>
Expand Down

0 comments on commit 22e0e4b

Please sign in to comment.