Skip to content

Commit

Permalink
make filter hideable
Browse files Browse the repository at this point in the history
  • Loading branch information
stepapo committed May 10, 2021
1 parent c96588d commit ecb56bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@ class Filter

public ?string $columnName;

public bool $hide;


/** @var array|Option[]|null $options */
public function __construct(
?array $options = null,
?string $prompt = null,
?string $columnName = null,
?string $function = null,
?int $collapse = null
?int $collapse = null,
bool $hide = false
) {
$this->options = $options;
$this->prompt = $prompt;
$this->collapse = $collapse;
$this->function = $function;
$this->columnName = $columnName;
$this->hide = $hide;
}


Expand All @@ -54,6 +58,9 @@ public static function createFromArray(array $config, array $params = []): Filte
if (array_key_exists('function', $config)) {
$filter->setFunction($config['function']);
}
if (array_key_exists('hide', $config)) {
$filter->setHide($config['hide']);
}
return $filter;
}

Expand Down Expand Up @@ -110,6 +117,19 @@ public function setFunction(?string $function): Filter
}


public function getHide(): bool
{
return $this->hide;
}


public function setHide(bool $hide): Filter
{
$this->hide = $hide;
return $this;
}


public function addOption(Option $option): Filter
{
$this->options[$option->name] = $option;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Dataset/FilterList/list.latte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{snippet}
{foreach $columns as $column}
{if $column->filter}
{if $column->filter && !$column->filter->hide}
{control filter-$column->name}
{/}
{/}
Expand Down

0 comments on commit ecb56bc

Please sign in to comment.