Refactor filter widget to use an approach much like ReportContainer
This commit is contained in:
parent
85c47c4e01
commit
6e54fea23f
|
|
@ -15,6 +15,25 @@ use ApplicationException;
|
|||
*/
|
||||
class Filter extends WidgetBase
|
||||
{
|
||||
//
|
||||
// Configurable properties
|
||||
//
|
||||
|
||||
/**
|
||||
* @var array Scope definition configuration.
|
||||
*/
|
||||
public $scopes;
|
||||
|
||||
/**
|
||||
* @var string The context of this filter, scopes that do not belong
|
||||
* to this context will not be shown.
|
||||
*/
|
||||
protected $context = null;
|
||||
|
||||
//
|
||||
// Object properties
|
||||
//
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
@ -35,12 +54,6 @@ class Filter extends WidgetBase
|
|||
*/
|
||||
protected $scopeModels = [];
|
||||
|
||||
/**
|
||||
* @var string The context of this filter, scopes that do not belong
|
||||
* to this context will not be shown.
|
||||
*/
|
||||
protected $activeContext = null;
|
||||
|
||||
/**
|
||||
* @var array List of CSS classes to apply to the filter container element
|
||||
*/
|
||||
|
|
@ -51,7 +64,10 @@ class Filter extends WidgetBase
|
|||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->activeContext = $this->getConfig('context');
|
||||
$this->fillFromConfig([
|
||||
'scopes',
|
||||
'context',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -241,11 +257,11 @@ class Filter extends WidgetBase
|
|||
/*
|
||||
* All scopes
|
||||
*/
|
||||
if (!isset($this->config->scopes) || !is_array($this->config->scopes)) {
|
||||
$this->config->scopes = [];
|
||||
if (!isset($this->scopes) || !is_array($this->scopes)) {
|
||||
$this->scopes = [];
|
||||
}
|
||||
|
||||
$this->addScopes($this->config->scopes);
|
||||
$this->addScopes($this->scopes);
|
||||
|
||||
/*
|
||||
* Extensibility
|
||||
|
|
@ -442,10 +458,11 @@ class Filter extends WidgetBase
|
|||
|
||||
/**
|
||||
* Returns the active context for displaying the filter.
|
||||
* @return string
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
return $this->activeContext;
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue