mirror of
https://github.com/humhub/humhub.git
synced 2025-01-29 12:28:06 +01:00
Update Notification count for each pjax call.
This commit is contained in:
parent
338dd40e73
commit
a18146928d
@ -226,6 +226,11 @@ class View extends \yii\web\View
|
||||
$value = Html::encode(array_values($viewStatus)[0]);
|
||||
$this->registerJs('humhub.modules.ui.status.' . $type . '("' . $value . '")', View::POS_END, 'viewStatusMessage');
|
||||
}
|
||||
|
||||
if (Yii::$app->request->isPjax) {
|
||||
echo \humhub\widgets\LayoutAddons::widget();
|
||||
$this->flushJsConfig();
|
||||
}
|
||||
|
||||
if (Yii::$app->request->isAjax) {
|
||||
return parent::endBody();
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
|
||||
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
|
||||
namespace content\_generated;
|
||||
|
||||
// This class was automatically generated by build task
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace humhub\modules\notification;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\notification\models\Notification;
|
||||
|
||||
/**
|
||||
@ -131,5 +132,12 @@ class Events extends \yii\base\Object
|
||||
'source_pk' => $event->sender->getPrimaryKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function onLayoutAddons($event)
|
||||
{
|
||||
if(Yii::$app->request->isPjax) {
|
||||
$event->sender->addWidget(widgets\UpdateNotificationCount::className());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use humhub\modules\space\models\Space;
|
||||
use humhub\commands\IntegrityController;
|
||||
use humhub\commands\CronController;
|
||||
use humhub\components\ActiveRecord;
|
||||
use humhub\widgets\LayoutAddons;
|
||||
|
||||
return [
|
||||
'id' => 'notification',
|
||||
@ -17,7 +18,8 @@ return [
|
||||
array('class' => Space::className(), 'event' => Space::EVENT_BEFORE_DELETE, 'callback' => array(Events::className(), 'onSpaceDelete')),
|
||||
array('class' => IntegrityController::className(), 'event' => IntegrityController::EVENT_ON_RUN, 'callback' => array(Events::className(), 'onIntegrityCheck')),
|
||||
array('class' => CronController::className(), 'event' => CronController::EVENT_ON_DAILY_RUN, 'callback' => array(Events::className(), 'onCronDailyRun')),
|
||||
array('class' => ActiveRecord::className(), 'event' => ActiveRecord::EVENT_BEFORE_DELETE, 'callback' => [Events::className(), 'onActiveRecordDelete'])
|
||||
array('class' => ActiveRecord::className(), 'event' => ActiveRecord::EVENT_BEFORE_DELETE, 'callback' => [Events::className(), 'onActiveRecordDelete']),
|
||||
array('class' => LayoutAddons::className(), 'event' => LayoutAddons::EVENT_BEFORE_RUN, 'callback' => [Events::className(), 'onLayoutAddons'])
|
||||
),
|
||||
];
|
||||
?>
|
@ -219,7 +219,7 @@ humhub.module('notification', function (module, require, $) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.menu = NotificationDropDown.instance('#notification_widget');
|
||||
};
|
||||
|
||||
var initOverviewPage = function () {
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\notification\widgets;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* UpdateNotificationCount widget is an LayoutAddon widget for updating the notification count
|
||||
* and is only used if pjax is active.
|
||||
*
|
||||
* @author buddha
|
||||
* @since 1.2
|
||||
*/
|
||||
class UpdateNotificationCount extends \yii\base\Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if (Yii::$app->user->isGuest) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->render('updateNotificationCount', [
|
||||
'count' => \humhub\modules\notification\models\Notification::findUnseen()->count()
|
||||
]);
|
||||
}
|
||||
}
|
@ -24,22 +24,23 @@ class LayoutAddons extends BaseStack
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addWidget(GlobalModal::className());
|
||||
$this->addWidget(GlobalConfirmModal::className());
|
||||
|
||||
if(Yii::$app->params['installed']) {
|
||||
$this->addWidget(\humhub\modules\tour\widgets\Tour::className());
|
||||
$this->addWidget(\humhub\modules\admin\widgets\TrackingWidget::className());
|
||||
}
|
||||
|
||||
$this->addWidget(LoaderWidget::className(), ['show' => false, 'id' => "humhub-ui-loader-default"]);
|
||||
$this->addWidget(StatusBar::className());
|
||||
$this->addWidget(BlueimpGallery::className());
|
||||
if(!Yii::$app->request->isPjax) {
|
||||
$this->addWidget(GlobalModal::className());
|
||||
$this->addWidget(GlobalConfirmModal::className());
|
||||
|
||||
if (Yii::$app->params['enablePjax']) {
|
||||
$this->addWidget(Pjax::className());
|
||||
}
|
||||
if(Yii::$app->params['installed']) {
|
||||
$this->addWidget(\humhub\modules\tour\widgets\Tour::className());
|
||||
$this->addWidget(\humhub\modules\admin\widgets\TrackingWidget::className());
|
||||
}
|
||||
|
||||
$this->addWidget(LoaderWidget::className(), ['show' => false, 'id' => "humhub-ui-loader-default"]);
|
||||
$this->addWidget(StatusBar::className());
|
||||
$this->addWidget(BlueimpGallery::className());
|
||||
|
||||
if (Yii::$app->params['enablePjax']) {
|
||||
$this->addWidget(Pjax::className());
|
||||
}
|
||||
}
|
||||
parent::init();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user