From bb9ca6e69d68548a0f7f8e49d3abf8cd1340e243 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Thu, 4 Nov 2021 15:21:03 +0100 Subject: [PATCH] fix: [Component:CRUD] Make set quickfilter works again Call the function with correct number of argument --- src/Controller/Component/CRUDComponent.php | 15 ++++++++------- src/Controller/MailingListsController.php | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index d5024ee..e6f61f0 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -363,12 +363,6 @@ class CRUDComponent extends Component if (isset($params['beforeSave'])) { $data = $params['beforeSave']($data); } - /* - - Update meta_field table: - - Add created and modified - - Update meta_template_field_table: - - Add counter column - */ $savedData = $this->Table->save($data); if ($savedData !== false) { if (isset($params['afterSave'])) { @@ -506,6 +500,13 @@ class CRUDComponent extends Component $params['contain'][] = 'Tags'; $this->setAllTags(); } + if ($this->Table->hasBehavior('MetaFields')) { // TODO: check if has meta field behavior + if (!empty($this->request->getQuery('full'))) { + $params['contain']['MetaFields'] = ['MetaTemplateFields' => 'MetaTemplates']; + } else { + $params['contain'][] = 'MetaFields'; + } + } $data = $this->Table->get($id, $params); $data = $this->attachMetaData($id, $data); @@ -804,7 +805,7 @@ class CRUDComponent extends Component $this->Controller->set('quickFilter', empty($quickFilterFields) ? [] : $quickFilterFields); if (!empty($params['quickFilter']) && !empty($quickFilterFields)) { $this->Controller->set('quickFilterValue', $params['quickFilter']); - $queryConditions = $this->genQuickFilterConditions($params, $query, $quickFilterFields); + $queryConditions = $this->genQuickFilterConditions($params, $quickFilterFields); $query->where(['OR' => $queryConditions]); } else { $this->Controller->set('quickFilterValue', ''); diff --git a/src/Controller/MailingListsController.php b/src/Controller/MailingListsController.php index 1cc60d1..2cb11ca 100644 --- a/src/Controller/MailingListsController.php +++ b/src/Controller/MailingListsController.php @@ -109,7 +109,7 @@ class MailingListsController extends AppController 'Individuals' => function (Query $q) use ($queryParams, $quickFilter, $matchingMetaFieldParentIDs) { $conditions = []; if (!empty($queryParams)) { - $conditions = $this->CRUD->genQuickFilterConditions($queryParams, $q, $quickFilter); + $conditions = $this->CRUD->genQuickFilterConditions($queryParams, $quickFilter); } if (!empty($matchingMetaFieldParentIDs)) { $conditions[] = function (QueryExpression $exp) use ($matchingMetaFieldParentIDs) {