summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-22 11:19:39 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-22 11:19:39 +0200
commitb49f4d5ccd5a61e901c448ad94495750bb2d0269 (patch)
tree669df8cff368242c879496a7452d9c5c58cb4f74
parent83d0f1154f2e068410ea592dd290c698cc6dd729 (diff)
downloadchd_gestion-b49f4d5ccd5a61e901c448ad94495750bb2d0269.zip
chd_gestion-b49f4d5ccd5a61e901c448ad94495750bb2d0269.tar.gz
chd_gestion-b49f4d5ccd5a61e901c448ad94495750bb2d0269.tar.bz2
bake: fix Search filter support (bad stringifyList())
-rw-r--r--app-from-scratch.sh9
-rw-r--r--fai_gestion/config/bake_extra.php36
-rw-r--r--fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php36
3 files changed, 61 insertions, 20 deletions
diff --git a/app-from-scratch.sh b/app-from-scratch.sh
index c0d9811..5d35c2b 100644
--- a/app-from-scratch.sh
+++ b/app-from-scratch.sh
@@ -360,3 +360,12 @@ git add plugins/CustomTheme/config/bootstrap.php plugins/CustomTheme/src/Templat
git add config/bake_extra.php
git add ../app-from-scratch.sh
git commit -m "bake: implement virtual entity titles"
+# 748b7bf7c5c4df2d546ae375d9c13b5657e431df
+
+# bake: fix Search filter support (bad stringifyList())
+editor plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php
+editor config/bake_extra.php
+git add plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php
+git add config/bake_extra.php
+git add ../app-from-scratch.sh
+git commit -m "bake: fix Search filter support (bad stringifyList())"
diff --git a/fai_gestion/config/bake_extra.php b/fai_gestion/config/bake_extra.php
index 1f7fe4f..897219b 100644
--- a/fai_gestion/config/bake_extra.php
+++ b/fai_gestion/config/bake_extra.php
@@ -85,8 +85,8 @@ EOT
'filters' => [
'q' => [
'mode' => 'like',
- 'before' => 'true',
- 'after' => 'true',
+ 'before' => true,
+ 'after' => true,
'field' => ['id','nom','nom2','prenom','prenom2','raison','proprio','tel_mobile1','tel_mobile2'],
'colspan' => 3,
'hint' => 'Chercher...',
@@ -104,14 +104,20 @@ EOT
],
],
'Equipements' => [
+ 'order' => [
+ 'Equipements.hostname' => 'ASC',
+ ],
+ 'orderHook' => [
+ 'Equipements.ip_management' => 'INET_ATON(Equipements.ip_management)',
+ ],
'title' => [
'pieces' => ['hostname', 'ip_management'],
],
'filters' => [
'q' => [
'mode' => 'like',
- 'before' => 'true',
- 'after' => 'true',
+ 'before' => true,
+ 'after' => true,
'field' => ['hostname', 'mac_boite', 'ip_management'],
'colspan' => 3,
'hint' => 'Hostname, IP, MAC...',
@@ -129,6 +135,10 @@ EOT
],
],
'EquipementModeles' => [
+ 'order' => [
+ 'EquipementModeles.constructeur' => 'ASC',
+ 'EquipementModeles.modele' => 'ASC',
+ ],
'title' => [
'glue' => ' - ',
'pieces' => ['constructeur', 'modele'],
@@ -138,8 +148,8 @@ EOT
'filters' => [
'q' => [
'mode' => 'like',
- 'before' => 'true',
- 'after' => 'true',
+ 'before' => true,
+ 'after' => true,
'field' => ['nom', 'prenom', 'date_demande', 'raison'],
'colspan' => 5,
'hint' => 'Chercher...',
@@ -151,16 +161,19 @@ EOT
],
],
],
- 'Ippubliques' => [
+ 'IpPubliques' => [
+ 'orderHook' => [
+ 'IpPubliques.ip4' => 'INET_ATON(IpPubliques.ip4)',
+ 'IpPubliques.ip6' => 'INET6_ATON(IpPubliques.ip6)',
+ ],
'title' => [
- 'glue' => ' ',
'pieces' => ['ip4', 'ip6'],
],
'filters' => [
'q' => [
'mode' => 'like',
- 'before' => 'true',
- 'after' => 'false',
+ 'before' => true,
+ 'after' => false,
'field' => ['ip4','ip6'],
'colspan' => 2,
'hint' => 'Derniers chiffres...',
@@ -173,6 +186,9 @@ EOT
],
],
'LienRadios' => [
+ 'order' => [
+ 'LienRadios.ssid' => 'ASC',
+ ],
'title' => [
'pieces' => ['ssid'],
],
diff --git a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php
index 6063ba5..c70be2e 100644
--- a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php
+++ b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php
@@ -61,19 +61,14 @@ class BakeExtraHelper extends Helper
return $extraModels;
}
public function stringifySearchManagerConfig($filterConfig) {
- $field = array_key_exists('field', $filterConfig)?$filterConfig['field']:FALSE;
- unset($filterConfig['field']);
+ // Do not output Model & Template specific options here
unset($filterConfig['mode']);
unset($filterConfig['colspan']);
unset($filterConfig['hint']);
- $s = '';
- if ($field) {
- $s .= "\n 'field' => [";
- $s .= $this->Bake->stringifyList($field, ['indent'=>4]);
- $s .= "],";
- }
- $s .= $this->Bake->stringifyList($filterConfig, ['indent'=>3]);
- return $s;
+ //Bake::stringifyList() has bugs with nested array + option quotes in Cake 3.6.7
+ $s = var_export($filterConfig, true);
+ $s = str_replace([ 'array (', ')'], ['[', ']'], $s);
+ return trim($s, '[]') . ' ';
}
public function hasAction($action, $controllerName) {
@@ -103,4 +98,25 @@ class BakeExtraHelper extends Helper
return Hash::get($this->_config, "templateExtra.$controllerName.title");
}
+ public function hasOrderOpts($controllerName) {
+ if ( ! is_string($controllerName) ) return FALSE;
+ $orderOpts = $this->getOrderOpts($controllerName);
+ return (is_array($orderOpts) && count($orderOpts) > 0);
+ }
+
+ public function getOrderOpts($controllerName) {
+ if ( ! is_string($controllerName) ) return FALSE;
+ return Hash::get($this->_config, "templateExtra.$controllerName.order");
+ }
+
+ public function hasOrderHooks($controllerName) {
+ if ( ! is_string($controllerName) ) return FALSE;
+ $orderHooks = $this->getOrderHooks($controllerName);
+ return (is_array($orderHooks) && count($orderHooks) > 0);
+ }
+
+ public function getOrderHooks($controllerName) {
+ if ( ! is_string($controllerName) ) return FALSE;
+ return Hash::get($this->_config, "templateExtra.$controllerName.orderHook");
+ }
}