From 75d8ce454345c054b4e3d5e21e413533d961d52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Farr=C3=A9?= <contact@marc.fun> Date: Wed, 22 Jan 2025 18:36:50 +0000 Subject: [PATCH] Enh #526: New event from the global calendar: display "Select space..." prompt instead of first Space --- controllers/GlobalController.php | 6 ++++-- docs/CHANGELOG.md | 1 + views/global/selectContainerModal.php | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/controllers/GlobalController.php b/controllers/GlobalController.php index d9a68706..8bf6168d 100644 --- a/controllers/GlobalController.php +++ b/controllers/GlobalController.php @@ -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'); } @@ -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]), ]); } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0e5b645c..8f560df7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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..." prompt instead of first Space 1.7.1 (January 17, 2025) ------------------------ diff --git a/views/global/selectContainerModal.php b/views/global/selectContainerModal.php index 4559cf81..f2bbd8d1 100644 --- a/views/global/selectContainerModal.php +++ b/views/global/selectContainerModal.php @@ -12,6 +12,7 @@ use humhub\widgets\ModalDialog; /* @var $contentContainerSelection array */ +/* @var $canSelectProfileCalendar bool */ /* @var $submitUrl array */ ?> @@ -20,7 +21,11 @@ <?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 ? null : Yii::t('CalendarModule.base', 'Select space...'), + ]) ?> </div> <div class="modal-footer"> <?= ModalButton::submitModal($submitUrl, Yii::t('CalendarModule.base', 'Next')) ?>