summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-23 20:25:21 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-23 20:25:21 +0200
commit4e2624a23f056b985a7613fe6c648e9abb20e261 (patch)
tree77414e32d15fe43f870c13312f1b333c260cafab
parent275785bef739bc3959cd7b1c671e53a30355c897 (diff)
downloadchd_gestion-4e2624a23f056b985a7613fe6c648e9abb20e261.zip
chd_gestion-4e2624a23f056b985a7613fe6c648e9abb20e261.tar.gz
chd_gestion-4e2624a23f056b985a7613fe6c648e9abb20e261.tar.bz2
bake : action view, limit and filter fields displayed
-rw-r--r--fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig5
-rw-r--r--fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php18
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");