Do not hardcode action specific parameters to preserve in the FilterEditor
This should only happen for other control parameters or framework specific stuff. This is still subject to improvement, as this solution is rather ugly imho.. refs #10370
This commit is contained in:
parent
d56056bba7
commit
8d04c8548a
|
@ -97,7 +97,7 @@ class GroupController extends AuthBackendController
|
|||
->from('group_membership', array('user_name'))
|
||||
->where('group_name', $groupName);
|
||||
|
||||
$this->setupFilterControl($members, null, array('user'));
|
||||
$this->setupFilterControl($members, null, array('user'), array('group'));
|
||||
$this->setupPaginationControl($members);
|
||||
$this->setupLimitControl();
|
||||
$this->setupSortControl(
|
||||
|
|
|
@ -99,7 +99,8 @@ class UserController extends AuthBackendController
|
|||
$this->setupFilterControl(
|
||||
$memberships,
|
||||
array('group_name' => t('User Group')),
|
||||
array('group_name')
|
||||
array('group_name'),
|
||||
array('user')
|
||||
);
|
||||
$this->setupPaginationControl($memberships);
|
||||
$this->setupLimitControl();
|
||||
|
|
|
@ -186,6 +186,7 @@ class Controller extends ModuleActionController
|
|||
* @param Filterable $filterable The filterable to create a filter editor for
|
||||
* @param array $filterColumns The filter columns to offer to the user
|
||||
* @param array $searchColumns The search columns to utilize for quick searches
|
||||
* @param array $preserveParams The url parameters to preserve
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
|
@ -194,25 +195,26 @@ class Controller extends ModuleActionController
|
|||
protected function setupFilterControl(
|
||||
Filterable $filterable,
|
||||
array $filterColumns = null,
|
||||
array $searchColumns = null
|
||||
array $searchColumns = null,
|
||||
array $preserveParams = null
|
||||
) {
|
||||
$editor = Widget::create('filterEditor')
|
||||
$defaultPreservedParams = array(
|
||||
'limit', // setupPaginationControl()
|
||||
'sort', // setupSortControl()
|
||||
'dir', // setupSortControl()
|
||||
'backend', // Framework
|
||||
'_dev' // Framework
|
||||
);
|
||||
|
||||
$editor = Widget::create('filterEditor');
|
||||
call_user_func_array(
|
||||
array($editor, 'preserveParams'),
|
||||
array_merge($defaultPreservedParams, $preserveParams ?: array())
|
||||
);
|
||||
|
||||
$editor
|
||||
->setQuery($filterable)
|
||||
->preserveParams(
|
||||
'limit',
|
||||
'sort',
|
||||
'dir',
|
||||
'format',
|
||||
'view',
|
||||
'user',
|
||||
'group',
|
||||
'backend',
|
||||
'stateType',
|
||||
'addColumns',
|
||||
'problems',
|
||||
'_dev'
|
||||
)
|
||||
->ignoreParams('page')
|
||||
->ignoreParams('page') // setupPaginationControl()
|
||||
->setColumns($filterColumns)
|
||||
->setSearchColumns($searchColumns)
|
||||
->handleRequest($this->getRequest());
|
||||
|
|
|
@ -574,7 +574,12 @@ class ListController extends Controller
|
|||
*/
|
||||
protected function filterQuery(DataView $dataView)
|
||||
{
|
||||
$this->setupFilterControl($dataView);
|
||||
$this->setupFilterControl($dataView, null, null, array(
|
||||
'format', // handleFormatRequest()
|
||||
'stateType', // hostsAction() and servicesAction()
|
||||
'addColumns', // addColumns()
|
||||
'problems' // servicegridAction()
|
||||
));
|
||||
$this->handleFormatRequest($dataView);
|
||||
return $dataView;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue