Skip to content

Commit

Permalink
Initialize the Filter widget even when no scopes are initially defined (
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin authored Sep 26, 2024
1 parent 58cab73 commit fb325f5
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions modules/backend/behaviors/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,39 +235,37 @@ public function makeList($definition = null)
if (isset($listConfig->filter)) {
$filterConfig = $this->makeConfig($listConfig->filter);

if (!empty($filterConfig->scopes)) {
$widget->cssClasses[] = 'list-flush';

$filterConfig->alias = $widget->alias . 'Filter';
$filterWidget = $this->makeWidget(\Backend\Widgets\Filter::class, $filterConfig);
$filterWidget->bindToController();

/*
* Filter the list when the scopes are changed
*/
$filterWidget->bindEvent('filter.update', function () use ($widget, $filterWidget) {
return $widget->onFilter();
});
$widget->cssClasses[] = 'list-flush';

/*
* Filter Widget with extensibility
*/
$filterWidget->bindEvent('filter.extendScopes', function () use ($filterWidget) {
$this->controller->listFilterExtendScopes($filterWidget);
});
$filterConfig->alias = $widget->alias . 'Filter';
$filterWidget = $this->makeWidget(\Backend\Widgets\Filter::class, $filterConfig);
$filterWidget->bindToController();

/*
* Extend the query of the list of options
*/
$filterWidget->bindEvent('filter.extendQuery', function ($query, $scope) {
$this->controller->listFilterExtendQuery($query, $scope);
});
/*
* Filter the list when the scopes are changed
*/
$filterWidget->bindEvent('filter.update', function () use ($widget, $filterWidget) {
return $widget->onFilter();
});

// Apply predefined filter values
$widget->addFilter([$filterWidget, 'applyAllScopesToQuery']);
/*
* Filter Widget with extensibility
*/
$filterWidget->bindEvent('filter.extendScopes', function () use ($filterWidget) {
$this->controller->listFilterExtendScopes($filterWidget);
});

$this->filterWidgets[$definition] = $filterWidget;
}
/*
* Extend the query of the list of options
*/
$filterWidget->bindEvent('filter.extendQuery', function ($query, $scope) {
$this->controller->listFilterExtendQuery($query, $scope);
});

// Apply predefined filter values
$widget->addFilter([$filterWidget, 'applyAllScopesToQuery']);

$this->filterWidgets[$definition] = $filterWidget;
}

return $widget;
Expand Down

0 comments on commit fb325f5

Please sign in to comment.