mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Add collapsible filter state in URL (#6445)
This commit is contained in:
parent
9969285398
commit
0dae15c975
@ -81,3 +81,4 @@ HumHub Changelog
|
||||
- Fix #6428: Translation for custom profile field is served from wrong file
|
||||
- Fix #6429: Fix Marketplace view
|
||||
- Fix #6383: Remove permission verifying from archive methods
|
||||
- Enh #6439: Add collapsible filter state in URL
|
||||
|
@ -18,6 +18,7 @@ humhub.module('stream.wall', function (module, require, $) {
|
||||
var Widget = require('ui.widget').Widget;
|
||||
var event = require('event');
|
||||
var Filter = require('ui.filter').Filter;
|
||||
var Url = require('ui.filter').Url;
|
||||
var string = require('util').string;
|
||||
var topic = require('topic');
|
||||
var view = require('ui.view');
|
||||
@ -382,11 +383,6 @@ humhub.module('stream.wall', function (module, require, $) {
|
||||
|
||||
WallStreamFilter.prototype.initFilterCount = function () {
|
||||
this.updateFilterCount();
|
||||
|
||||
var activeFiltersCount = parseInt(this.$.find('.filterCount').text().replace(/^.+?(\d+).+?$/, '$1'));
|
||||
if (activeFiltersCount > 0 && this.$.find('.wall-stream-filter-body').is(':hidden')) {
|
||||
this.toggleFilterPanel();
|
||||
}
|
||||
}
|
||||
|
||||
WallStreamFilter.prototype.updateFilterCount = function () {
|
||||
@ -414,7 +410,9 @@ humhub.module('stream.wall', function (module, require, $) {
|
||||
};
|
||||
|
||||
WallStreamFilter.prototype.toggleFilterPanel = function() {
|
||||
this.$.find('.wall-stream-filter-body').slideToggle();
|
||||
const filters = this.$.find('.wall-stream-filter-body');
|
||||
Url.updateParam('filters_visible', filters.is(':visible') ? 0 : 1);
|
||||
filters.slideToggle();
|
||||
};
|
||||
|
||||
WallStreamFilter.template = {
|
||||
|
@ -345,4 +345,9 @@ class WallStreamFilterNavigation extends FilterNavigation
|
||||
'class' => 'wallFilterPanel'
|
||||
];
|
||||
}
|
||||
|
||||
public function isCollapsed(): bool
|
||||
{
|
||||
return !Yii::$app->request->get('filters_visible', 0);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ use yii\helpers\Html;
|
||||
/* @var $this \humhub\modules\ui\view\components\View */
|
||||
/* @var $panels [] */
|
||||
/* @var $options [] */
|
||||
/* @var $isCollapsed bool */
|
||||
|
||||
$panelColumn1Blocks = isset($panels[WallStreamFilterNavigation::PANEL_COLUMN_1]) ? $panels[WallStreamFilterNavigation::PANEL_COLUMN_1] : null;
|
||||
$panelColumn2Blocks = isset($panels[WallStreamFilterNavigation::PANEL_COLUMN_2]) ? $panels[WallStreamFilterNavigation::PANEL_COLUMN_2] : null;
|
||||
@ -30,7 +31,7 @@ $panelColumn4Blocks = isset($panels[WallStreamFilterNavigation::PANEL_COLUMN_4])
|
||||
<?= Button::asLink(Yii::t('ContentModule.base', 'Filter') . '<b class="caret"></b>')
|
||||
->cssClass('wall-stream-filter-toggle')->icon('fa-filter')->sm()->style('pa') ?>
|
||||
</div>
|
||||
<div class="wall-stream-filter-body" style="display:none">
|
||||
<div class="wall-stream-filter-body"<?php if ($isCollapsed) : ?> style="display:none"<?php endif; ?>>
|
||||
<div class="filter-root">
|
||||
<div class="row">
|
||||
<?= FilterPanel::widget(['blocks' => $panelColumn1Blocks, 'span' => count($panels)])?>
|
||||
|
@ -377,6 +377,7 @@ humhub.module('ui.filter', function(module, require, $) {
|
||||
Filter: Filter,
|
||||
FilterInput: FilterInput,
|
||||
findFilterByComponent: findFilterByComponent,
|
||||
addFilterType: addFilterType
|
||||
addFilterType: addFilterType,
|
||||
Url: Url
|
||||
});
|
||||
});
|
||||
|
@ -152,7 +152,8 @@ abstract class FilterNavigation extends JsWidget
|
||||
{
|
||||
return $this->render($this->view, [
|
||||
'panels' => $this->filterOutEmptyPanels(),
|
||||
'options' => $this->getOptions()
|
||||
'options' => $this->getOptions(),
|
||||
'isCollapsed' => $this->isCollapsed()
|
||||
]);
|
||||
}
|
||||
|
||||
@ -269,4 +270,9 @@ abstract class FilterNavigation extends JsWidget
|
||||
|
||||
return array_key_exists($filterId, $this->definition) || in_array($filterId, $this->definition);
|
||||
}
|
||||
|
||||
public function isCollapsed(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user