mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Filter archived spaces on directory (#5349)
* Filter archived spaces on directory * Update CHANGELOG.md Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
parent
5047724d6f
commit
0a6728772b
@ -36,4 +36,5 @@
|
||||
- Fix #5331: Fix js error on pjax open "Directory" page
|
||||
- Enh #5333: Module's events handlers registration: check if method exists
|
||||
- Enh #5300: Blocking users for space
|
||||
- Enh #5349: Filter archived spaces on directory
|
||||
- Enh #5350: Show the latest file version
|
||||
|
@ -66,7 +66,11 @@ class SpaceDirectoryQuery extends ActiveQuerySpace
|
||||
|
||||
public function filterByConnection(): SpaceDirectoryQuery
|
||||
{
|
||||
switch (Yii::$app->request->get('connection')) {
|
||||
$connection = Yii::$app->request->get('connection');
|
||||
|
||||
$this->filterByConnectionArchived($connection === 'archived');
|
||||
|
||||
switch ($connection) {
|
||||
case 'member':
|
||||
return $this->filterByConnectionMember();
|
||||
case 'follow':
|
||||
@ -102,6 +106,13 @@ class SpaceDirectoryQuery extends ActiveQuerySpace
|
||||
]);
|
||||
}
|
||||
|
||||
public function filterByConnectionArchived(bool $showArchived = false): SpaceDirectoryQuery
|
||||
{
|
||||
return $this->andWhere('space.status ' . ($showArchived ? '=' : '!=') . ' :spaceStatus', [
|
||||
':spaceStatus' => Space::STATUS_ARCHIVED,
|
||||
]);
|
||||
}
|
||||
|
||||
public function order(): SpaceDirectoryQuery
|
||||
{
|
||||
switch (SpaceDirectoryFilters::getValue('sort')) {
|
||||
|
@ -54,6 +54,8 @@ class SpaceDirectoryFilters extends DirectoryFilters
|
||||
'member' => Yii::t('SpaceModule.base', 'Member'),
|
||||
'follow' => Yii::t('SpaceModule.base', 'Following'),
|
||||
'none' => Yii::t('SpaceModule.base', 'Neither..nor'),
|
||||
'separator' => '———————————',
|
||||
'archived' => Yii::t('SpaceModule.base', 'Show archived spaces'),
|
||||
],
|
||||
'sortOrder' => 300,
|
||||
]);
|
||||
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2021 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\space\widgets;
|
||||
|
||||
use humhub\components\Widget;
|
||||
use humhub\modules\space\models\Space;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* SpaceDirectoryStatus shows status like "Archived" for spaces cards
|
||||
*
|
||||
* @since 1.10
|
||||
* @author Luke
|
||||
*/
|
||||
class SpaceDirectoryStatus extends Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Space
|
||||
*/
|
||||
public $space;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if ($this->space->isArchived()) {
|
||||
return $this->render('spaceDirectoryStatus', [
|
||||
'class' => 'label label-primary',
|
||||
'text' => Yii::t('SpaceModule.base', 'Archived'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,7 @@ use humhub\modules\space\models\Space;
|
||||
use humhub\modules\space\widgets\Image;
|
||||
use humhub\modules\space\widgets\SpaceDirectoryActionButtons;
|
||||
use humhub\modules\space\widgets\SpaceDirectoryIcons;
|
||||
use humhub\modules\space\widgets\SpaceDirectoryStatus;
|
||||
use humhub\modules\space\widgets\SpaceDirectoryTagList;
|
||||
use yii\web\View;
|
||||
|
||||
@ -17,7 +18,7 @@ use yii\web\View;
|
||||
/* @var $space Space */
|
||||
?>
|
||||
|
||||
<div class="card-panel">
|
||||
<div class="card-panel<?php if ($space->isArchived()) : ?> card-archived<?php endif; ?>">
|
||||
<div class="card-bg-image"<?php if ($space->getProfileBannerImage()->hasImage()) : ?> style="background-image: url('<?= $space->getProfileBannerImage()->getUrl() ?>')"<?php endif; ?>></div>
|
||||
<div class="card-header">
|
||||
<?= Image::widget([
|
||||
@ -26,6 +27,7 @@ use yii\web\View;
|
||||
'linkOptions' => ['data-contentcontainer-id' => $space->contentcontainer_id, 'class' => 'card-image-link'],
|
||||
'width' => 94,
|
||||
]); ?>
|
||||
<?= SpaceDirectoryStatus::widget(['space' => $space]); ?>
|
||||
<div class="card-icons">
|
||||
<?= SpaceDirectoryIcons::widget(['space' => $space]); ?>
|
||||
</div>
|
||||
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2021 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
/* @var $text string */
|
||||
/* @var $class string */
|
||||
?>
|
||||
|
||||
<span class="card-status <?= $class ?>"><?= $text ?></span>
|
@ -89,6 +89,7 @@ abstract class DirectoryFilters extends Widget
|
||||
case 'dropdown':
|
||||
case 'dropdownlist':
|
||||
$inputOptions['data-action-change'] = 'directory.applyFilters';
|
||||
$inputOptions['options'] = ['separator' => ['disabled' => '']];
|
||||
$inputHtml = Html::dropDownList($filter, self::getValue($filter), $data['options'], $inputOptions);
|
||||
break;
|
||||
|
||||
|
@ -86,6 +86,9 @@
|
||||
margin: 15px 0;
|
||||
border-radius: 4px;
|
||||
background-color: #ffffff;
|
||||
&.card-archived {
|
||||
filter: opacity(45%);
|
||||
}
|
||||
}
|
||||
|
||||
.card-icons .fa {
|
||||
@ -118,6 +121,10 @@
|
||||
border: 2px solid #fff;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.card-status {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
}
|
||||
.card-icons {
|
||||
display: table-cell;
|
||||
padding: 0 0 2px 5px;
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user