From 3e36cb559251cb098195e107770d5a11dae2028d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jan 2018 22:59:53 -0500 Subject: [PATCH 1/5] docs: clarify how to use the ViewSearchListener The parameters were incorrect for usage with Crud. --- docs/_partials/pages/index/filters.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/_partials/pages/index/filters.rst b/docs/_partials/pages/index/filters.rst index 8fac995d..d8d3feba 100644 --- a/docs/_partials/pages/index/filters.rst +++ b/docs/_partials/pages/index/filters.rst @@ -12,7 +12,7 @@ to be installed and filters configured for your model using the search manager. public function index() { $this->Crud->addListener('Crud.Crud'); - $this->Crud->addListener('Crud.ViewSearch', [ + $this->Crud->addListener('viewSearch', 'CrudView.ViewSearch', [ // Indicates whether is listener is enabled. 'enabled' => true, @@ -51,8 +51,9 @@ Here's an e.g. of how configure filter controls options through search manager i addBehavior('Search.Search'); $this->searchManager() - ->useCollection('backend') + ->useCollection('default') ->add('q', 'Search.Like', [ 'field' => ['title', 'body'], 'form' => [ From 10569dc81c763d2b3be39bac3368e227e560fa63 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jan 2018 23:08:18 -0500 Subject: [PATCH 2/5] docs: fix reference to Crud.Search plugin [ci skip] --- docs/_partials/pages/index/filters.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/_partials/pages/index/filters.rst b/docs/_partials/pages/index/filters.rst index d8d3feba..46e29ac7 100644 --- a/docs/_partials/pages/index/filters.rst +++ b/docs/_partials/pages/index/filters.rst @@ -11,7 +11,13 @@ to be installed and filters configured for your model using the search manager. class SamplesController extends AppController { public function index() { - $this->Crud->addListener('Crud.Crud'); + // Enable the search listener + $this->Crud->addListener('search', 'Crud.Search', [ + // The search behavior collection to use. Default "default". + 'collection' => 'admin', + ]); + + // Enable the ViewSearch listener $this->Crud->addListener('viewSearch', 'CrudView.ViewSearch', [ // Indicates whether is listener is enabled. 'enabled' => true, From 7aa9f8e5d116d6983f643bf6965530ed8b057cca Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jan 2018 23:15:49 -0500 Subject: [PATCH 3/5] docs: add reference to the PrgComponent --- docs/_partials/pages/index/filters.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/_partials/pages/index/filters.rst b/docs/_partials/pages/index/filters.rst index 46e29ac7..630e4bd1 100644 --- a/docs/_partials/pages/index/filters.rst +++ b/docs/_partials/pages/index/filters.rst @@ -10,8 +10,19 @@ to be installed and filters configured for your model using the search manager. loadComponent('Search.Prg', [ + 'actions' => [ + 'index', + ], + ]); + } public function index() { - // Enable the search listener + // Enable the SearchListener $this->Crud->addListener('search', 'Crud.Search', [ // The search behavior collection to use. Default "default". 'collection' => 'admin', From dc91a6f2cfa7e64b33cdd783012837066c9ec231 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jan 2018 23:20:36 -0500 Subject: [PATCH 4/5] docs: clarify the Table example [ci skip] --- docs/_partials/pages/index/filters.rst | 47 ++++++++++++++++---------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/docs/_partials/pages/index/filters.rst b/docs/_partials/pages/index/filters.rst index 630e4bd1..8798fd40 100644 --- a/docs/_partials/pages/index/filters.rst +++ b/docs/_partials/pages/index/filters.rst @@ -8,8 +8,11 @@ to be installed and filters configured for your model using the search manager. .. code-block:: php Crud->addListener('search', 'Crud.Search', [ @@ -67,19 +71,28 @@ Here's an e.g. of how configure filter controls options through search manager i .. code-block:: php addBehavior('Search.Search'); - $this->searchManager() - ->useCollection('default') - ->add('q', 'Search.Like', [ - 'field' => ['title', 'body'], - 'form' => [ - 'data-foo' => 'bar' - ] - ]) - ->add('category_id', 'Search.Value', [ - 'form' => [ - 'type' => 'select', - 'class' => 'no-selectize' - ] - ]); + namespace App\Model\Table; + use Cake\ORM\Table; + + class SamplesTable extends Table + { + public function initialize(array $config) + { + parent::initialize($config); + $this->addBehavior('Search.Search'); + $this->searchManager() + ->useCollection('default') + ->add('q', 'Search.Like', [ + 'field' => ['title', 'body'], + 'form' => [ + 'data-foo' => 'bar' + ] + ]) + ->add('category_id', 'Search.Value', [ + 'form' => [ + 'type' => 'select', + 'class' => 'no-selectize' + ] + ]); + } + } From 4531c17fcb512c1cc163e20b496b704e3d76c05c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jan 2018 23:47:54 -0500 Subject: [PATCH 5/5] docs: add a return statement --- docs/_partials/pages/index/filters.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/_partials/pages/index/filters.rst b/docs/_partials/pages/index/filters.rst index 8798fd40..574af032 100644 --- a/docs/_partials/pages/index/filters.rst +++ b/docs/_partials/pages/index/filters.rst @@ -25,7 +25,8 @@ to be installed and filters configured for your model using the search manager. ]); } - public function index() { + public function index() + { // Enable the SearchListener $this->Crud->addListener('search', 'Crud.Search', [ // The search behavior collection to use. Default "default". @@ -62,7 +63,7 @@ to be installed and filters configured for your model using the search manager. ] ]); - $this->Crud->execute(); + return $this->Crud->execute(); } }