Skip to content

Commit

Permalink
Manage list filters
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Dec 9, 2015
1 parent d17d3a9 commit a9853fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@foreach($list->listFilterContents()[$listFilterKey] as $listFilterId => $listFilterValue)
<li>
<a href="{{ route('cms.list', ["category"=>$category->key, "entity"=>$entity->key, "sub"=>$listFilterKey.".".$listFilterId]) }}">
<a href="{{ route('cms.list', ["category"=>$category->key(), "entity"=>$entity->key(), "sub"=>$listFilterKey.".".$listFilterId]) }}">
{{ $listFilterValue }}
</a>
</li>
Expand Down
38 changes: 22 additions & 16 deletions src/Dvlpp/Sharp/Config/SharpEntityConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
namespace Dvlpp\Sharp\Config;

use Dvlpp\Sharp\Config\Commands\SharpCommandConfig;
use Dvlpp\Sharp\Config\FormFields\SharpFileFormFieldConfig;
use Dvlpp\Sharp\Config\Utils\HasFormTemplateColumnTrait;

/**
* TODO gérer les Filtres !
* The sharp config base class, which every entity config must extend.
*
* Class SharpEntityConfig
Expand Down Expand Up @@ -150,6 +148,13 @@ function buildEntityCommands() {}
*/
function buildListCommands() {}

/**
* Build the list filters, using addListFilter()
*
* @return void
*/
function buildListFilters() {}

/**
* @return SharpEntityStateIndicator|null
*/
Expand Down Expand Up @@ -197,6 +202,16 @@ final function addListCommand(SharpCommandConfig $commandConfig)
$this->listCommandsConfig[] = $commandConfig;
}

/**
* Add a list filter.
*
* @param string $name
*/
final function addListFilter($name)
{
$this->listFilters[] = $name;
}

/**
* @return null|string
*/
Expand All @@ -213,9 +228,6 @@ public function validator()
return $this->validator;
}

/**
* @return array
*/
public function formFieldsConfig()
{
if(!$this->formFieldsConfig) {
Expand All @@ -237,17 +249,11 @@ public function listTemplateColumnsConfig()
return (array) $this->listTemplateColumnsConfig;
}

/**
* @param SharpFormTemplateTabConfig $formTemplateTabConfig
*/
public function addFormTemplateTab(SharpFormTemplateTabConfig $formTemplateTabConfig)
{
$this->formTemplateTabsConfig[] = $formTemplateTabConfig;
}

/**
* @return array
*/
public function formTemplateTabsConfig()
{
if(!$this->formFieldsConfig) {
Expand Down Expand Up @@ -318,7 +324,11 @@ public function defaultSort()
*/
public function listFilters()
{
return $this->listFilters;
if(!$this->listFilters) {
$this->buildListFilters();
}

return (array) $this->listFilters;
}

/**
Expand Down Expand Up @@ -435,10 +445,6 @@ public function idAttribute()
return $this->idAttribute;
}

/**
* @param $key
* @return SharpFileFormFieldConfig|null
*/
public function findField($key)
{
foreach($this->formFieldsConfig() as $formField) {
Expand Down

0 comments on commit a9853fb

Please sign in to comment.