diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-07-23 20:25:21 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-07-23 20:25:21 +0200 |
commit | 4e2624a23f056b985a7613fe6c648e9abb20e261 (patch) | |
tree | 77414e32d15fe43f870c13312f1b333c260cafab /fai_gestion/plugins/CustomTheme | |
parent | 275785bef739bc3959cd7b1c671e53a30355c897 (diff) | |
download | chd_gestion-4e2624a23f056b985a7613fe6c648e9abb20e261.zip chd_gestion-4e2624a23f056b985a7613fe6c648e9abb20e261.tar.gz chd_gestion-4e2624a23f056b985a7613fe6c648e9abb20e261.tar.bz2 |
bake : action view, limit and filter fields displayed
Diffstat (limited to 'fai_gestion/plugins/CustomTheme')
-rw-r--r-- | fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig | 5 | ||||
-rw-r--r-- | fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php | 18 |
2 files changed, 21 insertions, 2 deletions
diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig index a5563bf..0b2dd28 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig @@ -149,19 +149,20 @@ {% for alias, details in relations %} {% set otherSingularVar = alias|variable %} {% set otherPluralHumanName = details.controller|underscore|humanize %} +{% set fields = BakeExtra.filterFieldsOther(details.fields, details.controller) %} <div class="related"> <h4><?= __('Related {{ otherPluralHumanName }}') ?></h4> <?php if (!empty(${{ singularVar }}->{{ details.property }})): ?> <table cellpadding="0" cellspacing="0"> <tr> -{% for field in details.fields %} +{% for field in fields %} <th scope="col"><?= __('{{ field|humanize }}') ?></th> {% endfor %} <th scope="col" class="actions"><?= __('Actions') ?></th> </tr> <?php foreach (${{ singularVar }}->{{ details.property }} as ${{ otherSingularVar }}): ?> <tr> -{% for field in details.fields %} +{% for field in fields %} <td><?= h(${{ otherSingularVar }}->{{ field }}) ?></td> {% endfor %} {% set otherPk = '$' ~ otherSingularVar ~ '->' ~ details.primaryKey[0] %} diff --git a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php index 44b28d4..a495973 100644 --- a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php +++ b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php @@ -104,6 +104,24 @@ class BakeExtraHelper extends Helper return $coll->take($takeFields)->toArray(); } + + public function filterFieldsOther($fields, $controllerName) { + + $takeFields = Hash::get($this->_config, "taskParams.$controllerName.index-columns"); + if ( $takeFields === NULL ) + $takeFields = Hash::get($this->_config, "taskParams.default.index-columns"); + //$filterTypes = ['binary']; // TODO + $rejectFields = ['id']; + + $coll = collection($fields); + $coll = $coll->reject(function ($field, $key) use ($rejectFields) { + return in_array($field, $rejectFields); + }); + + return $coll->take($takeFields)->toArray(); + } + + public function getTitleOpts($controllerName) { if ( ! is_string($controllerName) ) return FALSE; return Hash::get($this->_config, "templateExtra.$controllerName.title"); |